| title | description | keywords | ms.date | ms.topic | author | ms.author | ms.reviewer | ms.custom | ms.service | ms.collection |
|---|---|---|---|---|---|---|---|---|---|---|
Call a flow as an action |
Call a Power Automate flow from a bot topic using an action node. |
PVA, flow, automate |
07/28/2022 |
article |
iaanw |
iawilt |
peterswimm |
flow, ceX, advanced-authoring |
power-virtual-agents |
virtual-agent |
Learn how to use a cloud flow in Power Virtual Agents by giving a bot the ability to produce a weather forecast on request. In the previous example, you created a flow that fetches a weather forecast. In this example, you'll use a Call an action node in a bot 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.
-
In Power Virtual Agents, go to the Topics page for the bot you want to edit.
-
Create a new topic, and name it Get weather.
-
Add the following trigger phrases:
- will it rain
- today's forecast
- get weather
- what's the weather
:::image type="content" source="media/advanced-use-flow/create-get-weather-topic.png" alt-text="Screenshot of trigger phrases in a new topic.":::
A message node is created.
-
Enter I can help you with that in the message node, and then select Add node (+) under it to add a new node.
-
Add two Ask a question nodes for the City and Zipcode inputs the flow needs, as shown in the following example.
:::image type="content" source="media/advanced-use-flow/TopicDialogQuestions.jpg" alt-text="Screenshot of City and Zipcode question nodes in a topic.":::
Note the names of the variables associated with each response,
Var1for City andVar2for Zipcode. You can leave them as-is or select the pencil icon and give them a more meaningful name such as "City" and "Zipcode." -
Select Add node (+) under the Zipcode question node.
-
In the node selection window, select Call an action, and then select the flow you created earlier, Get weather forecast.
:::image type="content" source="media/advanced-use-flow/SelectFlowGetWeatherForecast.png" alt-text="Screenshot of a Call an action node with the Get weather forecast flow highlighted.":::
-
Assign the flow inputs to the output variables from the question nodes. City (text) gets its value from
Var1and Zipcode (number) gets its value fromVar2. If you changed the names of the variables, enter the new names instead. -
Under the flow node, add a Message node, and then enter a message that uses the flow's outputs. For example:
Today's forecast for
(x)location:{x}day_summary. Chance of rain is{x}chance_of_rain%:::image type="content" source="media/advanced-use-flow/ActionNodeGetWeatherForecast.png" alt-text="Screenshot of the flow inputs and outputs and the outputs used in a message node.":::
-
Select Save.
After you've called a flow from an action node in a bot topic, you can use the node menu to manage the flow. The Power Virtual Agents authoring canvas gives you three options:
-
Delete: Select to permanently delete the node, and the flow, from the topic.
-
Refresh flow: If you've made changes to the flow in the Power Automate portal, select to reload and validate the flow in the topic. You'll need to fix any problems with the flow before you can save the topic.
-
Replace flow: Select to open the action picker, where you can select or create a different flow.
:::image type="content" source="media/advanced-use-flow/advanced-flow-nodemanage.png" alt-text="Screenshot of flow options in the Power Virtual Agents authoring canvas.":::
It's a good idea to test the flow and the topic that calls it.
In the Test bot pane, type one of the topic's trigger phrases to start a conversation with the bot. Enter your city and zip code when the bot asks for them. Make sure the bot returns today's weather forecast and your message looks the way you expect.
:::image type="content" source="media/advanced-use-flow/GetWeatherE2E.png" alt-text="Screenshot of testing a bot.":::
Test your bot when you make changes to topics and flows to make sure everything is working. If the bot encounters a problem during a conversation, it will respond with an error message.
You'll find most flow-related issues in the Flow Checker. Any issues on the authoring canvas will appear in the topic checker.
[!INCLUDEfooter-include]