8.3 Manage Variables
Key Takeaways
- Variables have scopes: topic (default), global (session-wide), system (platform-provided), and read-only environment variables from Power Platform.
- Base types (string, boolean, number, table, record, DateTime, choice, blank) are fixed after first assignment; Power Fx formulas power complex sets and conditions.
- Set variable value, clear variable values, parse value, and redirect input/output bindings are core management nodes.
- Global values persist for the session until cleared; Reset Conversation and clear nodes matter for privacy and conversation history handling.
- Treat PII carefully: minimize storage, clear when done, prefer end-user auth context, and never echo secrets or Key Vault values into chat.
8.3 Manage Variables
Quick Answer: Capture data in topic variables by default; promote to Global. when multiple topics need the same session values; read System. context for user/activity data; use Set / Clear / Parse nodes and Power Fx; clear sensitive values and understand that reset may need explicit conversation history clearing on some channels.
Leaf skill Manage variables is the glue between questions, Adaptive Cards, generative answers, tools, and flows. AB-620 scenarios test scope choice, formula use, and what still lingers after “start over.”
Variable scopes
Microsoft describes four levels:
| Scope | Prefix / access | Lifetime & use |
|---|---|---|
| Topic | Default; topic-only | Answers collected in one topic; pass via redirect inputs/outputs when needed |
| Global | Global.Name (web app) | Any topic in the same user session; unique names agent-wide |
| System | System. in Power Fx; many listed in pickers | Platform context: activity, conversation, user, errors, recognizer |
| Environment | From Power Platform; read-only in Studio | ALM parameters and secrets configuration; republish after non-secret value changes |
Topic variables
Created automatically by Question, Ask with Adaptive Card outputs, Action outputs, and many other nodes. Best for values that should not leak across unrelated topics. Use Variables panel to mark:
- Receive values from other topics — skip re-asking when a redirect supplies the value
- Return values to original topics — expose outputs back through Redirect nodes
Passing variables between topics reduces overuse of globals when a clean call/return pattern fits.
Global variables
Change Usage to Global (any topic can access) on the Variable properties panel. Use globals when:
- Welcome collects name/email used later in booking, billing, and escalation topics
- External systems (embedded web chat, Dynamics) must seed context at conversation start
- Generative answers advanced mode stores a customized answer for later cards
Globals persist until the session ends or a Clear variable values path resets them. The Reset Conversation system topic demonstrates clearing globals—but read the fine print on history below.
External sources can set values: mark globals to accept values from Omnichannel, custom canvas pvaSetContext events, or query-string embedding (?UserName=Ana matching the name without the Global. prefix). Configure timeouts and defaults so the agent does not wait forever for context.
System variables
Always available (some only for certain triggers). High-value examples:
| System variable | Meaning |
|---|---|
System.Activity.Text | Latest user message |
System.User.DisplayName / Email / IsLoggedIn | Authenticated user profile fields (auth mode dependent) |
System.Conversation.Id | Conversation identifier |
System.Conversation.InTestMode | Test canvas flag |
System.LastMessage.Text | Previous user message |
System.Error.Code / Message | On Error trigger |
System.FallbackCount | Unknown-intent fallback counting |
Hidden system variables are reachable via Power Fx with the System. prefix. Voice-enabled agents add DTMF and speech recognition variables; auth modes may expose User.AccessToken for manual OAuth—treat tokens as secrets.
Environment variables
Defined in Power Platform for ALM. In Copilot Studio they are read-only. Types map across decimal, text, yes/no, JSON, data source, and secret. Secret values are retrieved at runtime (republish not required for secret rotation the same way as plain environment values). Warning: any maker who can edit the agent could potentially surface a secret in a Message node—governance and least privilege still apply.
Types and entities
| Base type | Holds |
|---|---|
| String | Text |
| Boolean | true/false |
| Number | Real numbers |
| Table | List of same-typed values |
| Record | Name-value structure |
| DateTime | Temporal values |
| Choice | String options with synonyms |
| Blank | No/unknown value |
Type is fixed after first assignment—assigning a number then a string errors. During test, variables may show unknown until filled. Entities on Question nodes (email, city, person name, money, custom entities) drive which type is stored and which operators Conditions allow.
Setting, clearing, and parsing
Set a variable value
Variable management → Set a variable value:
- Target an existing variable or create new
- Source: literal, another variable, or Power Fx formula
- Literals:
123as number vs"123"as string
Use Set nodes to normalize Adaptive Card outputs, compute flags (Topic.IsVip = Topic.Spend > 10000), or copy System.User.Email into a global used by flows.
Clear variable values
Clearing matters for privacy and “start over” UX:
- Clear specific variables or use patterns that clear globals (as in Reset Conversation)
- End all topics does not by itself clear globals—clear explicitly when needed
- To clear conversation history for the current session, use a Clear variable values option that targets conversation history; Microsoft notes Reset Conversation by default may not clear history, and channels like Teams retain extensive history unless you clear it intentionally
Parse value
Parse value converts JSON strings or untyped objects into Record/Table structures using sample JSON schema. Common after HTTP/flow returns. Once parsed, Power Fx IntelliSense can reach fields like Topic.ApiResult.Name.
Order of evaluation
Nodes evaluate top to bottom; condition branches left to right. Uninitialized globals referenced later can pull the conversation to the topic node that first defines them so the value is collected—powerful, but surprising if a buried Question suddenly fires mid-booking.
Power Fx formulas
Power Fx appears in Set nodes, conditions, message text, Adaptive Card Formula mode, tool inputs, and more.
Patterns to recognize on the exam:
| Goal | Formula idea |
|---|---|
| Concatenate | "Thanks, " & Topic.Name |
| System access | System.User.DisplayName |
| Blank-safe logic | Checks with Blank() / conditional formulas |
| Record construction | Object formulas for complex Action inputs |
| Comparisons | Numeric and text operators in Condition nodes |
Formulas let you avoid hard-coding environment-specific IDs—pair with environment variables for connection strings and flags.
Conversation history implications
Variables and history interact:
- Generative orchestration and models may use recent turns as context even when topic variables are empty.
- Turning off Allow ungrounded responses can block answers that rely only on prior-turn memory without a new knowledge/tool call.
- Reset / start over without history clear can leave channel transcripts visible while globals empty—users may think the agent “still knows” them from the scrollback even though variables reinitialized.
- Storing full transcripts in custom globals for logging should be a deliberate compliance decision, not an accident of
System.Activity.Textaccumulation.
Design explicit privacy topics: clear PII globals, clear history when policy requires, and confirm with the user when starting a new authenticated task.
Secure handling of PII and secrets
| Practice | Why |
|---|---|
| Minimize what you store in globals | Session-long globals increase exposure surface |
| Prefer topic scope for one-off sensitive answers | Automatic narrower visibility |
| Clear after use (post-ticket creation) | Reduces residual PII in long Teams chats |
| End-user credentials for Dataverse/SharePoint tools | Avoid shared identities reading everyone’s data |
| Never Message-node a secret environment variable | Makers and logs must not print Key Vault material |
| Be careful with User.AccessToken | Tokens are credentials; do not echo or store loosely |
| Card + history | Users may scroll to older cards showing SSNs—mask inputs and confirm channel retention policies |
| External context variables | Validate timeout defaults so stale browser query strings do not over-permission a chat |
Responsible agents treat variables as data processing, not just authoring convenience.
Practical management workflows
Workflow A — Collect once, reuse often
Welcome topic sets Global.CustomerName and Global.CustomerEmail. Booking and support topics reference globals; Conditions skip re-collection when non-blank. Reset Conversation clears globals when user says “start over.”
Workflow B — Redirect without globals
Topic A collects order number, redirects to Topic B with Add input mapping. Topic B returns shipment status variable to A. Cleaner than globals for single call chains.
Workflow C — Card → flow → clear
Adaptive Card captures employee ID and symptom text into topic variables → flow creates incident → Message confirms → Clear employee ID variable before generic survey questions continue.
Workflow D — External seed
Embedded canvas sends pvaSetContext with account tier. Global AccountTier marked for external set with timeout and default "standard". Agent greets with tier-specific quick replies without asking.
Variables panel discipline
Open Variables on the topic menu to audit every topic variable, rename defaults (Var1 → InvoiceNumber), and inspect View all references on globals before deleting. Deleting a global leaves Unknown references and can break topics—fix references first.
Exam decision tree
- Needed in one topic only? Topic variable.
- Needed across many topics in one session? Global.
- Provided by platform (user, channel, last message)? System.
- Environment-specific configuration / secret? Environment variable (read-only in Studio).
- Complex JSON from API? Parse value → Record.
- User said start over? Clear globals + consider conversation history clear on Teams.
- PII? Minimize, protect, clear, don’t print secrets.
Success checklist
- Meaningful variable names and correct types
- Scope matches reuse needs without unnecessary globals
- Power Fx used for calculations and dynamic cards/messages
- Set/Clear/Parse nodes placed consciously in canvas order
- Redirect in/out bindings reduce duplicate questions
- Session reset and history behavior documented per channel
- PII and tokens handled with security-minded defaults
Managing variables well is how Copilot Studio agents remember the right facts for the right duration—and forget them when compliance demands. That judgment is exactly what AB-620 measures under Configure topics.
What is the default scope of a variable created by a Question node?
A user says “start over.” Reset Conversation clears global variables, but the Teams transcript still shows earlier personal details. What additional step may be required?
Which practice best protects PII when an Adaptive Card collects an employee national ID before creating a ticket?