Loading...
Loading...
GramIO — type-safe TypeScript Telegram Bot API framework for Node.js, Bun, and Deno. Use when building Telegram bots, handling commands/callbacks/inline queries, creating keyboards, formatting messages, uploading files, managing sessions/scenes, writing plugins, setting up webhooks, or integrating Telegram payments.
npx skill4agent add gramiojs/documentation gramio@gramio/typesnpm create gramio bot-name
cd bot-name
npm run devimport { Bot } from "gramio";
const bot = new Bot(process.env.BOT_TOKEN as string)
.command("start", (context) => context.send("Hello!"))
.onStart(({ info }) => console.log(`@${info.username} started`))
.onError(({ context, kind, error }) => console.error(`[${kind}]`, error));
bot.start();.command().on().extend()context.is("message")new Plugin("name").derive(() => ({ ... }))bot.extend(plugin)bot.api.method({ suppress: true })awaitbot.start()await.derive().decorate()| Plugin | Package | Purpose |
|---|---|---|
| Session | | Persistent per-user data storage |
| Scenes | | Multi-step conversation flows |
| I18n | | Internationalization (TS-native or Fluent) |
| Autoload | | File-based handler loading |
| Prompt | | Interactive single-question prompts |
| Auto Retry | | Retry on 429 rate limits |
| Media Cache | | Cache file_ids |
| Media Group | | Handle album messages |
| Split | | Split long messages |
| Auto Answer CB | | Auto-answer callbacks |
| PostHog | | Analytics + feature flags |
| Topic | Description | Reference |
|---|---|---|
| Bot Configuration | Constructor, API options, proxy, test DC, debugging | bot-configuration |
| Bot API | Calling methods, suppress, withRetries, type helpers | bot-api |
| Context & Updates | derive, decorate, middleware, start/stop, type narrowing | context |
| Triggers | command, hears, callbackQuery, inlineQuery, reaction | triggers |
| Hooks | onStart, onStop, onError, preRequest, onResponse | hooks |
| Updates & Lifecycle | start/stop options, graceful shutdown (SIGINT/SIGTERM) | updates |
| Topic | Description | Reference |
|---|---|---|
| Keyboards | Keyboard, InlineKeyboard, layout helpers, styling | keyboards |
| Formatting | bold, italic, code, pre, link, mention, join | formatting |
| Files | MediaUpload, MediaInput, download, Bun.file() | files |
| CallbackData | Type-safe callback data schemas | callback-data |
| Storage | In-memory, Redis, Cloudflare adapters | storage |
| Telegram Stars | Payments, invoices, subscriptions, inline invoices, refunds, test mode | telegram-stars |
| Types | @gramio/types, type helpers, Proxy wrapper, declaration merging | types |
| Topic | Description | Reference |
|---|---|---|
| Webhook | Framework integration, tunneling, custom handlers | webhook |
| Rate Limits | withRetries, broadcasting, queues | rate-limits |
| Docker | Dockerfile, multi-stage build, Docker Compose | docker |
| TMA | Mini Apps, mkcert HTTPS, @gramio/init-data auth | tma |
| Plugin | Description | Reference |
|---|---|---|
| Session | Per-user data, Redis support | session |
| Scenes | Multi-step flows, state, navigation | scenes |
| I18n | TS-native and Fluent internationalization | i18n |
| Autoload | File-based handler discovery | autoload |
| Prompt | Send + wait for response | prompt |
| Others | auto-retry, media-cache, media-group, split, posthog | other |
| Plugin Development | Writing custom plugins, derive/decorate/error, lazy loading | plugin-development |
| Example | Description | File |
|---|---|---|
| Basic bot | Commands, hooks, error handling | basic.ts |
| Keyboards | Reply, inline, columns, conditional | keyboards.ts |
| CallbackData | Type-safe callback schemas | callback-data.ts |
| Formatting | All entity types, join helper | formatting.ts |
| File upload | Path, URL, buffer, media groups | file-upload.ts |
| Error handling | Custom errors, suppress, scoped | error-handling.ts |
| Webhook | Framework integration | webhook.ts |
| Session | Counters, settings, Redis | session.ts |
| Scenes | Registration flow with steps | scenes.ts |
| Telegram Stars | Payments, invoices, refunds | telegram-stars.ts |
| TMA | Elysia server, init-data auth, webhook | tma.ts |
| Docker | Graceful shutdown, webhook/polling toggle | docker.ts |