Condition blocks are used to create conditional logic in your bot. You can use it to check if a certain condition is met and then perform different actions based on the result.

Similar to an “if-else” statement in programming, condition blocks evaluate a condition and executes different paths based on whether the condition is true or false.

Condition block

Types of condition blocks

There are two types of condition blocks available in Chatling:

  • Variable: Compares a variable with a value or another variable.
  • Language: Checks if the user’s language matches a specific language. Useful for creating multilingual bots.

How do condition blocks work?

Condition blocks consist of two main parts:

  • Conditions: The conditions that the block will evaluate. You can use variables, languages, comparison operators, and logical operators to create complex conditions.
  • Paths: The paths that the block will follow based on the result of the conditions. Every condition you add will have a corresponding path that the block will follow if the condition is true.
Condition block components

Here’s an example of how a condition block works:

  1. The block evaluates conditions in the order they are added.
  2. If a condition is true, the block follows the path associated with that condition.
  3. If none of the conditions are true, the block follows the “Else” path.

The Else condition

The Else condition is executed if none of the other conditions are met. You can use it to define a fallback path that the block will follow if none of the other conditions are true.

Comparison operators

Conditions support a variety of comparison operators that you can use to compare values. Here are some of the operators you can use:

  • Equals: Checks if the variable is equal to the value.
  • Not equals: Checks if the variable is not equal to the value.
  • Contains: Checks if the variable contains the value.
  • Not contains: Checks if the variable does not contain the value.
  • Greater than or equals: Checks if the variable is greater than or equal to the value.
  • Less than: Checks if the variable is less than the value.
  • Less than or equals: Checks if the variable is less than or equal to the value.
  • Starts with: Checks if the variable starts with the value.
  • Ends with: Checks if the variable ends with the value.
  • Is empty: Checks if the variable is empty.
  • Is not empty: Checks if the variable is not empty.

Group and child conditions

Conditions are grouped together to create complex logic using logical operators like “AND” and “OR”. Every group contains one or more conditions that are evaluated together.

Group and child conditions

Conditions within a group are evaluated together to determine if the group is true or false. You can use logical operators such as “AND” and “OR” to combine conditions within a group.

For example, you can create a group with two conditions and set it to “AND” to require both conditions to be true for the group to be true. On the other hand, you can set it to “OR” to require only one of the conditions to be true for the group to be true.

By default, condition blocks have one group with one condition. To add additional groups, click the Add group condition button.

Logical operators

Logical operators are used to combine conditions within a group. You can choose from the following logical operators:

  • AND: Requires all conditions in the group to be true for the group to be true.
  • OR: Requires at least one condition in the group to be true for the group to be true.