# The Telegram Bot Framework.
[![Bot API](https://img.shields.io/badge/Bot%20API-6.7-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
[![Deno](https://shield.deno.dev/x/grammy)](https://deno.land/x/grammy)
[![npm](https://img.shields.io/npm/v/grammy?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/grammy)
[![All Contributors](https://img.shields.io/github/all-contributors/grammyjs/grammy?style=flat&labelColor=000&color=3b82f6)](#contributors-)
## _[docs.](https://grammy.dev) [reference.](https://deno.land/x/grammy/mod.ts) [chat.](https://telegram.me/grammyjs) [news.](https://telegram.me/grammyjs_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](https://grammy.dev) 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](https://www.typescriptlang.org/) (or JavaScript) and run on [Node.js](https://nodejs.org/) or [Deno](#deno-support).
## Quickstart
> If you are new to Telegram bots, read the official [Introduction for Developers](https://core.telegram.org/bots) written by the Telegram team.
Visit [@BotFather](https://t.me/BotFather) and create a new bot. You will obtain a **bot token**.
Create a new directory and run
```bash
npm install grammy
```
inside it. Then create a file `bot.js` with this content:
```ts
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
```bash
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](https://grammy.dev), and an [API Reference](https://doc.deno.land/https://deno.land/x/grammy/mod.ts). It even integrates with your code editor, e.g. [VS Code](https://code.visualstudio.com/). 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](https://t.me/grammyjs) 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](https://grammy.dev)
βmain project website and documentation.
Gets you started and explains all concepts.
### [grammY API reference](https://doc.deno.land/https://deno.land/x/grammy/mod.ts)
βreference of everything that grammY exports.
Useful to look up descriptions about any element of grammY.
### [grammY examples](https://github.com/grammyjs/examples)
βrepository full of example bots.
Includes a setup to easily run any of them.
### [Awesome grammY](https://github.com/grammyjs/awesome-grammY)
βlist of awesome projects built with grammY.
Helpful if you want to see some real-world usage.
### [grammY chat](https://t.me/grammyjs)
β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](https://t.me/grammyjs_ru).
### [grammY news](https://t.me/grammyjs_news)
βThe channel where updates to grammY and the ecosystem are posted.
We are also [on Twitter](https://twitter.com/grammy_js).
### [Telegram Bot API Reference](https://core.telegram.org/bots/api)
βdocumentation of the API that Telegram offers, and that grammY connects to under the hood.
## Deno Support
All grammY packages published by [@grammyjs](https://github.com/grammyjs) run natively on [Deno](https://deno.land). 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`](https://deno.land/x/grammy).
You may also be interested in [why we support Deno](https://grammy.dev/resources/faq.html#why-do-you-support-deno).
## JavaScript Bundles
The grammY core package in this repository is available as a JavaScript bundle via .
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 .
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 Β»](./CONTRIBUTING.md)
## Contributors β¨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
Contributions of any kind welcome!