Condition Step

Tahsim Ahmed
Tahsim Ahmed
  • Updated

How do I create conditional paths? How do I create conditions?

As conversation designers, we are in control of every action, intent and function our conversation carries out.

We can add another element to our conversations/assistants that will alter the conversation's path: Conditions.

Similar to programming, conditions are basic “if, then” logic functions/paths that modify how our conversations are executed. Conditions are a key part of the flow/path-selection or following process for your conversations.

Ex. Conditions are part of our everyday lives. As people, we can think about situations and make decisions based on what we observe or know to be true. For example, “If it is raining out, then we will have recess inside.” Or “If it is my birthday, then I can have a birthday cake.” Conditions are cause and effect: “If this, then that.”

Conditions allow us to control what the conversation does and perform different actions based on these “if, then” logic statements.

Since conversations are interfaces that can’t do anything without the designer and/or user directing them, we direct the conversation using the Condition Step. This tells the conversation what to do and the flow/path to do it.

The Condition Step allows you to send the user down different conversation paths depending on the value of variable and associated conditions.

By default, your first Condition step will have one condition field ready to be configured. Conditions are checked from top-to-bottom.

Adding Conditional Paths

The Condition Step can have multiple condition paths. To create a path, click on Add Condition (6). You can choose to assign a label (2) to your Condition(s).

Note: Similar to the Set Step, each condition has a label that you can use to provide a plain-language description of the condition that will be displayed on the assistant canvas.

Remember that if you do not provide a label, the actual condition statement (code-friendly view of the logic expression) will appear on the canvas instead.

Building a Condition

The Condition Step provides you the flexibility to check/evaluate multiple pieces of logic or functions. Your condition can be an evaluation of four items:

  • Variable - you will define a variable from your assistant (ie. Set or Input), and the set value will be evaluated
  • Value - this is a static, plain text value you can define
  • Logic Group - this is a collection of conditions using and/or statements
  • Expression - this is a Javascript expression. For the condition to work, it must be a valid JavaScript statement that evaluates to "True"

Nesting Multiple Conditions/Logic Groups

You can get pretty sophisticated with your logic in your conversations with the Condition step. You can add multiple sub-conditions (4) to get specific with your desired condition.

Under your main desired condition, you can hit 'Add a Condition' to add an additional Variable, Value or Logic Group to your sub-condition.

These subconditions can be nested under your main condition as an 'AND' or 'OR'. Under traditional programming logic, these conditions can either be conditional of being both conditions required to be fulfilled (AND) or one condition or the either (OR).

Evaluating Conditions

Every condition evaluates the value of a variable you select against another value you define. If the variable is equal to the value you defined, the path will activate.

Ex.You can select and compare a variable such as {score} to the value of '5' ; meaning if the {score} variable has been filled and is equal to '5' , the conversation will follow that condition statement's path.

Note: Conditions require exact matches. Condition statements require exact matches when comparing the selected variable and value. This means if you are comparing an {animal} variable and value of "dog", and the user says "Dog" with a capital D and ends up being stored in the {animal} variable, then the condition will not be met as it is not an exact match.

Adding Actions to Conditions

In addition to porting a connection in your Condition step, you can use Actions (5) to nest navigation and backend logic in a single Condition within the step. This can be configured under the Actions menu, following each respective Condition configuration & selection.

Under the Condition step, you can perform these nested actions per Choice:

  • Go to Block - Goes to a specific block referenced within the assistant
  • Go to Intent - Goes to an existing intent contained in the assistant
  • End - Ends the conversation at its current state
  • Set variable - Allows you to set and change the value of variables
  • API - Allows you to set up, configure and execute API calls & functions
  • Code - Allows you to set up and code custom Javascript functions & commands
Tip: Learn more about Actions in-depth and in detail here.

The No Match Path

The No Match condition path (7) within the Condition Step is similar to that of the Choice Step as it is activated when none of the other paths can be activated. You can select what you want to happen when a No Match occurs. Either you can have the assistant end the conversation, or it can follow a path. 

You can configure this by navigating into No Match inside the Condition step and configure the No Match Type to either Path or None. Editing Path Label displays changes to the label that is shown on the assistant canvas for this path.

Was this article helpful?

0 out of 2 found this helpful

Have more questions? Submit a request



Article is closed for comments.