v2.0 A framework, not a wrapper

Telegram bots,
the NestJS way.

A real NestJS framework for the Telegram Bot API — modules, DI, pipes & guards, built to scale and survive production.

Read the docs →
// where others wrap,
telegrafgrammYnode-telegram-bot-apinestgram frameworks.
// the difference

Other libraries wrap the API.
Nestgram is the framework.

Telegraf, grammY and node-telegram-bot-api are great clients. The “NestJS” packages around them are thin adapters. Nestgram is built from the ground up on Nest’s own lifecycle — so the framework works for you, not the API.

◇ Thin wrappers

  • ✕ Middleware lives outside Nest’s pipeline
  • ✕ Bot logic bolted onto a service, not routed
  • ✕ Magic strings & manual update parsing
  • ✕ No guardrails for production foot-guns

◆ Nestgram

  • ✓ Guards, pipes & interceptors from Nest’s pipeline
  • ✓ A router is a controller — updates map to handlers
  • ✓ Typed events & decorators: @Sender() @Args()
  • ✓ Framework warns you before you ship a mistake
// what you get

Everything NestJS, mapped to Telegram.

Native Nest pipeline

Guards, pipes and interceptors run on the exact same lifecycle as your HTTP routes. No parallel system to learn.

01

Router = Controller

Your update handlers are just controllers. Decorators bind messages, callbacks & commands to methods.

02

Typed events & decorators

Each handler gets the concrete update it asked for. Pull the sender or args with one explicit decorator — no magic strings.

03
// router = controller

If you know Nest,
you already know this.

A controller declares routes. In Nestgram, those routes are Telegram updates. Same decorator discipline, same DI, same testability — pointed at a different transport.

@Router() marks a class as a routed controller.
@OnMessage() / @Command() bind handlers to update types.
@Sender() @Args() inject exactly what you ask for.
greet.router.ts
@Router()
export class GreetRouter {
  @Command('start')
  start(@Sender() user: User) {
    return `Welcome, ${user.first_name} 👋`;
  }

  @OnMessage()
  echo(message: Message) {
    return message.text;
  }
}
// from update to handler

One predictable pipeline.

Every Telegram update flows through the same Nest lifecycle your team already reasons about — no parallel middleware system.

▼ incoming updatehandler response ▲
Update
webhook / polling
→
Guard
@UseGuards()
→
Interceptor
wrap / log
→
Pipe
transform / validate
→
Handler
@Command() @OnMessage()
→
Reply
return value
→
// it warns you first

Guardrails against
production foot-guns.

The framework knows the Telegram Bot API’s sharp edges. It surfaces them at boot — not in an incident channel at 2 a.m.

Nestgram warning
[WebhookUpdateSource]
Webhook is set without a secretToken —
anyone who learns the URL can spoof updates.
→ set webhook.secretToken in NestgramModule.forRoot()

Build the bot like you build the app.

Bring your NestJS instincts. Nestgram brings the Telegram transport, the pipeline, and the guardrails.