Type-safe TypeScript SDK for building Telegram bots. Types are generated from the official Bot API documentation; everything else is a thin layer over native fetch with zero runtime dependencies.
| Package | What it is | Use it when |
|---|---|---|
@effect-ak/tg-bot-api |
TypeScript types for the whole Bot API + Mini Apps (Telegram.WebApp), regenerated from https://core.telegram.org |
You only need types (own client, Mini App front-end) |
@effect-ak/tg-bot-client |
HTTP client: client.execute("send_message", { โฆ }) for every method, typed errors, automatic file uploads |
Sending notifications, managing channels, integrating Telegram in an app |
@effect-ak/tg-bot |
Bot framework: fluent builder, guarded handlers, long polling or webhooks, inline-keyboard screens as data | Building a bot โ locally, on a VPS, or on Cloudflare Workers / Bun / Deno |
Dependency chain: api โ client โ bot. Method names are snake_case exactly as in the official docs.
npm install @effect-ak/tg-botimport { createBot } from "@effect-ak/tg-bot"
await createBot()
.command("/start", ({ ctx }) => ctx.reply("Welcome!"))
.onText(({ payload, ctx }) => ctx.reply(`You said: ${payload.text}`))
.run({ bot_token: "YOUR_BOT_TOKEN" })npm install @effect-ak/tg-bot-clientimport { makeTgBotClient } from "@effect-ak/tg-bot-client"
const client = makeTgBotClient({
bot_token: "YOUR_BOT_TOKEN"
})
await client.execute("send_message", {
chat_id: 123456789,
text: "Hello, World!"
})import { createBot, defineScreens } from "@effect-ak/tg-bot"
const screens = defineScreens({
root: { text: "Main menu", buttons: [[{ label: "Hours", next: "hours" }]] },
hours: { text: "MonโFri 9โ18", parent: "root" }
})
const bot = createBot().use(screens)
export default {
fetch: (request: Request, env: Env) =>
bot.webhook({ bot_token: env.BOT_TOKEN, secret_token: env.WEBHOOK_SECRET })(request)
}A complete, deployable demo (several bots behind one token, KV state, GitHub Actions deploy) lives in example/.
- Always Up-to-Date: Types generated from official Telegram API documentation
- Fully Type-Safe: Complete TypeScript support for all API methods and types; errors are tagged unions
- Runs Anywhere: native
fetch, no dependencies โ Node.js 18+, Bun, Deno, Cloudflare Workers, browsers - Polling or Webhooks: long polling needs no public URL; webhooks verify Telegram's secret token out of the box
- Screens: inline-keyboard navigation declared as data (
defineScreens) โ Back, actions, edit-in-place handled for you
Full documentation and API reference: tg-bot-sdk.website
- tg-bot-sdk.website/llms.txt โ index of the docs with the conventions that matter; llms-full.txt โ all guides in one file
- bot-api.json / mini-app.json โ machine-readable Bot API and Mini Apps specs
- Each package README documents its full API surface; repo conventions for agents are in
.claude/CLAUDE.md
Try it in your browser: Telegram Bot Playground
pnpm install
pnpm buildPush to main triggers two GitHub Actions workflows:
- Build โ runs
pnpm build,pnpm typecheck, andpnpm test - Release โ runs after a successful Build, uses changesets to version and publish packages to npm
To release a new version:
- Create a changeset:
pnpm changeset - Commit the generated changeset file and merge to
main - The Release workflow will open a "Release" PR that bumps versions
- Merge the PR โ packages are automatically published to npm
Packages are published with npm provenance via OIDC between GitHub Actions and npm, so every published version is cryptographically signed and linked back to its source commit and workflow run.