Skip to content

Switch

Instructions for using the "Switch" block to redirect users along different scenario branches in the bot

Sometimes you need to distribute user traffic along different scenario branches based on some conditions, for this you can use the Condition block. But in this case, you can only direct traffic along two branches: the client meets the condition or does not meet it.

condition in chat bot

"Condition" block

We faced the task of distributing user traffic along multiple scenario branches based on given conditions. For this, we developed a new Switch block. Click the Add Block button in the upper right corner of the scenario, then select this block in the Expert tab.

switch in chat bot

"Switch" block in scenario

In the block settings, you can add multiple conditions.

multiple conditions in bot

Setting conditions in "Switch" block

multiple conditions in bot

Setting conditions in "Switch" block

Conditions are checked sequentially from top to bottom, the first matching condition is triggered. If no condition matches, the "Default" condition is triggered, on the same principle as "Any other phrase" in other blocks.

At the time of writing, the following condition types are supported:

This way, it became possible to segment traffic along different scenarios, as well as create simple phrasebooks based on the "Message Contains Text" condition type.

Creating multiple conditions and branches in chat bots

Create a smart chat bot that conducts natural dialogue with users.

The video shows the complete process: from connecting a Telegram bot to setting up complex logic with "Switch" and "Condition" blocks to simulate live communication.

Bonus for new users and the opportunity to receive 500 rubles as a gift 🎁

  • Register on LEADTEX
  • Create and test your first project
  • Don't miss the special offer. Get gift 👈