Skip to content

What is TBL?

TBL (Tele Bot Language) is JavaScript with built-in extras for Telegram bot development — reply to messages, store user data, call APIs, show buttons, gate features behind channel joins.

You write real JavaScript in command Logic fields. TeleBotHost adds Bot, Api, user, chat, db, modules, and more so you skip the boilerplate and ship faster. It's not for building general websites or CLI tools — it's JavaScript tuned for bots. TeleBotHost handles hosting; you focus on "what should happen when someone sends /start," not "how do I keep a Node process alive at 3 AM."

New to the platform? Getting Started. Ready to write code? Learning TBL.


Commands, not event loops

Most Node bot frameworks look like this: register listeners, keep a process alive, hope nothing leaks memory. TBL flips that model entirely.

Telegram sends an update. TBL finds the matching command and runs it. The command finishes. Nothing stays running in the background waiting for the next message — the next update starts a fresh execution.

Update  →  match command  →  send Answer  →  run Logic  →  done

One update, one command, one path through the code. Easier to reason about, harder to accidentally create a zombie process.


What a command can do

Surface Example
Telegram reply Answer field + Logic → chat message
Inline buttons Logic sends keyboard → Handling Callbacks
Formatted text Markdown/HTML answers — Markdown & Formatting
Public web page is_web command → /public/{bot_id}/index.html
HTTP API Webhook or webapp command → res.json()

See Command Flow for the full structured guide.


Short-lived executions

Each run is sandboxed and time-bounded. Your command does its work — send messages, read storage, call HTTP — and exits. Under load, many users can trigger commands at once without one long-running script getting tangled.

You won't find background timers or daemons in TBL by design. If something should happen "later," it's because a new update arrived or you chained work through on_run / another command. Patience, delivered via Telegram updates.


Async when it helps

Some calls take time — Telegram's API, an external HTTP request, channel membership checks (await Libs.mcl.quick(...)). TBL supports await where you need the result before continuing. It doesn't push async everywhere; only where waiting actually matters.

Most day-to-day bot code runs synchronously. Add await when you're waiting on something external — not "just in case."


Built-in toolboxes

You don't install npm packages. TBL gives you two drawers:

Toolbox Best for Docs
modules JWT, bcrypt, CSV, lodash, ethers Modules
Libs Referrals, dice rolls, channel gates, game economies Libs

Rule of thumb: npm-style utility → modules. Telegram-bot glue → Libs.


Why the limits exist

TBL is JavaScript, but it's not a full Node.js server. You can't install arbitrary npm packages or open raw sockets. That frustrates people who want a general-purpose backend — and protects everyone else from accidental infinite loops, runaway memory, or bots that become impossible to debug.

The tradeoff: less freedom than raw Node, faster path to a working bot. For most Telegram bots, that's a fair swap — you get the language you know, plus the extras you actually need.