Skip to content

kondaurovDev/tg-bot-sdk

Repository files navigation

Telegram Bot TypeScript SDK

Docs Telegram Bot API Telegram WebApp

Type-safe TypeScript SDK for building Telegram bots, automatically generated from official Telegram Bot API documentation.

📦 Packages

This monorepo contains three packages:

TypeScript types for Telegram Bot API and Mini Apps, auto-generated from official documentation.

Lightweight HTTP client for Telegram Bot API with full type safety.

Bot framework with fluent builder API, long polling, webhooks, and hot reload.

🚀 Quick Start

Bot Framework

npm install @effect-ak/tg-bot
import { createBot } from "@effect-ak/tg-bot"

await createBot()
  .onMessage(({ command, text }) => [
    command("/start", ({ ctx }) => ctx.reply("Welcome!")),
    text(({ update, ctx }) => ctx.reply(`You said: ${update.text}`))
  ])
  .run({ bot_token: "YOUR_BOT_TOKEN" })

HTTP Client

npm install @effect-ak/tg-bot-client
import { makeTgBotClient } from "@effect-ak/tg-bot-client"

const client = makeTgBotClient({
  bot_token: "YOUR_BOT_TOKEN"
})

await client.execute("sendMessage", {
  chat_id: "123456789",
  text: "Hello, World!"
})

🎯 Key Features

  • Always Up-to-Date: Types generated from official Telegram API documentation
  • Fully Type-Safe: Complete TypeScript support for all API methods and types
  • Zero Config: Works out of the box with sensible defaults
  • No Webhooks Required: Uses long polling - run anywhere without public URLs

📚 Documentation

Full documentation and API reference: tg-bot-sdk.website

🎮 Playground

Try it in your browser: Telegram Bot Playground

🛠️ Development

Setup

pnpm install
pnpm build

CI/CD

Push to main triggers two GitHub Actions workflows:

  1. Build — runs pnpm build, pnpm typecheck, and pnpm test
  2. Release — runs after a successful Build, uses changesets to version and publish packages to npm

To release a new version:

  1. Create a changeset: pnpm changeset
  2. Commit the generated changeset file and merge to main
  3. The Release workflow will open a "Release" PR that bumps versions
  4. 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.

About

A comprehensive library with full Telegram Bot API type support

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors