Share via


Use input and output variables to pass information

Use variables as input and output parameters to pass information between agent flows and Copilot Studio agents.

Important

An agent can only receive up to 1 MB of data from a flow in a single action. However, there's no limit on how many variables or the amount of data an agent can send.

In this example, you create a flow with an input parameter and return it to an agent as an output parameter.

Prerequisites

  • Understand how to create a flow from the Copilot Studio authoring canvas

Supported parameter types

Copilot Studio agents support the following types of input and output parameters for agent flows:

  • Number
  • String
  • Boolean

The following data types aren't supported:

  • Object
  • Date
  • Timestamp
  • List [String]
  • List [Number]
  • List [Boolean]
  • List [Object]
  • List [Date]
  • List [Timestamp]

Create a topic and a flow

  1. Go to the Topics page for your agent.

  2. Create a new topic called Echo message.

  3. Add the trigger phrase echo.

  4. Add a Question node and enter the message "Tell me something and I'll say it back to you."

  5. For Identify, choose User's entire response.

  6. For Save user response as, rename the variable to userResponse.

    Screenshot of a Question node that collects the user's response.

  7. Select the Add node icon under the Question node, and select Add a tool.

  8. On the Basic actions tab, select New Agent flow. The agent flow designer tab opens with a starting template for an agent flow called by an agent. The flow includes two actions: When an agent calls the flow and Respond to the agent.

  9. Select Save draft.

  10. On the Overview tab of the flow, edit the details for the flow, replacing the name with Echo parameter. Select Save.

  11. Return to the Designer tab.

Add an input parameter to the flow

  1. Select the When an agent calls the flow flow trigger, and select Add an input.

  2. Select Text and enter the name String_Input.

    Screenshot of the flow trigger input parameter.

Add an output parameter to the flow

  1. Select the Respond to the agent response action, and select Add an output.

  2. Select Text and enter the name String_Output.

    Screenshot of the response action output parameter.

  3. For the value, enter a slash (/) in the box, select Insert dynamic content, and then select the String_Input variable.

  4. Select Save draft and Publish. Copilot Studio informs you when the agent flow is published.

  5. Select Go back to agent to return to the agent topic editor. The new action flow is added to the topic.

Call the flow from the topic

  1. Select the new action node.

  2. Set the flow input parameter to the output variable from the Question node: String_Input (string) gets its value from the userResponse variable.

    Screenshot of the Action node that calls the 'Echo parameter' flow.

  3. Add a Message node.

  4. Select Insert variable, and then select String_Output.

    Screenshot of the message node that echoes the user input.

  5. Select Save.

  6. Test your agent.

    Screenshot of an agent conversation.