Create a flow
Learn how to use a cloud flow in Copilot Studio by giving a copilot the ability to produce a weather forecast on request. In this first example, you'll create a flow that fetches a weather forecast. In the next example, you'll call the flow as an action from a topic so the copilot can respond with the forecast when a customer asks about the weather.
To work with copilots, a Power Automate flow requires specific flow trigger and response action.
Flow trigger: Run a flow from Copilot
Response action: Respond to Copilot
When you create a flow from Copilot Studio, the trigger and the action are added for you. You can modify an existing flow for use with copilots by changing it to use these actions.
Important
To use cloud flows in custom copilots in Copilot Studio, the flows must:
- Have the Run a flow from Copilot trigger.
- Be located in a solution within the same environment as the copilot. Existing flows can be added to a solution to be available when adding actions to your copilot.
- Return a response synchronously with the Respond to Copilot action, within the 100-second action limit. To avoid timeouts, optimize the flow logic, queries, and the amount of data returned so that a typical run is below this limit. Actions that need to run longer can be placed after the Respond to Copilot action to continue executing for up to the flow run duration limit, which is typically 30 days.
Prerequisites
- Access to Copilot Studio with a license that includes the use of flows within the context of Copilot Studio creations.
Create a flow to use with a copilot
Go to the Topics page for your copilot.
Open the authoring canvas for the topic from which you want to call a flow.
Select Add node (+) below an existing node to add a new node.
In the node selection window, select Call an action, Basic Action and then select Create a flow.
The Power Automate portal opens in a new tab, with a starter flow template open for editing. The portal opens in the same environment as the copilot and uses the same user credentials.
Tip
Rename nodes to make them easier to identify. Select the node's name field to update the name directly, or select the More icon (…) of the node and select Rename from the menu. You can also rename nodes in the code editor.
It's not possible to rename Trigger nodes and Go to step nodes.
Node names can be up to 500 characters in length.
Now add actions to your flow. In this example, you add an action that fetches the current forecast from MSN Weather.
Select the name of the flow and rename it Get weather forecast.
Add the following input parameters to the Run a flow from Copilot trigger:
- City (Text)
- Zipcode (Number)
Select Add an action to create a new action below the Run a flow from Copilot flow trigger.
Search for MSN weather, and then select the Get forecast for today action.
In the Get forecast for today action, in the Location box, select Add dynamic content, and then select City and Zipcode.
In the Respond to Copilot action, add the following output parameters and variables:
Output parameter Type Variable day_summary
String Day Summary location
String Location chance_of_rain
Number Day Rain Chance Select Save.
Manage which connections are used by the flow
In a supported authenticated copilot, cloud flows can be configured to use end user credentials when they're run as a generative action or from a topic. If you are using the flow in a supported channel, this requires no special configuration in your copilot dialog, and users will be able to manage their connections while using the copilot.
Cloud flows in environments using customer-managed keys (CMK) cannot yet be run with end user credentials as generative actions or from topics. Ensure the run-only settings for cloud flows in CMK environments are set to specific connections instead of Provided by run-only user.
Modify an existing flow to use with a copilot
If you have a flow with a different trigger that you wish to use with your copilot, you can change the flow to use the Run a flow from Copilot trigger and Respond to Copilot response action, and make sure it's in a solution in the same environment as the custom copilot.
Go to the Power Automate portal and use the Environment selector at the top right to choose the environment where your flow is stored.
Navigate to My flows in the left side and search for the flow.
Select the flow.
Add the Copilot trigger and response action
If your flow doesn't already include the Copilot trigger and response action, you must add them before you can use the flow with your copilot.
Select New step.
Search for Copilot and select Run a flow from Copilot.
Select New step.
Search for the Copilot connector and select Respond to Copilot. The response action can be used at multiple branches in the flow, but must have the same outputs at each usage.
Save and publish the flow.
Ensure response action is set to return in real time
Flows that you want to use in a copilot must return values in real time, or synchronously. Flows that run in the background, or asynchronously, may cause an error when your copilot tries to run them. Instead of running the flow, the copilot will say, "Something unexpected happened. We're looking into it. Error code: 3000."
When you create a flow from Copilot Studio, asynchronous responses are turned off by default. If you modified an existing flow that has asynchronous responses turned on, follow these steps to check the setting and ensure it is turned off:
Open your flow and find the Respond to Copilot action(s).
Select the Settings tab.
Set Asynchronous Response to Off, and then select Done.
Add the flow to a solution
To be available to copilots, flows must be stored in a solution in the same Power Platform environment. If a flow is in a solution, a Solutions tile will be visible on the flow's detail page that lists which solutions the flow is in. Flows can be added to the Default Solution for use with copilots, or moved into a different solution using the below steps:
Go to the Power Automate portal.
Go to Solutions and either select an existing solution or create a solution for your flows.
To create a solution, select New solution.
Give your new solution a name, select CDS Default Publisher in the Publisher field, enter a Version number, and then select Create.
On the Solutions tab, go to the solution you want to use. Select Add existing to add a flow to it.
On the Add existing flow page, select the From solutions tab, select your flow, and then select Add.
To move a flow from the My flows tab to a solution, select Outside solutions, and then select Add to add your flow to the solution.