Skip to main content

Conditions

Conditions allow you to alter your response based on entities

or context variables.

Overview

A condition consists of the following fields:

  • The name: This is what you want to name the condition to distinguish it.

  • The list of one or more rules. Rules (for environment rules see Rules

    ) all evaluate to either true or false, and consist of the following:

    • The check for attribute, which can include either an entity or a context variable.

    • An operator, which has to be one of the following:

      • is equal to
      • is not equal to
      • is greater than
      • is less than
      • contains
      • does not contain
      • exists
      • does not exist
    • A specific value, to be compared with the check for attribute via the operator. It is omitted when the operator is exist or not_exist.

  • The match operator. It can be one of the following:

    • ALL: All rules must evaluate to true.

    • ANY: At least one of the rules must evaluate to true.

    • ELSE: The rest of the conditions are not satisfied.

Examples of different responses

Context variable

In the following image, you can see an example in which the response is different based on the $amount context variable.

You can see the use of a condition where if the context variable $amount is more than 50,theuserseesthatnoextrashippingisdue.Otherwise,theuserseesthattheyhavetopayanextra50, the user sees that no extra shipping is due. Otherwise, the user sees that they have to pay an extra 5 in shipping.

System variable

In the following example, you can see that the AI Agent checks for the $sys-channel variable, which is a system variable that stores the communication channel.

So, if the user greets the assistant through WhatsApp, they receive the response with the carousel

. Otherwise, they receive the text message response, as shown above.

Entity

You can also create a condition based on entities. The following example shows a dialog in which the condition checks for the @payment-methods entity. If the value that is recognized is card or cash, the response is appropriate. Otherwise, the assistant tells the user what the available payment methods are.

Tags

You can use tags to remember that a specific dialog has been triggered. Hence, a specific dialog can tag the conversation so that future dialogs can alter responses accordingly. In the following example, registered customers are separated from unregistered ones by using a condition. The condition checks for the variable $tags. If the assistant has already assigned the tag customer, then the response is that there is no shipping fee. Otherwise, the response is that a $5 shipping fee is applied.