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.
Last updated: August 2026

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:

ScopePrefix / accessLifetime & use
TopicDefault; topic-onlyAnswers collected in one topic; pass via redirect inputs/outputs when needed
GlobalGlobal.Name (web app)Any topic in the same user session; unique names agent-wide
SystemSystem. in Power Fx; many listed in pickersPlatform context: activity, conversation, user, errors, recognizer
EnvironmentFrom Power Platform; read-only in StudioALM 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 variableMeaning
System.Activity.TextLatest user message
System.User.DisplayName / Email / IsLoggedInAuthenticated user profile fields (auth mode dependent)
System.Conversation.IdConversation identifier
System.Conversation.InTestModeTest canvas flag
System.LastMessage.TextPrevious user message
System.Error.Code / MessageOn Error trigger
System.FallbackCountUnknown-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 typeHolds
StringText
Booleantrue/false
NumberReal numbers
TableList of same-typed values
RecordName-value structure
DateTimeTemporal values
ChoiceString options with synonyms
BlankNo/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: 123 as 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:

GoalFormula idea
Concatenate"Thanks, " & Topic.Name
System accessSystem.User.DisplayName
Blank-safe logicChecks with Blank() / conditional formulas
Record constructionObject formulas for complex Action inputs
ComparisonsNumeric 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:

  1. Generative orchestration and models may use recent turns as context even when topic variables are empty.
  2. Turning off Allow ungrounded responses can block answers that rely only on prior-turn memory without a new knowledge/tool call.
  3. 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.
  4. Storing full transcripts in custom globals for logging should be a deliberate compliance decision, not an accident of System.Activity.Text accumulation.

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

PracticeWhy
Minimize what you store in globalsSession-long globals increase exposure surface
Prefer topic scope for one-off sensitive answersAutomatic narrower visibility
Clear after use (post-ticket creation)Reduces residual PII in long Teams chats
End-user credentials for Dataverse/SharePoint toolsAvoid shared identities reading everyone’s data
Never Message-node a secret environment variableMakers and logs must not print Key Vault material
Be careful with User.AccessTokenTokens are credentials; do not echo or store loosely
Card + historyUsers may scroll to older cards showing SSNs—mask inputs and confirm channel retention policies
External context variablesValidate 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 (Var1InvoiceNumber), 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

  1. Needed in one topic only? Topic variable.
  2. Needed across many topics in one session? Global.
  3. Provided by platform (user, channel, last message)? System.
  4. Environment-specific configuration / secret? Environment variable (read-only in Studio).
  5. Complex JSON from API? Parse value → Record.
  6. User said start over? Clear globals + consider conversation history clear on Teams.
  7. 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.

Test Your Knowledge

What is the default scope of a variable created by a Question node?

A
B
C
D
Test Your Knowledge

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?

A
B
C
D
Test Your Knowledge

Which practice best protects PII when an Adaptive Card collects an employee national ID before creating a ticket?

A
B
C
D