Our IT team asked for a small change to the SPGuides help desk agent. When someone requests a laptop, the agent should remember the model they picked, hand back a ticket number, and greet them by name, all in one reply.
The obvious move is to type that reply straight into a Message node. That breaks the moment a second employee asks, because nothing in a fixed message knows who’s asking or what they chose. Variables fix exactly that.
In this tutorial, we’ll cover how to create a variable in Copilot Studio three ways: from a Question node, with a Set variable value node and Power Fx, and as a global variable any topic can read. I built and tested every step today on a real agent.
Quick answer: Add a Question node and Copilot Studio creates a topic variable (Var1) for the answer. Select it to rename it in Variable properties. For a value you calculate, add + > Variable management > Set a variable value > Create a new variable, then pick a value or a Power Fx formula. Switch Usage to Global (any topic can access) to share it across topics.
What Are Variables in Copilot Studio?
A variable holds a value the agent can reuse later in the conversation, like an answer, a calculated ticket number or the user’s name. Every variable has a scope, and the scope decides which topics can see it and how you reference it in a formula.
| Scope | Who creates it | Where it works | Power Fx prefix |
|---|---|---|---|
| Topic | You (the default for new variables) | Only the topic that created it | Topic. |
| Global | You, by changing a topic variable’s scope | Every topic in the agent, for one session | Global. |
| System | Copilot Studio, automatically | Every topic (read-only, with a few exceptions) | System. |
| Environment | An admin, in Power Platform | Every topic, read-only in Copilot Studio | Environment. |
Variables live inside topics, so you need a topic to work in. If you haven’t built one before, start with our guide to create a custom topic in Copilot Studio and come back.
Everything here uses a standard agent with the classic topic canvas. Ours is SPGuides IT Help Desk – SharePoint, with generative orchestration on; to build one, see create a new agent in Copilot Studio. The running sample is one topic called Laptop Request.
Which Variable Types Can You Use?
Each variable gets a base type the first time you assign it a value. After that, the type is fixed. If a variable starts as a Number and you later try to store “apples” in it, you get an error.
| Type | Holds | Example from our build |
|---|---|---|
| String | Text | Global.TicketNumber |
| Choice | One of a list of options | Topic.LaptopType |
| Number | Any real number | A quantity question |
| Boolean | true or false | Conversation.InTestMode |
| DateTime | A date or time | A Date and time question |
| Table / Record | Lists or name-value pairs | Activity.Attachments (table) |
| Blank | No value yet | Shown as unknown in the canvas |
Note: a brand-new variable shows the type unknown until it receives a value. That’s normal, not an error.
How to Create a Variable in Copilot Studio From a Question Node
This is the fastest way, because Copilot Studio creates the variable for you. I added a Laptop Request topic from blank and gave the trigger a short description for The agent chooses.
Then I selected + > Ask a question and typed “Which laptop do you need?” Under Identify, I kept Multiple choice options and added Standard, Developer and Executive. Save user response as showed the default Var1 with the type choice:

Adding the options also created a Condition branch for each one plus All other conditions. I left them empty, and they join again below the question.
Important: when you add an option, click inside the new Enter option box before typing and press Tab to commit. Twice, my text vanished because the canvas re-rendered and moved focus.
Var1 tells nobody anything, so rename it. Select the Var1 chip to open the Variable properties panel, type a new name under Variable name, and leave Usage on Topic (limited scope):

I named it LaptopType, so its full name is Topic.LaptopType. The panel also shows where the value comes from (the Which laptop do you need? question), a View all references link, and a Sensitive data toggle that I left off.
How to Add Variables in Copilot Studio With a Set Variable Value Node
Questions only capture what the user types. For the ticket number, I needed a value the agent calculates, so I used a Set variable value node below the condition branches.
Select + > Variable management > Set a variable value. The same submenu has Set text variable, Parse value, List management and Clear all variables:

On the new node, select the box under Set variable. The picker has two tabs. Custom lists Create a new variable plus your existing variables, and System lists only the three system variables you’re allowed to write: ClientPluginActions, Conversation.LocalTimeZone and User.Language.
Select Create a new variable. Copilot Studio adds Var1 with the type unknown, because it doesn’t have a value yet:

Now give it a value. Open the To value picker and you get four tabs: Custom, System, Environment and Formula. You can also type a literal value; Learn notes that 123 is read as a number and “123” as a string.
I wanted a ticket number built from the current date and time, so I opened the Formula tab, typed this into the fx box and selected Insert:
"IT-" & Text(Now(), "yyyymmdd-hhmm")
The editor showed Type: String with a green output check before I inserted it. The Examples list under the box is handy if you forget the syntax:

Var1 switched from unknown to string. I renamed it TicketNumber the same way as before. The formula works because Text() formats Now() as year, month, day, hour and minute, and the & joins it to the IT- prefix.
How to Create a Global Variable in Copilot Studio
A topic variable disappears once its topic ends. I wanted the ticket number available to a follow-up topic too, like a future Check Ticket Status topic, so I made TicketNumber global.
You don’t create a global variable from scratch. You change the scope of a topic variable. In Variable properties, under Usage, select Global (any topic can access):

Note: my first click on the Global option didn’t stick, because the panel re-rendered. Check that the name box shows the Global. prefix before you move on.
Once it took, the name read Global.TicketNumber, and four new settings appeared: Allow to carry between sessions, External sources can set value, External sources can receive value, and a Variable description box. I left all of them unchecked.
The Set variable value node now shows the global name with its formula:

Three rules from Microsoft Learn are worth knowing before you go global:
- A global variable name must be unique across all topics in the agent.
- You can’t convert a global variable back to a topic variable.
- The value lasts until the session ends. A Clear variable values node, such as the one in the Reset Conversation system topic (“Start over”), resets all of them.
External sources can set value is how a website passes context in. On an embedded agent, you append the name without the Global. prefix as a query string, like ?TicketNumber=IT-1001. We cover the embed itself in publish an agent to a live or demo website.
How to Use Variables in a Message
A variable only helps once the user sees it. I added + > Send a message below the Set variable value node and typed the reply.
For each variable, I used the Insert variable {x} button on the message toolbar. It has Custom, System and Environment tabs, and I searched for User.DisplayName, Laptop and Ticket:

Here’s the full message, with one variable from each scope I’d created or used:
Thanks {System.User.DisplayName}, your {Topic.LaptopType} laptop request is logged as {Global.TicketNumber}. IT will email you within one business day.
Note: once, the Custom tab showed an empty list. Typing part of the name in the search box brought the variables back. Select Save and wait for the Topic Saved! banner.
Agent-wide wording rules, like tone or sign-offs, belong in agent instructions and conversation starters rather than in every message node.
Test the Topic and Watch the Variables
I started a new test session and typed “I need a new laptop.” The activity map showed the agent interpreting the intent and picking Laptop Request. It asked Which laptop do you need? with Standard, Developer and Executive as quick replies, and I picked Developer.
The reply came back with all three variables filled in:

Thanks Bijay Kumar [Microsoft MVP], your Developer laptop request is logged as IT-20261101-2218. IT will email you within one business day.
The display name comes from the tester’s Microsoft Entra account, and the ticket number is whatever Now() returned during the test. Every new request gets its own number without any extra setup.
To see the values, open the Variables panel inside the test pane. It listed Topic (2) with LaptopType as choice and TicketNumber as string, plus System (46) with names like Bot.Name, Conversation.Id and Conversation.InTestMode:

Hover over TicketNumber here and the tooltip shows its real name, Global.TicketNumber. Watching this panel is the quickest way to spot a variable that never got a value.
Find Every Variable in the Topic Variables Pane
Outside of testing, select Variables on the topic’s toolbar. The pane has Browse and Test tabs and groups the variables by scope:

Ours showed Topic (1) for LaptopType, Global (1) for Global.TicketNumber and Environment (16). The two checkboxes next to a topic variable are its receive and return settings, which matter when one topic redirects to another.
Pass Variables Between Topics Without Making Them Global
Global isn’t the only way to share. Learn recommends passing values between topics when only two topics need them, which keeps the global list short.
- Receive values from other topics: check this on the variable in the destination topic. When another topic redirects here and passes a value, the agent skips the question that would normally fill it.
- Return values to original topics: check this on a variable the called topic collects. It shows up as an output on the Redirect node in the calling topic.
- Redirect node: in the source topic, add a Redirect node, select Add input, pick the destination variable, then choose which value to send.
The same idea applies to tools. When a variable’s type matches a flow input, you can feed it straight in, which is how we pass details to an agent flow built in Copilot Studio.
System Variables Worth Knowing
Copilot Studio creates system variables for every agent, and they’re available in every topic. Our test listed 46 of them. These are the ones I reach for most:
| System variable | Type | What it gives you |
|---|---|---|
| User.DisplayName | string | The signed-in user’s display name (Entra authentication) |
| User.Email | string | The signed-in user’s email address |
| Activity.Text | string | The user’s most recent message |
| Recognizer.TriggeringMessage.Text | string | The message that started the current topic |
| Conversation.Id | string | The unique ID of the conversation, good for logging |
| Conversation.InTestMode | Boolean | true when you’re in the test pane |
| Bot.Name | string | Your agent’s name |
In a formula, add System. in front, as in System.User.DisplayName. Not every system variable appears in the picker, and Learn says a Power Fx formula reaches the hidden ones. The User variables depend on authentication, which we explain in manual authentication in Copilot Studio.
A practical use: save User.Email and the laptop type to a list with a flow. That’s the pattern from our post on how to create a SharePoint list item using Copilot Studio.
What About Environment Variables in Copilot Studio?
Environment variables come from Power Platform, not from your topic. They’re read-only in Copilot Studio, and they hold values that change between environments, such as a SharePoint site URL in dev versus production.
Our Variables pane showed 16 of them on the Environment tab. If you point SharePoint list knowledge in Copilot Studio at a different site per environment, this is where that URL should live.
Important: when an admin changes an environment variable, republish every agent that uses it. Secret environment variables backed by Azure Key Vault are the exception, because they’re read at runtime.
Common Errors and How to Fix Them
- The variable stays unknown. Nothing assigned it a value yet. Check that the node that sets it runs before the node that reads it.
- Type mismatch error. The type is fixed by the first value. Create a second variable instead of storing text in a number.
- Global option won’t stick. Click it again and confirm the Global. prefix appears in the name box.
- Two topics want the same global name. Global names must be unique across topics, so give each one a distinct name.
- Variable missing from the {x} list. Type part of its name in the search box.
- References show Unknown. Someone deleted a global variable that other topics used. Fix those nodes before you publish.
- The test shows old values. Start a new test session after saving.
Where to Go Next
Event triggers often read system variables like Activity.Name, so event triggers in Copilot Studio make a natural next step. Our Copilot Studio tutorials page lists everything else.
If you’d like a guided path through topics, variables and flows, the Copilot Studio training course covers them with real builds.
A few more Copilot Studio guides pair well with this one:
Frequently Asked Questions
How do I create a variable in Copilot Studio?
Add a Question node and Copilot Studio creates a topic variable for the answer, or add Variable management > Set a variable value and select Create a new variable. Select the variable to rename it in the Variable properties panel.
How do I create a global variable in Copilot Studio?
Open a topic variable’s Variable properties panel and select Global (any topic can access) under Usage. The name gets the Global. prefix. Details are in Work with global variables on Microsoft Learn.
How long does a global variable keep its value?
Until the user’s session ends, unless a Clear variable values node runs first, for example in the Reset Conversation system topic. Allow to carry between sessions is a separate option on the global variable.
Can I change a global variable back to a topic variable?
No. Microsoft Learn says a global variable can’t be converted back. Create a new topic variable instead, as described in Work with variables.
How do I use a variable in a Power Fx formula in Copilot Studio?
Add the scope prefix: Topic. for topic variables, Global. for global variables, System. for system variables and Environment. for environment variables, for example Text(Topic.LaptopType).

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.