If you’re developing a bot in Microsoft Copilot Studio and need to store and process user inputs, understanding how to create custom variables is essential. Whether you’re working with topic-specific variables or global variables that persist throughout conversations, this guide will walk you through the setup process, ensuring that your Copilot bot efficiently stores and uses data.
Types of Variables in Copilot Studio
- Topic Variables: These variables are specific to the current conversation topic. The information is stored only within that topic, so if the conversation moves to another topic and then returns, the data will no longer be accessible.
- Global Variables: Unlike topic variables, global variables are accessible throughout the entire conversation. They persist no matter which topic the user is interacting with.
Creating Custom Variables
To begin, let’s create a new custom variable. Here’s how you can set it up:
- Navigate to Copilot Studio:
- Open your Copilot project (in this case, a coffee bot example).
- Select the topic where you want to create the variable (e.g., the “Coffee Order” topic).
- Creating a Variable:
- Variables are essentially containers used to store user input. They can store text, numbers, dates, or even boolean values.
- In Copilot Studio, click the “Add a new conversation node” button, and select “Ask a Question.”
- This will create a new variable that stores the user’s response.

Setting Variable Types
Variables in Copilot Studio are automatically assigned types based on the first user interaction. These types determine the kind of data the variable can store:
- String: Text data.
- Boolean: Yes/No values.
- Number: Numeric values.
- Date & Time: Specific date and time values.
Make sure that the type of variable aligns with the data you’re storing. For instance, you cannot store text in a date-time variable.
Example: Coffee Order Bot
In this example, we’re building a coffee order bot that asks the user for their preferred coffee roast type:
- Light Roast
- Medium Roast
- Dark Roast
How to Use the Variables:
- Ask a Question:
- In the bot, ask a question like, “What type of coffee would you like?”
- Store the Response:
- The user’s response (e.g., “Light Roast”) will be stored in a variable for further use.
- Use the Variable:
- Once the response is captured, the bot can reference the variable in future conversation nodes, such as confirming the order: “Got it! You’d like a Light Roast coffee.”
Troubleshooting Common Issues
Sometimes, you might encounter issues like incorrect data types or lost values when switching between topics. If this happens, ensure that you’re using the correct variable types and that the variables are properly defined at the beginning of each topic.
Final Tips
- Always test your bot to ensure that variables are capturing and using data as expected.
- Remember that variables are powerful tools for personalizing conversations and improving user experience.
In Conclusion
By setting up custom variables, you can enhance the functionality of your Copilot Studio bots and create more efficient, engaging interactions with your users.
Thanks for reading. Happy Developing!