Use variables in conditions
Your topic has currently been updated from the second lab with entities and slot filling capabilities, and it’s using dynamic data to store variables and reuse those variables in messages to provide a dynamic authoring experience. Now, you’ll use the same variable in a condition statement in Microsoft Copilot Studio.
Expand here for more details.
With condition statements in Microsoft Copilot Studio, a copilot author can determine behavior under certain conditions that can be true, false, or something else (for example, if it’s blank). Condition statements allow and promote flexibility in the authoring canvas, allowing you to provide great customer or user experiences based on their needs while limiting the need to create several similar topics. After you begin to use conditions, you’ll create branches, which create separate flows that the person who’s using the Copilot can be directed to. These branches can have their own conditions, depending on what behavior you want to create.
For more information on conditions, see Authoring using conditions.
Create a condition by using variables
In this task, you’ll create a condition based on the three variable options that were used in the custom entity in the first exercise.
-
In your authoring canvas, under the Message node that you modified in the previous task, select the plus (+) icon to add a new node and then select Add a condition.
-
Two new nodes will appear, one is your Condition and the other is an exception for All other conditions.

-
Keep the condition operator as is equal to and then select the empty box beneath to display the three available options from the selected variable. Select the Update option – make sure you click on the Enter or select a value part, and not on the chevron icon (>).
-
A completed condition should now show: if the OrderRequest is equal to Update.
-
Create two more conditions in this branch for the two other options for the OrderRequest variable (check and cancel). Select the plus (+) icon to add a node above the condition and then select Add a condition to add another conditional branch.

- Repeat the previous steps by selecting your Global.OrderRequest variable and then select the Check and Cancel options in two other conditions so that you’ll have a conditional branch with three options (including All Other Conditions), as shown in the following screenshot.

-
Under each condition node, add a Message node that will display different text depending on the condition, as shown in the following example.
One moment, I will update your order for you.
Pro tip: do things faster by selecting a node and copying it with the top-left productivity tools menu. Once copied, the node gets available to be pasted, using the same productivity tools menu or when using the (+) icon to add a new node.
-
Save your topic and then select the Test option to explore the different trigger phrases and conditions that lead the user to view different message outcomes.
Conditions are foundational tools that help you create tailored experiences based on what the user has selected or answered in previous questions. You can nest conditions within other conditions for more complex logic.
Congratulations, you’ve now completed the basics of using conditions and using variables as parameters within them.