Skip to main content

The Telegram Bot Framework

Build powerful Telegram bots with ease. grammY makes bot development simple, scalable, and type-safe for both Node.js and Deno.

Quick start

Get your first bot running in minutes

1

Install grammY

Install grammY using your preferred package manager:
npm install grammy
2

Create your bot

Visit @BotFather on Telegram to create a new bot and obtain your bot token.
Keep your bot token secure! Never commit it to version control or share it publicly.
3

Write your first bot

Create a simple echo bot that responds to text messages:
bot.ts
import { Bot } from "grammy";

// Create a bot instance
const bot = new Bot("YOUR_BOT_TOKEN");

// Register listeners to handle messages
bot.on("message:text", (ctx) => ctx.reply("Echo: " + ctx.message.text));

// Start the bot (using long polling)
bot.start();
Run your bot:
node bot.ts
4

Test your bot

Open Telegram and send a message to your bot. It should echo back whatever you send!
Ready to build something more complex? Check out our core concepts to learn about middleware, filters, and more.

Explore by topic

Dive deeper into grammY’s powerful features

Core Concepts

Learn about the Bot class, Context object, middleware system, and filter queries

Keyboards

Build custom and inline keyboards to create interactive bot experiences

Sessions

Store user data across conversations with built-in session management

Inline Queries

Handle inline queries and let users interact with your bot from any chat

Webhooks

Deploy your bot using webhooks for production environments

Plugins

Extend grammY with community plugins or create your own

Why grammY?

Built for developers who want power and simplicity

Type-safe

Full TypeScript support with intelligent autocomplete and type inference throughout the framework

Cross-platform

Run on Node.js, Deno, or in the browser. Deploy to any serverless platform or traditional server

Powerful middleware

Build complex bot logic with a flexible middleware system and powerful filter queries

Production-ready

Battle-tested in thousands of bots. Comprehensive error handling and built-in best practices

Community & Support

Join thousands of developers building with grammY

Telegram Chat

Ask questions and get help from the community

GitHub

View source code, report issues, and contribute

Examples

Browse example bots and learn from real implementations

Ready to build your bot?

Start creating powerful Telegram bots with grammY’s intuitive API and comprehensive documentation

Get Started

Build docs developers (and LLMs) love