Command Flow¶
Every bot is a pile of commands. Telegram sends an update, your bot picks one command, runs it, and calls it a day. No background process, no event loop — just match, run, done.
This section explains how commands are built, matched, and executed — from basic /start replies to callbacks, markdown, and public web pages.
What is command flow?¶
Every Telegram bot on TeleBotHost is a collection of commands. The platform receives an update, picks one command, runs it, and finishes.
| You get | You skip |
|---|---|
| Answer + Keyboard without code | Building a web server |
| Logic when you need it | Event-driven architecture |
Special handlers (@, !, @@) | Custom error middleware |
New to TBL?
TBL is JavaScript with built-in bot extras — not a separate language. Brand new? Start with Getting Started, then Your First Bot. The big picture: What is TBL?. Quick intro: Learning TBL.
How an update becomes a response¶
Telegram update arrives
│
▼
Run `@` initialization (if defined)
│
▼
Match one command (priority order)
│
▼
Send Answer + Keyboard (if configured)
│
▼
Run Logic code (if any)
│
▼
On error → run `!` handler
│
▼
Run `@@` post-processor (if defined)
│
▼
Done
See Execution Flow for the full lifecycle.
Try it — your first command¶
No Logic needed — just an Answer field:
- Create a command named
/start - Set Answer to:
Welcome! Type /help for commands. - Save and message your bot
/start
That's command flow in action. Add Logic when you need dynamic behavior:
Globals like user and chat: Global Variables
Command surfaces at a glance¶
| Surface | Trigger | Answer field | Logic + res |
|---|---|---|---|
| Telegram message | User sends text/command | Yes | Yes |
| Callback query | Inline button tap | Yes (then logic) | Yes |
| Webhook | Signed HTTP URL | No | Yes + res |
| Webapp | /webapp/{bot_id}/{cmd} | No | Yes + res |
| Public web | /public/{bot_id}/{path} | N/A — serves command source | No sandbox |
Pages in this section¶
Core concepts¶
| Page | What you'll learn |
|---|---|
| Command Fields | Answer, Logic, Keyboard, aliases, need_reply, is_web, parse_mode |
| Matching & Priority | How the platform picks which command runs |
| Execution Flow | @, !, @@, answer-before-logic, sessions |
| Special Commands | /start, @, !, @@, * |
| Dynamic Handlers | /handle_{update_type}, inline query, channel |
Formatting & web¶
| Page | What you'll learn |
|---|---|
| Markdown & Formatting | Answer markdown, parse_mode, modules.md2html |
| Public Web Commands | is_web flag, static pages per bot |
Interactions¶
| Page | What you'll learn |
|---|---|
| Handling Callbacks | Inline buttons, callback_query, editing messages |
| Handling User Input | need_reply sessions |
| Using Aliases | Multiple triggers for one command |
| Wildcard (*) | Catch-all for unknown input |
Hands-on tutorials¶
| Page | What you'll build |
|---|---|
| Your First Bot | /start with an answer |
| Adding a Keyboard | Reply keyboard menu |
| Command Structure | Short overview + links |
Read first¶
New to TeleBotHost? Start with Getting Started, then Your First Bot.
Want the big picture? What is TBL? explains the command-driven model.