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

    Screenshot of the Run a flow from Copilot flow trigger.

  • Response action: Respond to Copilot

    Screenshot of the Respond to Copilot response action.

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

  1. Go to the Topics page for your copilot.

  2. Open the authoring canvas for the topic from which you want to call a flow.

  3. Select Add node (+) below an existing node to add a new node.

  4. In the node selection window, select Call an action, Basic Action and then select Create a flow.

    Screenshot of the Create a flow option in the Call an action menu.

    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.

    Screenshot of the Power Automate flow template called from Copilot Studio.

    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.

  1. Select the name of the flow and rename it Get weather forecast.

    Screenshot of flow name selected.

  2. Add the following input parameters to the Run a flow from Copilot trigger:

    • City (Text)
    • Zipcode (Number)

    Screenshot of input parameters for Power Automate flow.

  3. Select Add an action to create a new action below the Run a flow from Copilot flow trigger.

    Screenshot of the Add flow action button.

  4. Search for MSN weather, and then select the Get forecast for today action.

    Screenshot of the Get forecast for today action under the MSN Weather connector.

  5. In the Get forecast for today action, in the Location box, select Add dynamic content, and then select City and Zipcode.

    Screenshot of variables added to the Get forecast for today action

  6. 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

    Screenshot of dynamic output variables added to the flow response action.

  7. 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.

  1. Go to the Power Automate portal and use the Environment selector at the top right to choose the environment where your flow is stored.

  2. Navigate to My flows in the left side and search for the flow.

  3. Select the flow.

    Screenshot of the Get weather forecast flow in the Default Solution.

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.

  1. Select New step.

  2. Search for Copilot and select Run a flow from Copilot.

  3. Select New step.

  4. 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.

  5. 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:

  1. Open your flow and find the Respond to Copilot action(s).

  2. Select the Settings tab.

  3. Set Asynchronous Response to Off, and then select Done.

    Screenshot of the Asynchronous Response toggle.

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:

  1. Go to the Power Automate portal.

  2. Go to Solutions and either select an existing solution or create a solution for your flows.

    To create a solution, select New solution.

    Screenshot of the New solution button.

    Give your new solution a name, select CDS Default Publisher in the Publisher field, enter a Version number, and then select Create.

    Screenshot of solution properties.

  3. On the Solutions tab, go to the solution you want to use. Select Add existing to add a flow to it.

    Screenshot of the Add existing button.

  4. On the Add existing flow page, select the From solutions tab, select your flow, and then select Add.

    Screenshot of the list existing flows in solutions.

    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.

    Screenshot of the list of existing flows outside of solutions.