Skip to content

easytg documentation ​

New to easytg? Start with Getting started: a small shop bot built step by step. Upgrading? See Migrating. Looking for a method? See the API reference.

On the docs site, code blocks marked "Try it" run in a Telegram simulator in your browser, and so does every example in the playground.

Building the UI ​

Pagespages, nav, delivery modes, keeping messages, app.edit, params validation (functions or zod/valibot), long messages, middlewares, Back, refreshEveryMs
Mediaphotos, videos, documents, audio, albums, copies from a channel, protectContent, file id cache
Main menua reply-keyboard menu with replyMenu
Flow mapapp.flowchart(): the bot as a Mermaid diagram of pages, dialogues, commands and buttons
Commandsapp.command: /commands for pages and dialogues, and Telegram's command menu (syncCommands)
Dialoguesmulti-step forms: text, files, choices, several options, numbers, dates (calendar), contacts, locations, Mini Apps; typed answers, schemas, when, timeouts
Text inputpage.onText: search boxes and other typed input on a page
Text formattingMarkdown, HTML, safe md / html templates
Rich messagesrich: headings, tables, task lists, details, formulas, pictures and buttons in one message (Bot API 10.3)
Languagesyour messages with t() (placeholders, plurals), setLocale, built-in texts
Inline modepages as @yourbot query results
Mini Appsopening Mini Apps, checking initData, answering, sharing, sendData
Groupsmenu ownership, pages for one member only (ephemeral), admin-only pages, chat-wide state, privacy mode
Streamingapp.stream: an AI answer appearing as it is written (drafts, rich or plain), with a stop button

State and data ​

Sessionsstate per chat, per user across chats, and chat-wide; typed keys, expiry, migrations
StorageMemoryStorage, SqliteStorage, RedisStorage, custom adapters
Button paramsinline, stored and signed buttons
Deep linkst.me/yourbot?start=… links to pages and dialogues

Beyond a single update ​

Sending without an updatesendTo, sendLater, broadcast, broadcastLater
Relaysapp.relay: two users talking through the bot (anonymous chats, support)
Scheduled taskstask(), app.schedule, recurring tasks, deleteLater, deleteAfterMs
Queuesconcurrency limits for slow jobs
Paymentsinvoices, Telegram Stars, checkout, onSuccess

Running in production ​

Anti-spamrate limits, mutes, double taps
Scalingsequential updates, Telegram's rate limits (app.throttle), several processes (cluster), webhooks
Serverless and edgeCloudflare Workers, Deno Deploy, Vercel: webhooks, Redis over HTTP, cron for tasks
Security noteswhat to trust and what not
Eventsupdate (timings), pageView, sent, spam, error, payment, …
Error helpersisChatUnreachable, isTransient, retryAfterMs, autoRetry
Optionsevery option of new EasyTG()
API referenceevery export and app method
Migratingbreaking changes between versions
Testingeasytg/testing: a fake Telegram API for your tests
Preview and recorded testseasytg preview: your bot file in a simulated Telegram in the browser; tests recorded from it; loadBot
Simulatoreasytg/simulator: an in-memory Telegram with users, groups and a browser chat window; easytg in the browser

Examples ​

Runnable bots (BOT_TOKEN=… bun run examples/<file>) that show features in context:

ExampleFeatures
getting-started.tspages, typed navigation, a dialogue, sessions, main menu
shop.tsreply-keyboard menu with close button, pagination, nav.back(), photos, albums, choice/contact/location steps, events
search.tspage.onText, i18n.messages with t / t.md and plurals, a language picker with setLocale
media.tsphoto, video, GIF, generated document, audio, album
course.tscopy from a storage channel, protectContent, { mode: 'send' }, .params(parse), signed buttons, prepareProactive, allowedUsers, app.edit, deleteAfterMs
reminders.tsscheduled tasks: task, schedule, everyMs, cancelTask, deleteLater, SQLite
queue.tsapp.queue, app.enterQueue, perUser, queueWait, page.loading, app.withLoading
payments.tsTelegram Stars invoices, preCheckout, onSuccess, refunds
inline.tsapp.inlineResult, .params(schema), media.cacheFileIds, autoRetry
mini-app.tsa bot with its Mini App: verifyInitData, withUser, answerWebAppQuery, prepareShare, a webApp step, replyMenu.webApp
sessions.tssession (this chat), userSession (every chat), chatSession (shared), typed keys
loading.tspage.loading (placeholder, "typing…", toast), dialogue.loading, app.withLoading, a default
throttle.tsapp.throttle with per-chat rules, autoRetry, a paced broadcast
group.tschatSession, requireChatAdmin, refreshEveryMs, dialogue.timeout
production.tsRedisStorage / SqliteStorage, cluster, webhooks, the scheduler, autoRetry
broadcast.tsbroadcast in the background with progress, broadcastLater, dialogue middlewares, pageView/spam events
match.tsa reply-keyboard menu acting on the card on screen, showMenu / hideMenu in renders, a dialogue with when and a photo, sendTo for likes and matches, app.relay chats, app.command + syncCommands
booking.tsdate (calendar), number and multiChoice steps, when
support.tsa support desk with app.relay: tickets, relay.filter, replies and edits carried over, relayEnd, rating
team.tsa group board: ephemeral pages and a dialogue (mode: 'ephemeral'), ephemeral commands, nav.disabled
ai-chat.tsapp.stream with rich: an answer streamed as a rich draft with ⏹ Stop, then a rich message
rich.tsrich pages: Rich Markdown with a table from data (md), Rich HTML with details and a button inside the text, blocks with a photo
flowchart.tsapp.flowchart() and mermaidLiveUrl: a bot that sends its own map
cloudflare-worker.tsa Cloudflare Worker: webhook, Redis over HTTP, cron for scheduled tasks
captcha.tsserver-side answers, per-key session TTL, dialogues
notify.tsSQLite storage, stored buttons, sendLater
locales/id.tstranslating built-in texts
testing.test.tstesting with easytg/testing

MIT licensed