In one of my previous posts about Copilot Studio, I’ve already had a look at Variables and how to work with variables. However it will be useful to take this a bit further. In this post I’m looking at all the things you can do with variables in Copilot Studio.
Types of variables in Copilot Studio
Table of Contents
It is important to understand the structure of variables in Copilot Studio. The following types of variables are available in Copilot Studio.
- Custom
- System
- Environment

Custom variables – are the variables that are created within your topic. You will find that Microsoft also refers to these as Topic Variables
System variables – are variables that supply details on the conversation. So for example you can figure out where the user is using your agent and who the user is.
Environment variables – Environment variables have been around for a while now and like in Power Automate where you can use environment variable to for example point at a SharePoint site or list, we can use the same environment variables within Copilot Studio.

Types of Variables in Copilot Studio
Yes, there is another categorisation we can look at when we look at variables. Variables can use the following data types:
| Data Type | Description |
| String | A text |
| Boolean | A true or false value |
| Number | A number |
| Table | A list of values or records. Notice that each records/value within a single table will have to use the same type |
| Record | A list of properties |
| DateTime | A Date and time |
| Choice | A list of options |
| Blank | A no value aka null |
Now with the above types we can create any data structure that we may want to use in our agents.
Records and Table of Records
Most of the above datatypes are easy to use. However tables and records has always been more complicated.
In my post about actions in Copilot Studio I already mentioned an example of a table. I used a SharePoint action that returned a table.

In the above example I just displayed the table. And later on with the following expression I selected the DisplayName property of the first record.
First(Topic.ListRootFolder).DisplayName
Important functions (like we are used to in Power Automate and Power Apps) are:
- First
- FirstN
- Last
- LastN
- Index
- CountRows
But also functions like ForAll are available. Remember earlier we had a table of JSON code returned by that SharePoint action that gives us all the SharePoint lists.
If we now wanted a table with just the list names then this will work too:
ForAll(Topic.ListRootFolder,DisplayName)

Accessing variables in Copilot Studio
Topic, System and Global give us access to the various variables.
So when we type “Topic.” in the Power Fx editor, (By the way has anyone ever mentioned this small editor expression in the classic UI in Power Automate to anyone??) then the topic variables will be suggested by the intellisense.

For System Variables we can now see that we can get to details about the Activity, Bot (Agent), ClientPluginActions, Conversation, LastMessage, Recognizer and User.

For Global Variables we first may need to create a global variable. In the Variable properties, it is easy to switch between Topic and Global varibales.

Once you have created a global variable it can be found with “Global.” in the expression editor.

Thoughts about variables and querying Objects
One important thing to notice here is that Power Automate has two ways to access properties
Object.Property
Object?['Property']
Within Copilot only the first option is available. This means that a property will need to exist to avoid any errors. Or we might have to check for the existence of the property first before querying it.
Discover more from SharePains
Subscribe to get the latest posts sent to your email.