Command Structure in TBL¶
Every TeleBotHost bot is a collection of commands. Not routes, not controllers, not event listeners — commands. Telegram sends an update, TBL matches exactly one, runs it, and finishes.
One update in. One path through your code out. That's the whole model.
The command-driven model¶
No background process humming away. No while(true) loop. Each message is a fresh, self-contained run — plus automatic @ and @@ wrappers around it (Special Commands).
What a command contains¶
Think of a command as a small form with a few parts:
| Part | Role |
|---|---|
| Name | What triggers it (/start, Help, *) |
| Answer | Optional auto-reply before logic |
| Logic | Real JavaScript + built-in bot extras for dynamic behavior |
| Options | Keyboard, aliases, need reply, public web, parse mode |
Answer is the fast path — static text TBL sends for you. Logic is where Bot, Api, db, and globals like user and params come in.
Full field reference: Command Fields.
Learn part by part¶
Flow & matching¶
- Command Flow overview — hub for this section
- Matching & Priority — which command wins
- Execution Flow —
@, Answer, Logic,!,@@ - Special Commands —
/start,@,!,@@,* - Dynamic Handlers —
/handle_{update_type}
Formatting & surfaces¶
- Markdown & Formatting — answers and
md2html - Public Web Commands —
is_webstatic pages
User interactions¶
- Handling Callbacks — inline buttons
- Handling User Input — need reply sessions
- Using Aliases — multiple triggers
- Wildcard (*) — catch-all
Hands-on¶
- Your First Bot — start here if you haven't built anything yet
Where to go next¶
Built /start already? Add a keyboard. Need buttons inside messages? Callbacks. Want a landing page? Public web.
The docs are modular — read what you need, skip what you don't.