Use workflows as tools

Scenario

In this exercise, you will:

  • Create an agent
  • Create workflows
  • Add workflows as tools
  • Use tools in the agent and in topics
  • Test the agent

This exercise will take approximately 45 minutes to complete.

What you will learn

  • How workflows enable agents to perform deterministic actions
  • How to configure workflows as tools
  • How to use workflows in a topic

High-level lab steps

  • Create an agent using Copilot
  • Create a workflow to send a message to Microsoft Teams
  • Add the workflow as a tool to the agent
  • Create a workflow and add to a topic

Prerequisites

  • Have a Microsoft Entra ID account
  • Have a Copilot Studio license or have signed up for a free trial.
  • Have access to a Power Platform environment and a solution where you can create agents and related assets.
  • Have access to Microsoft Teams and permission to post messages to a Teams channel.
  • You can use:
    • the environment and Lab Exercises solution created in the ILT Setup lab, or
    • your own existing environment and solution.
  • If you do not already have an environment and solution prepared, complete the steps in the ILT Setup lab before continuing.

[!IMPORTANT] You may notice a new Copilot Studio experience that is currently in preview. These labs use the current Copilot Studio interface, so some steps and screenshots may not match the preview experience. To follow the lab instructions successfully, use the current Copilot Studio UI throughout these exercises.

Key concept: Agent components and behavior

When generative orchestration is enabled, the agent can use instructions, knowledge, topics, and tools to generate responses dynamically. The agent can use tools to perform actions in external systems, retrieve data, and send messages. Tools are typically used for performing actions or retrieving external data, while topics guide structured conversational flows.

Exercise 1 - Create an agent

In this exercise, you will create a new agent using natural language to analyze, categorize, and prioritize tasks.

Task 1.1 – Create an agent to analyze tasks

  1. In the Copilot Studio home page https://copilotstudio.microsoft.com/, verify that you are working in the environment you want to use for this exercise.

  2. Select Agents in the left-hand navigation.

  3. In the bottom-left of the Start building by describing what your agent needs to do text box, select the Agent Settings icon, which is displayed as a Cog image.

    Screenshot of the agent settings dialog.

  4. Leave English (United States) set as the primary language for the agent.

  5. In the Solution drop-down, select Lab Exercises or another solution you want to use for this exercise.

  6. Enter analyzetaskagent for the Schema name.

  7. Select Update.

  8. In the Start building by describing what your agent needs to do text box, Enter the following prompt:

    You are an agent that analyzes, categorizes, and prioritizes tasks.
    
  9. Select the Send icon.

    Once your agent has been provisioned, you may proceed with configuring your agent.

Exercise 2 - Create a workflow tool

In this exercise, you create a workflow that sends a message to Microsoft Teams. You will add this workflow to the agent.

[!NOTE] Agent responses, orchestration behavior, and tool usage may vary slightly from the screenshots shown in this lab depending on your tenant configuration and model behavior.

Task 2.1 – Create the Send Message to Teams workflow

  1. In Copilot Studio, select Tools in the left-hand navigation.

    Screenshot of Tools registry page.

  2. Select + New tool.

  3. In the New Tool dialog, select the Agent flow tile.

  4. Verify that the When an agent calls the flow trigger and the Respond to the agent action have been added to the workflow.

    Screenshot of a new workflow.

  5. Select the trigger step When an agent calls the flow and select + Add an input.

  6. Select Text.

  7. Enter Task Summary for Input and Analyzed tasks for Please enter your input.

    Screenshot of trigger properties of the flow.

  8. Select Save draft near the upper-right of the page.

  9. Select the Overview tab.

  10. In the Details section, select Edit.

    Screenshot of details properties of the flow.

  11. In the Details pane, update Flow name to Send Summary to Teams.

  12. For Description, enter Post a message to Teams with the summary of the task analysis.

  13. Select Save.

Task 2.2 - Post to Teams action

  1. Select the Designer tab.

  2. Select the + icon between the two steps in the workflow to insert a new action.

  3. Enter Teams in the Search field and select See more for the Microsoft Teams connector.

    Screenshot of searching for connector in the workflow.

  4. Select the Post message in a chat or channel action.

  5. Select Sign in.

    [!NOTE] If you receive the error “Failed to create OAuth connection: ClientWarning: The browser has blocked the connection authentication popup window”, select the pop-up blocked icon in the browser address bar and then select **Always allow pop-ups and redirects from https://copilotstudio.microsoft.com**.

  6. Select your account.

  7. In the Confirmation required dialog, select the I have verified this request and trust the source checkbox, then select Allow access.

  8. For Post as, select Flow bot.

  9. For Post in, select Channel.

  10. For Team, select a team from the list, for example, Leadership.

  11. For Channel, select a channel from the list, for example, General.

  12. For Message, use Dynamic Content to select Task Summary.

    Screenshot of Teams action in the workflow.

Task 2.3 - Response action

  1. Select the Respond to the agent node in the authoring canvas and select + Add an output.

  2. Select Text.

  3. For Enter a name, enter Message.

  4. For Enter a value to respond with, use Dynamic Content and select the Message link from the Teams action.

    Screenshot of the response action in the workflow.

  5. Select Save draft near the upper-right of the page.

  6. Select Publish near the upper-right of the page.

  7. In Copilot Studio, select Tools in the left-hand navigation to verify the workflow status is Ready.

Task 2.4 - Add workflow as a tool to the agent

  1. Select Agents from the left navigation pane.

  2. Open the Task Analysis agent.

  3. Select the Tools tab.

  4. Select + Add a tool.

  5. In the Add tool dialog, select the Workflows filter.

    Screenshot of adding a workflow as a tool.

  6. Select the Send Summary to Teams workflow.

  7. Select Add and configure.

  8. In the Details section, for Description, enter Sends a summary of the completed task analysis to a Microsoft Teams channel.

  9. Expand Additional details and select or enter the following:

    • When this tool may be used: Agent may use this tool at any time
    • Ask the end user before running: No
    • Credentials to use: End user credentials
    • Description: Please sign in to notify Teams
  10. In the Inputs section, for Fill using select Dynamically fill with AI. This allows the agent to determine the appropriate input value dynamically from the conversation context.

  11. In the Completion section, for After running, select Write the response with generative AI.

    Screenshot of the configuration of workflow as a tool.

  12. Select Save.

Task 2.5 - Update agent instructions

  1. Select the Overview tab.

  2. In the Instructions section, select Edit.

  3. Under the ## Step-by-step instructions in the agent instructions, add the following to the final step: Use the and type / and select the Send Summary to Teams tool and then enter ` when the task analysis is complete.`

    Screenshot of referencing the workflow tool in the agent instructions.

  4. Select Save.

Task 2.6 - Test the workflow tool in the agent

  1. Select the Test icon in the upper-right of the page to open the testing pane.

  2. In the Test pane, select the ellipses () next to the variables {x} icon, and toggle Show activity map when testing to On and Track between topics to Off.

    Show activity map.

  3. At the top of the Test pane, select the Start new test session icon +.

  4. When the Conversation Start message appears, your agent will start a conversation. In response, let’s try to trigger the topic that you’ve created:

    Analyze this list of tasks 1. Build an agent, 2. Test an agent, 3. Deploy an agent

  5. If prompted to connect to Microsoft Teams, select Allow.

    Screenshot of the workflow tool used when testing the agent.

  6. In a new browser tab, navigate to https://teams.cloud.microsoft/ and sign in if prompted.

  7. Navigate to the Team and channel you selected earlier in the workflow and verify the task analysis summary was posted to the Teams channel.

    Screenshot of the message in Teams.

Exercise 3 - Create a workflow tool that analyzes an Excel file in a topic

In this exercise, you will use Copilot to create a topic from a description, create a workflow tool that analyzes the tasks in an Excel file, and call the tool from a topic.

Task 3.1 - Create an Excel file

  1. In Copilot Studio, select the App launcher icon in the upper-left corner, then select OneDrive.

    Screenshot of App Launcher.

  2. If prompted, skip any welcome messages.

  3. Select + Create or upload.

  4. Select Excel workbook.

    Screenshot of creating a file in OneDrive.

  5. In the upper-left of the Excel workbook, rename the file by selecting Book and entering Operations tasks.

    Screenshot of renaming a file in OneDrive.

  6. Create the following columns in the first row:

    • Reference
    • Title
    • Description
    • Requested by
    • Priority
    • Status
  7. In the second row, enter for the first task:

    • OPS-001
    • Server Patch Update
    • Apply monthly security patches to production servers
    • IT Operations
    • High
    • Open
  8. In the third row, enter for the second task:

    • OPS-002
    • Backup Validation
    • Verify nightly backups completed successfully
    • Infrastructure Team
    • Medium
    • In Progress
  9. In the fourth row, enter for the third task:

    • OPS-003
    • Access Review
    • Review and remove inactive user accounts
    • Security Team
    • High
    • Open
  10. In the fifth row, enter for the fourth task:

    • OPS-004
    • Incident Report
    • Document root cause for recent service outage
    • Service Desk
    • Medium
    • Completed

    Screenshot of tasks in a file in OneDrive.

  11. Select the rows and columns containing data (A1:F5), and in the toolbar select the Insert tab, and select Table, then select OK.

  12. Select the Table Design tab and in the upper-left change the name of the table from Table1 to Tasks.

    Screenshot of tasks as a table in a file in OneDrive.

  13. Close the browser tab containing the Excel workbook.

  14. In OneDrive, select My files and verify that the Operations tasks Excel workbook is listed.

  15. Close the OneDrive browser tab.

Task 3.2 – Create the Analyze Excel tasks workflow

  1. In Copilot Studio, in the left-hand navigation, select Tools.

  2. Select + Add a tool.

  3. In the Add tool dialog, select the Agent flow tile.

  4. Verify that the When an agent calls the flow trigger and the Respond to the agent action have been added to the workflow.

  5. Select the trigger step When an agent calls the flow and select + Add an input.

  6. Select Text.

  7. Enter Priority for Input and Priority of Tasks for Please enter your input.

  8. Select Save draft near the upper-right of the page.

  9. Select the Overview tab.

  10. In the Details section, select Edit.

  11. In the Details pane, update Flow name to Get Task List.

  12. For Description, enter Retrieve a list of tasks with a matching priority.

  13. Select Save.

  14. Select the Designer tab.

  15. Select the + icon between the two steps in the workflow to insert a new action.

  16. Enter Excel in the Search field and select See more for the Excel Online (Business) connector.

  17. Select the List rows present in a table action.

  18. Select Sign in to create a connection.

  19. In the Sign into your account dialog, select the account you are using for this lab environment (such as MOD Administrator), select the I have verified this request and trust the source checkbox, and select Allow access.

  20. For Location select OneDrive for Business.

  21. For Document library select OneDrive.

  22. For File browse and select the Operations tasks workbook.

  23. For Table select Tasks.

    Screenshot of Excel action in the workflow.

  24. Select Show all.

  25. For Filter query, enter Priority eq ''.

  26. Move the cursor between the two single quotes and use Dynamic content to insert the Priority input parameter.

    Screenshot of Excel filter in the workflow.

  27. Select the Respond to the agent node in the authoring canvas and select + Add an output.

  28. Select Text.

  29. For Enter a name, enter Task list.

  30. For Enter a value to respond with, use Dynamic Content and select the body/value from the List rows present in a table action.

  31. Select Save draft near the upper-right of the page.

  32. Select Publish near the upper-right of the page.

  33. Select Tools in the left-hand navigation to verify the workflow status is Ready.

Task 3.3 – Add a topic to the agent

  1. Select Agents from the left navigation pane.

  2. Open the Task Analysis agent.

  3. Select the Topics tab.

  4. Select + Add a topic and select Add from description with Copilot. A new dialog window appears.

  5. In the Name your topic text box, enter Priority Tasks.

  6. In the Create a topic to… text box, enter Ask the user to choose a priority from a list containing High, Medium, and Low.

  7. Select Create.

    Screenshot of topic with a question node.

  8. Select the Priority variable in the bottom of the question node to open Variables properties.

  9. Under Usage select Global (any topic can access).

    Screenshot of global variable for a question node.

  10. Select Save.

Task 3.4 - Add workflow as a tool

  1. Select Agents from the left navigation pane.

  2. Open the Task Analysis agent.

  3. Select the Tools tab.

  4. Select + Add a tool.

  5. In the Add tool dialog, select the Workflows filter.

  6. Select the Get Task List workflow.

  7. Select Add and configure.

  8. In the Details section, for Description enter Retrieves a list of tasks for a specified priority.

  9. Expand Additional details and select or enter the following:

    • When this tool may be used: Only when referenced by topics or agents
    • Ask the end user before running: No
    • Credentials to use: End user credentials
    • Description: Please sign in to retrieve tasks
  10. In the Inputs section, for Fill using select Custom value and select the Priority global variable.

    Screenshot of the inputs of workflow as a tool.

  11. In the Completion section, for After running, select Write the response with generative AI.

  12. Select Save.

Task 3.5 - Add workflow tool to the topic

  1. Select the Topics tab.

  2. Select the Priority Tasks topic.

  3. Under the Question node, select the + icon, select Add a tool, select the Tool tab, and then select the Get Task List tool.

    Screenshot of adding a workflow as a tool to a topic.

  4. Select Save.

Task 3.6 - Update agent instructions with the topic

  1. Select the Overview tab.

  2. In the Instructions section, select Edit.

  3. Under the ## Skills in the agent instructions, add the following to the final step: Use the and type / and select the Priority Tasks topic and then enter ` to get the task list.`

  4. Select Save.

Task 3.7 - Test the workflow tools

  1. Select the Test icon in the upper-right of the page to open the testing pane.

  2. In the Test pane, select the ellipses () next to the variables {x} icon, and toggle Show activity map when testing to Off and Track between topics to On.

  3. At the top of the Test pane, select the Start new test session icon +.

  4. When the Conversation Start message appears, your agent will start a conversation. In response, let’s try to trigger the topic that you’ve created:

    Analyze the task list

  5. The Priority Tasks topic will be shown.

  6. Select Medium.

  7. If prompted to connect to Excel Online (Business), select Allow.

  8. The test pane should contain two tasks.

    Screenshot of the workflow tool used when testing the agent.

  9. In a new browser tab, navigate to https://teams.cloud.microsoft/ and sign in if prompted.

  10. Navigate to the Team and channel you selected earlier and review the two tasks posted to the channel.

    Screenshot of the message in Teams.

Summary

In this lab, you created workflow tools that are called by the agent using generative AI and from a topic.