Forum Discussion
Pass a variable in topic to agent flow
Hi there,
How do we pass an output variable from a topic to be used as input in agent flow?
I have stored the output of an action into a variable.
In my agent flow, I could not find my variable from my topic.
Any advice how to do that? Thank you
You're looking in the wrong place for the variable, and that's the bit that trips most people up — the flow can't see topic variables at all. The handoff happens where the topic calls the flow, not inside the flow designer. And your second screenshot actually shows why it's stuck: the input on your trigger is called Data entity, but its type reads Unknown. A topic variable can't be matched to an input with no type, so nothing shows up to pick.
Start there. In the flow designer, click that input on the When an agent calls the flow trigger and give it a proper type — Text, for a data entity name — then publish the flow again. The flow also needs a Respond to the agent action at the end, and it has to be published before the agent can use it at all.
Then add it to the agent as a tool: Tools, Add a tool, Flow, pick the published flow, Add and configure, and under Inputs choose how each input gets filled. Finally, back in your topic, add an action node that calls the flow, and for its input pick your topic variable from the variable picker. The variable's type has to match the input's type, which is exactly what the Unknown type was blocking. So the variable never lives in the flow; it just gets handed over at the moment the topic calls it. If the flow doesn't appear in the Tools list at all, it's usually because it isn't published yet, or it doesn't have that agent trigger.
2 Replies
- maskwill53Tin Contributor
In Copilot Studio, you need to explicitly define an input for your Agent Flow.
1. Open your Agent Flow.
2. Add an input variable under Inputs and set its data type.
3. Save and publish the flow.
4. Return to your topic and add the Agent Flow action.
5. Map your topic variable to the corresponding flow input.
6. Save and test.
Important: Topic variables are not automatically available inside Agent Flows. You must explicitly pass them as input parameters.
- AmezingtechsataraIron Contributor
You're looking in the wrong place for the variable, and that's the bit that trips most people up — the flow can't see topic variables at all. The handoff happens where the topic calls the flow, not inside the flow designer. And your second screenshot actually shows why it's stuck: the input on your trigger is called Data entity, but its type reads Unknown. A topic variable can't be matched to an input with no type, so nothing shows up to pick.
Start there. In the flow designer, click that input on the When an agent calls the flow trigger and give it a proper type — Text, for a data entity name — then publish the flow again. The flow also needs a Respond to the agent action at the end, and it has to be published before the agent can use it at all.
Then add it to the agent as a tool: Tools, Add a tool, Flow, pick the published flow, Add and configure, and under Inputs choose how each input gets filled. Finally, back in your topic, add an action node that calls the flow, and for its input pick your topic variable from the variable picker. The variable's type has to match the input's type, which is exactly what the Unknown type was blocking. So the variable never lives in the flow; it just gets handed over at the moment the topic calls it. If the flow doesn't appear in the Tools list at all, it's usually because it isn't published yet, or it doesn't have that agent trigger.