Use Power Automate to add actions

Completed

Frequently, when a copilot interacts with customers, it might require information from other applications to provide the customer with a personalized experience. For example, if a customer asks about the weather for their location, the copilot could pass the location details, such as the customer's city and postal address, to a weather service that retrieves the forecast for their location. The forecast details can be sent back to the copilot, which can then include those values in a message back to the customer.

In Microsoft Copilot Studio these are referred to as actions. Actions call Power Automate Flows to help automate activities, call operating systems, or engage with external applications. For example, with an action that calls a Power Automate flow, it would pass the location information that is captured in the copilot to an external service and then send the forecast details back to the Microsoft Copilot Studio copilot.

Power Automate flows are called from within topics by using the Call an action node. You can use a flow that already exists in your Power Apps environment, or you can create one from within the Microsoft Copilot Studio authoring canvas. To allow a Power Automate flow to interact with a Microsoft Copilot Studio copilot, it requires a special Microsoft Copilot Studio trigger. This trigger captures data from the copilot and sends response information back to the copilot.

Power Automate provides the following trigger and action:

  • Microsoft Copilot Studio - Trigger that specifies input parameters that are captured from the Microsoft Copilot Studio copilot.

  • Return value(s) to Microsoft Copilot Studio - Action that defines output parameters that are sent back to the Microsoft Copilot Studio copilot.

When a new flow is created from a Microsoft Copilot Studio copilot, a starter template is loaded that includes the Microsoft Copilot Studio trigger and the Return values to Microsoft Copilot Studio action. You need to define the necessary input and output parameters and complete the structure of the flow.

Screenshot of create a flow menu.

Work with input and output parameters

Variables that are defined in your copilot can be to supply values to input parameters and consume values from output parameters. For example, a customer's response to the "What city do you live in?" question could be used as the value for a City input parameter.

Input parameters

Input parameters represent values that are captured in the Microsoft Copilot Studio copilot and used by the Power Automate flow steps. No limit is placed on the number of input parameters that you can add. However, you can only use number, string, and Boolean types as input parameters with Power Automate flows.

Screenshot of parameters.

Consider what type of data is required when the input parameter is passed through the flow. For example, if you intend on sending a customer's city and zip code to the MSN weather service, you might configure the input parameters as shown in the following figure.

Name Data type
City Text
Zip_Code Number

The City parameter was defined as Text because MSN Weather consumes city names as text. The Zip_Code parameter was set to Number because it's consumed as a number. Each service that Power Automate can interact with is different, so make sure that you take time to understand how it works.

When a step to get today's weather forecast from MSN Weather is added, the city and zip code are passed to the location so that MSN Weather knows what forecast to get.

Screenshot of parameters inserted into flow step.

Output parameters

Output parameters are values from a Power Automate flow that are returned to the Microsoft Copilot Studio copilot. Like input parameters, output parameters can be a string, number, or Boolean value.

Returning to the previous weather example, after the flow has received the forecast details from the MSN weather service, you create output parameters to store the details that are returned by the MSN weather service, where the values can be consumed by the Microsoft Copilot Studio copilot. For example, if you want to present the customer with a summary and chance of rain percentage for their location, you might create the following output parameters.

Name Data Type
Day_summary Text
Location Text
Chance_of_rain Number

The actual details to include come from the information that is received in the MSN forecast.

Screenshot of day summary parameter.

All flows that are created from the Microsoft Copilot Studio authoring canvas are saved in a default solution in Power Automate and they can be used by your copilots immediately.

Call a Power Automate flow as an action from a copilot

After your flow has been created, it can be initiated from your copilot topic by using the Call an action node. When you call the action, variables can be passed to the flow as input parameters. Make sure that you have created a topic with appropriate trigger phrases. For example, you can create a Get Weather topic that includes trigger phrases such as:

  • Will it rain?

  • What's the weather?

  • Get weather

Screenshot of get weather topic.

To pass location information as variables to the Power Automate flow, you need to capture them. The simplest way to accomplish this task is with the Ask a question node. You use the Identify field on the question node to define what type of data that you want to capture. For example, you could set one item on the Identify field to City and the other to Zip code. The responses to these questions are stored in variables.

After you have defined the questions that you use to capture the details, add a new Call an action conversation node to the copilot by selecting the weather flow that you created previously.

In the flow configuration, you need to map the flow input blocks to the output variables from the question nodes. For example, City (text) gets its value from City (city) and Zipcode (number) gets its value from Zip (number).

Screenshot of the get weather flow added.

Now, you should be able to observe that the Get weather Forecast flow runs and what output parameters are returned from it.

Under the flow's 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%.

Screenshot of the message node.

For more information, see Use Power Automate flows in Microsoft Copilot Studio.