help.chat-api.com

Logic blocks - Condition

The "Condition" block allows you to guide the user through a particular branch of the script, depending on certain conditions.

Unfolding a flow by condition

The simplest condition block has two outputs:

- the user goes to the branch of the scenario whose condition (or group of conditions) is met

- the user goes to the second branch of the scenario, when the condition is not met. This output is marked in red

Multiple Condition Groups

You can add both a single condition and groups of conditions to a block and configure whether all conditions are to be met or only one of them.

There can be several groups with conditions, each group can have up to 4 conditions.

You can swap the condition groups in a block using the arrows on the left side of the group. At the same time, the group is not disconnected from other blocks.

To delete a particular condition in a group, click on the gray garbage can, to delete the whole group, click on the red garbage can.

Error message

If one of the conditions does not have a script continuation, the bot will give an error to the user:

What are the terms
Condition by tag

Depending on whether a user is assigned a tag or not, he or she can be routed to one or the other branch of the script. Tags can be added or removed under Settings → Tags 

Condition by channel (messenger)

The ideology of the platform is to connect all communication channels with customers into one system and work in them according to single scripts. However, sometimes you have to arrange the different logic of the script, depending on what messenger (channel) you are communicating with the user. 

Conditioning on the value of variables

The platform allows you to construct conditions by variables. To do so, select one of the variables in the list. System (preset) and user variables are available for selection.

System variables

The system variables are presented at the beginning of the list. These variables are filled in automatically by the system and are available to each user.

User variables

User variables are located in the drop-down list after the system variables. These variables must be added manually in Settings.

Constructing a variable condition

Usually a variable condition has three parts (variable, operation, and argument). For example, age is greater than 18. Here age is the variable, more than is the operation, and 18 is the argument. The operation can be selected from the drop-down list below the variable list.

In most cases, after selecting an operation, you must enter an argument in the next input field. The exceptions are operations such as Contains Any Value and Value Not Specified. For these, the argument entry field will not be displayed.

Consider the following example: you want the bot to send appropriate content to the user based on his age. To do this, create a variable "age", select the appropriate operation and enter the necessary argument value, and then add script branches.

Arbitrary formula condition

The Condition block allows you to write complex formulas in Python using system and user variables. The result of the calculation must be a bool-type value.

For example, an age condition can be written with a formula like this: age > 18

Was this article helpful?

Your opinion will be used to improve the content of the article

The Most Multifunctional API Provider

Chat API has been operating since 2015 and is one of the first and largest providers in Eastern Europe.

Here are some curious and important figures:

  • We have tremendous expertise in docker container management at scale with an SLA of 99.5+%;
  • Chat API involves in its work more than 200 servers, with the ability to quickly connect another 100;
  • 3200 cores and 25 terabytes of RAM;
  • 200+ methods and features that keep adding;
  • Highload system, Up Time servers 99.9%;
  • Support 24\7;
Get access to the API