AGENT FLOWS & AUTOMATION

Build Agent Flows & Use Them as Smart Tools

Learn how to extend your Copilot Studio agents by integrating agent flows that perform real-time actions, fetch external data, and return dynamic responses. With agent flows, your bot can go beyond conversations and execute powerful backend logic seamlessly.

This guide walks you through creating flows, modifying existing ones, calling them from agents and topics, passing data using input/output variables, and returning structured or list-based results. By the end, you'll be able to build intelligent, action-driven agents that interact with APIs, databases, and enterprise systems efficiently.

πŸ€– What is an Agent Flow Tool?

Agent flows allow your Copilot agent to:

  • 🌐 Fetch real-time data (APIs, weather, DB)
  • βš™οΈ Perform backend actions
  • πŸ” Return dynamic responses

In short, it turns your bot into a smart, action-driven assistant.

πŸ“Œ Prerequisites

  • Access to Copilot Studio
  • License with flow support
  • An existing agent with topics

βš™οΈ Key Requirements

  • Use When an agent calls the flow trigger
  • Add Respond to the agent action
  • Turn OFF asynchronous response
  • Ensure response within 100 seconds

πŸš€ Performance Tips

  • Optimize API calls
  • Reduce data payload
  • Simplify logic
  • Run long tasks after response

Keep flows fast to avoid timeout issues.

πŸ› οΈ Create an Agent Flow

  • Go to Topics page
  • Click Add node β†’ Add a tool
  • Select New Agent flow
  • Publish and return to topic
  • Save the agent

πŸ“ Input Parameters

Add inputs in trigger:

  • City (Text)
  • ZIP Code (Number)

🌦️ Weather Action

Use MSN Weather connector β†’ "Get forecast for today" and map dynamic inputs.

πŸ“€ Output Parameters

  • day_summary (Text)
  • location (Text)
  • chance_of_rain (Number)

πŸ’¬ Using the Flow in Agent

Once added, the flow is available as an action node.

  • "What’s the weather today?"
  • "Will it rain in Bangalore?"

The agent calls the flow and responds with real-time data.

πŸ” Connections

  • Supports user credentials
  • No extra setup needed in supported channels

⚠️ CMK Limitation

  • User credentials not supported
  • Use specific connections

✨ Best Practices

  • Keep flows lightweight
  • Use clear naming
  • Minimize API calls
  • Test with real queries

πŸš€ Final Thought

Agent flows transform your bot into a powerful assistant capable of real-world actions and integrations.

πŸ”„ Modify Existing Flow

You can reuse an existing flow by updating it to work with agents.

  • Replace old trigger
  • Add agent-compatible response
  • Ensure real-time execution

πŸ“Œ Requirements

  • Use When an agent calls the flow
  • Add Respond to the agent
  • Turn OFF async response
  • Respond within 100 seconds

βš™οΈ Update Trigger & Response

  • Delete existing trigger
  • Add When an agent calls the flow
  • Add Respond to the agent action
  • Ensure same outputs across all branches

⏱️ Performance Rules

  • Response must be under 100 seconds
  • Optimize queries & logic
  • Reduce data size
  • Run long tasks after response

⚑ Real-Time Response Required

Agent flows must return data synchronously.

  • Turn OFF Asynchronous response
  • Otherwise, agent shows error: Error code 3000

Check this in Respond to the agent β†’ Settings.

🧭 Locate Your Flow

  • Go to Power Automate
  • Select My flows
  • Search and open your flow
  • Click Edit

βž• Add Required Actions

Add Copilot trigger and Respond action. These are mandatory for agent integration.

πŸ“¦ Add Flow to Solution

Flows must be inside a solution in the same environment as your agent.

  • Go to Solutions in Power Automate
  • Create new or open existing solution
  • Select Add existing β†’ Cloud flow
  • Choose your flow and add it

πŸ†• Create New Solution

  • Click New solution
  • Enter name and version
  • Select default publisher
  • Click Create

🌍 Environment Tip

Ensure your flow and agent are in the same environment. Use the environment selector in Power Automate.

▢️ Call an Agent Flow

Use agent flows to dynamically respond to user requests like weather forecasts.

  • Trigger flow when needed
  • Pass user inputs
  • Return real-time results

πŸ“Œ Prerequisite

Ensure you have already created the weather forecast flow before calling it.

πŸ€– Call Flow from Agent

  • Go to Agents β†’ Tools
  • Click Add a tool
  • Select your flow
  • Click Add and configure

βš™οΈ Tool Configuration

  • Provide clear name & description
  • Define input handling
  • Set completion behavior

Helps the agent decide when to use the tool.

🧩 Call Flow from Topic

Use an Action node inside a topic to trigger the flow.

  • Create topic (e.g., Get weather)
  • Add trigger phrases (weather-related queries)
  • Use Ask a question nodes for inputs
  • Add Action node to call flow

πŸ“ Collect User Inputs

  • Ask: "What is your city?"
  • Store in variable (City)
  • Ask: "What is your ZIP code?"
  • Store in variable (ZIPcode)

πŸ”— Map Inputs to Flow

Pass collected variables into the flow inputs (City & ZIP code).

πŸ“€ Use Flow Output

Display results using flow output variables.

  • "Today's forecast: day_summary"
  • "Chance of rain: chance_of_rain%"

Use dynamic values in message nodes.

πŸ› οΈ Manage Flow in Topic

  • Delete β†’ removes flow
  • Refresh β†’ sync latest changes
  • Change flow β†’ switch flow

πŸ§ͺ Testing

  • Use test panel
  • Enter trigger phrases
  • Provide inputs
  • Verify output response

⚠️ Troubleshooting

  • Check flow errors in flow checker
  • Validate topic using topic checker
  • Fix issues before saving

🚨 Error Handling

If something fails, the agent shows an error message. Always test after making changes.

πŸ” Input & Output Variables

Variables allow you to pass data between agent flows and Copilot agents.

  • πŸ“₯ Send input to flow
  • πŸ“€ Receive output from flow
  • πŸ”„ Enable dynamic responses

⚠️ Important

Agents can receive up to 1 MB of data per flow response. There’s no limit on data sent to flows.

βœ… Supported Types

  • Number
  • String
  • Boolean

❌ Unsupported Types

  • Object, Date, Timestamp
  • Lists (String, Number, Boolean, Object)

🧩 Create Topic & Flow

  • Create topic: Echo message
  • Add trigger phrase: echo
  • Add question node to capture user input
  • Save response as userResponse

βž• Add Agent Flow

  • Click Add node β†’ Add a tool
  • Select New Agent flow
  • Publish and return
  • Save topic

✏️ Rename Flow

Update flow name to Echo parameter for clarity.

πŸ“₯ Input Parameter

  • Add Text input
  • Name: String_Input

πŸ“€ Output Parameter

  • Add Text output
  • Name: String_Output
  • Map it to input value

▢️ Call Flow from Topic

  • Map String_Input to userResponse
  • Add message node
  • Insert String_Output variable

This will echo the user input back to them.

πŸ§ͺ Testing

  • Type "echo"
  • Enter any message
  • Verify same message is returned

πŸ’‘ Pro Tip

Use variables effectively to build dynamic, reusable, and interactive agent experiences.

πŸ“‹ Return a List of Results

Agents can fetch and return multiple results from external systems using flows.

  • πŸ” Connect to external systems
  • πŸ” Run search queries
  • 🧾 Format results
  • πŸ“€ Return list to agent

πŸ“Œ Example Use Case

Use Dataverse connector to search accounts and return: account name, city, and account number.

βœ… Prerequisites

  • Create flows from Copilot Studio
  • Understand input/output variables
  • Configure Dataverse search

πŸ—‚οΈ Setup Dataverse Table

  • Go to Power Apps β†’ Tables
  • Open Account table
  • Add sample data

πŸ“ Sample Data

  • Seattle β†’ Contoso Inc β†’ AC0125
  • San Francisco β†’ Contoso Residences β†’ AC0255
  • Olympia β†’ Contoso Meal Delivery β†’ AC0035

πŸ’¬ Create Topic

  • Name: Account search
  • Add trigger phrases (search account/customer)
  • Add message + question node
  • Capture input as organization

🧠 Smart Input

Use Organization entity to extract company names automatically.

βž• Add Flow

Create new agent flow and publish it before editing.

βš™οΈ Configure Flow

  • Rename flow: Search account
  • Add input: Organization (Text)
  • Add action: Dataverse β†’ Search rows

πŸ” Search Configuration

  • Use Organization as search term
  • Table: account
  • Sort: search.score desc
  • Sort: name asc

🧾 Parse JSON

Convert Dataverse response into structured data using Parse JSON action.

πŸ“¦ Initialize Variable

  • Name: ListOfAccounts
  • Type: String

πŸ” Loop Through Results

Use Apply to each and append formatted data into variable.

🧾 Format Output

Append results using format:

  • - accountnumber: name - city
  • Add line breaks for readability

πŸ“€ Return Results

  • Output name: FoundAccounts
  • Return ListOfAccounts variable

▢️ Call Flow

  • Map Organization β†’ organization variable
  • Add message: "Okay, this is what I found."

πŸ“‹ Display Results

Insert FoundAccounts variable in message node to show list.

πŸ§ͺ Testing

  • Enter search query
  • Provide organization name
  • Verify list of results

πŸ’‘ Final Tip

Always format and structure list data properly for better readability in agent responses.