Exit Conditions in the Builder July 23, 2024 15:13 Updated To enable state changes for a user, the Builder provides exit conditions. An exit condition consists of one or more rules and the identifier of the destination block, if the condition is met. The destination block can be any of the blocks in the bot's conversation flow. Each rule is composed of up to four structures: data source, operator, variable name, and an expected value. When the data source of type Variable is selected, it is also necessary to add the name of the variable that will be analyzed in the condition. Data Source A condition can use up to four different data sources to create a rule. These are: user input, variable value, intent, or entity extracted from the user's last input. Operator There are different types of operators for a rule. The table below presents all operators and their respective definitions: Operator Name Description Exists Checks if there is any value in the data source, regardless of what it is. Equal to Checks if the data source is exactly equal to the expected value. Different from Checks if the data source is different from the expected value. Contains Checks if the data source contains the expected value. Starts with Checks if the data source starts with the expected value. Ends with Checks if the data source ends with the expected value. Greater than Checks if the data source is greater than the expected value. Less than Checks if the data source is less than the expected value. Greater than or equal to Checks if the data source is greater than or equal to the expected value. Less than or equal to Checks if the data source is less than or equal to the expected value. Similar to Checks if the data source is similar to the expected value (using the Levenshtein function). Matches regex Checks if the data source matches the regex pattern defined in the expected value. Expected Value The expected value in the data source. This value can be text, number, or even a regex pattern. Example: Imagine that, during any question, a bot needs to change the user's state based on their response. The expected response values are “yes” or “no”. In this situation, the block with the question will have two exit conditions: Condition 1 Data Source: User input Operator: Equal to Values: yes Destination Block: 1 - Yes State Condition 2 Data Source: User input Operator: Equal to Values: no Destination Block: 2 - No State To visualize better, check the following image: Example: Imagine that, during any question, a bot needs to change the user's state based on one of their context variables. Consider that the variable {{plan}} represents the user's plan, was set in a previous state, and can take the values “free” or “premium”. In this situation, the block with the question will have two exit conditions: Condition 1 Data Source: Variable value Variable Name: plan Operator: Equal to Values: free Destination Block: 1 - Free State Condition 2 Data Source: Variable value Variable Name: plan Operator: Equal to Values: premium Destination Block: 2 - Premium State To visualize better, check the following image: Note: An exit condition is composed of one or more rules. All rules in a condition must be true for the corresponding target block to be activated. Exit conditions for a Builder block are processed sequentially until a true condition is met. That is, it is necessary to register the conditions, ordered from the most specific to the most generic. By default, every block has a pre-configured default exit condition (Fallback). Although it is possible to change the default exit for any block, it is not possible to remove it. For more information, join the discussion on the topic in our community or watch the videos on our channel. 😃 Related articles Creating interactive messages in WhatsApp How to configure a destination block by variable Setting up Session Expiration and Timeout NPS - Satisfaction Survey Undestanding bot and subbot hierarchy (or architecture)