Call a flow as an action

Learn how to use a cloud flow in Copilot Studio by giving an agent the ability to produce a weather forecast on request. In the previous example, you created a flow that fetches a weather forecast. This example uses an Action node in a topic to call the flow when a customer asks about the weather.

If you haven't already created the weather forecast flow, do that now.

Prerequisites

Call a flow from a topic

  1. In Copilot Studio, go to the Topics page for your agent.

  2. Create a new topic, and name it Get weather.

  3. Add the following trigger phrases:

    • will it rain
    • today's forecast
    • get weather
    • what's the weather

    Screenshot of trigger phrases for the 'Get weather' topic.

  4. Select the Add node icon below the Trigger node, and select Send a message.

  5. On the Message node, enter I can help you with that. in the text box.

  6. Select the Add node icon under the Message node and select Ask a question to add a Question node for the first piece of information for your flow, the city.

  7. On the Question node:

    1. Enter the question "What is your city?" in the text box.
    2. Under Identify, select User's entire response.
    3. Note the name of the variable associated with this response, Var1. You can leave the name as is, or replace it with a more meaningful name such as "City" (see Rename a variable, if needed).
  8. Proceed in the same fashion to add another Question node for the other piece of information for your flow, the ZIP code:

    1. Enter the question "What is your ZIP code?" in the text box.
    2. Under Identify, select Number.
    3. Note the name of the variable associated with this response, Var2. You can leave the name as is, or replace it with a more meaningful name (for example,"ZIPcode").
  9. Select the Add node icon under the Question node for the ZIP code, select Add an action, and then select the flow you created earlier, Get weather forecast.

  10. Set the flow inputs to the output variables from the question nodes. City (String) gets its value from Var1 (or City if you renamed it) and ZIP code (Number) gets its value from Var2 (or ZIPcode if you renamed it).

    Screenshot of the Action node showing the input and output parameters of the 'Get weather forecast' flow.

  11. Under the Action node, add a Message node, and enter a message that uses output information from the flow. For example:

    "Today's forecast for location: day_summary"
    "Chance of rain is chance_of_rain%"
    Where location,day_summary, and chance_of_rain are output parameters from your flow.

    Screenshot of the Message node with a message that uses output parameters from the flow.

  12. Select Save.

Manage a flow used in a topic

Once you have an Action node that calls a flow, you can use the following options from the node's menu to manage the flow:

  • Delete permanently deletes the node and removes the flow from the topic.

  • Refresh reloads the flow to obtain any changes you made in Power Automate, and validates it in the topic. You must fix any problems with the flow before you can save the topic.

If you would like to select or create a different flow, use the Change flow icon that appears when you hover over the flow in your Action node.

Test your flow and topic

It's a good idea to test the flow and the topic that calls it.

In the Test your agent panel, type one of the topic's trigger phrases to start a conversation with the agent. Enter your city and ZIP code when the agent asks for them. Verify that the agent returns today's weather forecast for your city and that the message looks the way you expect.

Screenshot of a test chat showing information from the 'Get weather forecast' action.

Troubleshoot your agent

Always test your agent when you make changes to topics and flows, to make sure everything still works. If the agent encounters a problem during a conversation, it responds with an error message.

Find most flow-related issues in the flow Checker. Use the topic checker to identify issues on the authoring canvas.