Skip to content
Home » How to Create Variables in Microsoft Copilot Studio | Step-by-Step Guide

How to Create Variables in Microsoft Copilot Studio | Step-by-Step Guide

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

  1. 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.
  2. Global Variables: Unlike topic variables, global variables are accessible throughout the entire conversation. They persist no matter which topic the user is interacting with.

To begin, let’s create a new custom variable. Here’s how you can set it up:

  1. 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).
  2. 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.
creating variable in Microsoft copilot studio. variable settings

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.

How to Use the Variables:

  1. Ask a Question:
    • In the bot, ask a question like, “What type of coffee would you like?”
  2. Store the Response:
    • The user’s response (e.g., “Light Roast”) will be stored in a variable for further use.
  3. 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.”

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.

  • 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!