Common Patterns
These proven patterns solve problems you'll encounter regularly. Copy and adapt them!
Welcome Flow with Registration Check
Goal: Greet returning users differently than new ones.
Menu Pattern
Goal: Show a menu and handle selections.
Menu Message:
📋 Main Menu
Choose an option:
[📊 Stats] [⚙️ Settings]
[❓ Help] [📞 Contact]
Confirmation Pattern
Goal: Ask "Are you sure?" before important actions.
Confirmation Message:
⚠️ Are you sure you want to delete your account?
This action cannot be undone.
[✅ Yes, delete] [❌ Cancel]
Access Control (Guard)
Goal: Restrict certain commands to verified users.
Implementation:
- Add a Guard at the start of protected flows
- Check
var.is_verified == true
Admin-Only Commands
Goal: Commands only admins can use.
Expression:
user.id == global.admin_id || user.id == global.admin_id_2
Or store admin IDs in a list:
contains(global.admin_ids, user.id)
Retry Pattern
Goal: Ask again if input is invalid.
Add a counter to prevent endless retries:
flow.attempts < 3
After 3 tries, offer help or exit.
Loading Indicator
Goal: Show the bot is working on slow operations.
Add a Chat Action node with typing before HTTP requests or heavy processing.
Pagination Pattern
Goal: Show data in pages.
Pagination Buttons:
[⬅️ Previous] Page 2 of 5 [➡️ Next]
Timeout Pattern
Goal: Handle users who don't respond.
Broadcast Pattern
Goal: Send a message to all users.
Add delays between messages to avoid Telegram rate limits.
Error Recovery
Goal: Handle errors gracefully.
Feature Toggle
Goal: Enable/disable features without changing flows.
Set global.feature_enabled to true or false in settings.
Next Steps
- Common Errors → — Fix problems
- FAQ → — Common questions