MCPcopy
hub / github.com/grammyjs/grammY

github.com/grammyjs/grammY @v1.44.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.44.0 ↗
779 symbols 1,490 edges 44 files 544 documented · 70%
README

grammY

The Telegram Bot Framework

Bot API Deno npm All Contributors

docs. reference. chat. news.

grammY makes it easy to create Telegram bots. Both for beginners and at scale.

You want grammY because it is easy to use. It is very powerful and always up to date. It has the best documentation in town. It is extremely efficient and scales up effortlessly. It has a thriving ecosystem of plugins, a friendly community chat, seamless integrations with web frameworks and databases, and so much more.

Are you ready? 🤖🚀

Bots are written in TypeScript (or JavaScript) and run on Node.js or Deno.

Quickstart

If you are new to Telegram bots, read the official Introduction for Developers written by the Telegram team.

Visit @BotFather and create a new bot. You will obtain a bot token.

Create a new directory and run

npm install grammy

inside it. Then create a file bot.js with this content:

const { Bot } = require("grammy");

// Create a bot object
const bot = new Bot(""); // <-- place your bot token in this string

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

// Start the bot (using long polling)
bot.start();

Now you can run the bot via

node bot.js

and it will echo all received text messages.

Congrats! You just wrote a Telegram bot :)

Going Further

grammY has an excellent documentation, and an API Reference. It even integrates with your code editor, e.g. VS Code. You can hover over any element of grammY to get a detailed description of what that thing does or means.

If you are still stuck, just join the Telegram chat and ask for help. People are nice there and we appreciate your question, no matter what it is :)

Here are some more resources to support you:

Resources

grammY website

—main project website and documentation. Gets you started and explains all concepts.

grammY API reference

—reference of everything that grammY exports. Useful to look up descriptions about any element of grammY.

grammY examples

—repository full of example bots. Includes a setup to easily run any of them.

Awesome grammY

—list of awesome projects built with grammY. Helpful if you want to see some real-world usage.

grammY chat

—The chat where you can ask any question about grammY or bots in general. We are also open for feedback, ideas, and contributions!

The Russian community chat can be found here.

grammY news

—The channel where updates to grammY and the ecosystem are posted.

Telegram Bot API Reference

—documentation of the API that Telegram offers, and that grammY connects to under the hood.

Deno Support

All grammY packages published by @grammyjs run natively on Deno. We are compiling every codebase to still run on Node.js.

However, given that most bot developers are still using Node.js, all documentation is written Node.js-first. We may migrate it if Deno overtakes Node.js. If you are already on Deno today, import grammY from https://deno.land/x/grammy/mod.ts.

You may also be interested in why we support Deno.

JavaScript Bundles

The grammY core package in this repository is available as a JavaScript bundle via https://bundle.deno.dev/. This lets you transpile all published versions including current main branch to standalone JavaScript files. For example, the most recent source on main is available from https://bundle.deno.dev/https://raw.githubusercontent.com/grammyjs/grammY/main/src/mod.ts.

Being compatible with browsers is especially useful for running bots on Cloudflare Workers. For this reason, we also include a web bundle in our npm package. You can simply do import { Bot } from "grammy/web".

Contribution Guide »

Contributors ✨

Thanks goes to these wonderful people (emoji key):

KnorpelSenf KnorpelSenf 🤔 💻 📖 🎨 💡 ⚠️ 🔌 📦 👀 🧑‍🏫 📆 🚇 🔊 ️️️️♿️ 📢 Heero Heero 🔌 📓 💡 📖 👀 💻 🤔 Wojciech Pawlik Wojciech Pawlik 🤔 👀 🚇 📦 🔧 💻 Alessandro Bertozzi Alessandro Bertozzi 📖 Thomas Thomas 💻 👀 KnightNiwrem KnightNiwrem 💻 🐛 🔌 📖 💡 👀 🧑‍🏫 Muthu Kumar Muthu Kumar 👀 🐛 💻 EdJoPaTo EdJoPaTo 🔌 📖 🤔 👀 🐛 💻 Amir Zouerami Amir Zouerami 📖 🔌 💡
Roj Roj 📖 👀 🚇 🌍 💻 🤔 🧑‍🏫 💡 jokasimr jokasimr 🐛 Qz Qz 📖 🌍 AndreoliBR AndreoliBR 👀

Extension points exported contracts — how you extend this code

URLLike (Interface)
Something that looks like a URL.
src/types.deno.ts
URLLike (Interface)
Something that looks like a URL.
src/types.node.ts
URLLike (Interface)
Something that looks like a URL.
src/types.web.ts
AsyncError (Interface)
A container for a rejecting promise
src/core/client.ts
SessionData (Interface)
(no doc)
test/convenience/session.test.ts
PollingOptions (Interface)
(no doc)
src/bot.ts
MiddlewareObj (Interface)
(no doc)
src/composer.ts
StaticHas (Interface)
(no doc)
src/context.ts

Core symbols most depended-on inside this repo

orThrow
called by 183
src/context.ts
use
called by 68
src/composer.ts
text
called by 45
src/context.ts
matchFilter
called by 44
src/filter.ts
middleware
called by 42
src/composer.ts
filter
called by 32
src/composer.ts
webhookCallback
called by 29
src/convenience/webhook.ts
read
called by 26
src/convenience/session.ts

Shape

Method 533
Function 182
Class 34
Interface 30

Languages

TypeScript100%

Modules by API surface

src/context.ts233 symbols
src/core/api.ts196 symbols
src/convenience/keyboard.ts58 symbols
src/convenience/session.ts42 symbols
src/composer.ts34 symbols
src/convenience/inline_query.ts27 symbols
src/convenience/frameworks.ts27 symbols
src/core/client.ts25 symbols
src/bot.ts25 symbols
src/filter.ts17 symbols
src/core/payload.ts12 symbols
src/types.deno.ts9 symbols

Dependencies from manifests, versioned

@grammyjs/types3.28.0 · 1×
@types/debug4.1.12 · 1×
@types/node12.20.55 · 1×
@types/node-fetch2.6.2 · 1×
abort-controller3.0.0 · 1×
debug4.4.3 · 1×
deno2node1.16.0 · 1×
node-fetch2.7.0 · 1×

For agents

$ claude mcp add grammY \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact