Logic blocks - Condition
The "Condition" block allows you to guide the user through a particular branch of the script, depending on certain conditions.
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
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.
If one of the conditions does not have a script continuation, the bot will give an error to the user:
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
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.
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.
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 are located in the drop-down list after the system variables. These variables must be added manually in Settings.
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.
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