This section dives deep into variable management in Copilot Studio, covering global variables for seamless data sharing, Power Fx formulas for dynamic logic and complex expressions, and topic input/output parameters for collecting, validating, and passing information between topics.
By combining these features, you can build intelligent, context-aware conversational agents that remember user inputs, perform calculations, validate responses, and generate personalized messagesβenabling smarter, more interactive, and seamless conversation flows.
Variables store user responses during a conversation. For example, when a user provides their name, you might store it in a variable like UserName.
By default, variables are topic-scoped, meaning they can only be used within the topic where they were created.
But what if you want to reuse that data across multiple topics?
π Thatβs where global variables come in.
Imagine this flow:
Without global variables, you'd need to ask again β
With global variables, the agent already remembers β
You donβt create a global variable from scratchβyou convert a topic variable into a global one.
Once done: The variable gets a prefix: Global. (Example: UserName β Global.UserName)
You can use global variables in Message nodes and Question nodes by selecting the {x} variable picker.
Useful for logged-in users and CRM integrations like Dynamics 365.
Example: Pass user name and greet instantly.
Text("")
botURL?variableName=value
https://web.powerva.microsoft.com/webchat/bots/12345?UserName=Ana
dispatch({
type: "WEB_CHAT/SEND_EVENT",
payload: {
name: "pvaSetContext",
value: {
"UserName": "Ana"
}
}
});
Depending on your authentication setup, Copilot Studio provides predefined global variables for personalization and secure interactions.
Power Fx is a low-code language that uses Excel-like formulas. Use Power Fx to create complex logic that allows your agents to manipulate data. For instance, a Power Fx formula can set the value of a variable, parse a string, or use an expression in a condition.
To use a variable in a Power Fx formula, you must add a prefix to indicate its scope:
System.Global.Topic.Environment.
Example: System.Conversation.Id
You can also use literal values in formulas. Ensure they match the correct data type format:
Choice: Not supported
This example stores and outputs the customer's name in capital letters.
customerNamecapsNameUpper(Text(Topic.customerName))
Then display: HELLO {capsName}
Example: Check if a booking date qualifies for a discount (14+ days in advance).
bookingDateTopic.bookingDate > (DateAdd (Now(), 14))
Topics in Copilot Studio can have input and output parameters. When a topic redirects to another topic, these parameters allow information to be passed between topics seamlessly.
If your agent uses generative orchestration, it can automatically fill input parameters using conversation context or generate questions to collect values from the user. Similarly, outputs can be used to generate contextual responses without configuring verbatim messages within the topic.
Topic inputs and outputs can share values with other topics and actions within the same generated plan, enabling a consistent flow of information.
To add inputs or outputs for a topic:
For agents using generative AI, additional properties are available for input variables under How will the agent fill this input?:
Ensure the correct type of value is captured by specifying an entity type under Identify as.
Inputs have properties to control agent behavior:
These settings ensure the agent collects the right type of value and validates responses effectively.
When configuring inputs for topics or actions, additional settings allow you to control how your agent gathers input and validates responses.
By default, the agent uses the name and description of input parameters to automatically generate questions for missing information. You can override this behavior:
By default, agents repeat a question up to two times if the user provides an invalid answer. Options include:
Responses are validated based on the entity selected in Identify As. You can add extra validation:
Topic.Var1 < 10.Determines what happens when the agent cannot get a valid response after maximum retries:
Enable seamless data sharing across topics, helping your agent remember user inputs and maintain context throughout the conversation.
Allow dynamic logic, complex condition evaluation, and data manipulation for smarter decision-making within conversations.
Ensure accurate data capture, validate responses, configure prompts, and control reprompt behavior for a smooth, context-aware user experience.
Combining these elements allows you to create conversational agents that are intelligent, responsive, and personalized, reducing repetitive questions and optimizing interaction flows. Explore advanced patterns to make your agent truly context-aware and user-friendly.