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.
.png)
"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.
.png)
"Switch" block in scenario
In the block settings, you can add multiple conditions.
.png)
Setting conditions in "Switch" block
.png)
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:
- Condition Type "Message Contains Text"
- Condition Type "Message Matches Text"
- Condition Type "Contact Contains Tags"
- Condition Type "Contact Does Not Contain Tags"
- Condition Type "Contact Has Set Number of Referrals"
- Condition Type "Contact Is Subscribed to Telegram Channel/Group"
- Condition Type "Current Day of Week Matches Set Days"
- Condition Type "Variable Matches Set Expression"
- Condition Type "Global Variable Matches Set Expression"
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 👈