• Stars
    star
    2,109
  • Rank 21,878 (Top 0.5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Telegram Bot Framework.
grammY

The Telegram Bot Framework.

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. We are also on Twitter.

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

📖
trgwii
trgwii

💻 👀
KnightNiwrem
KnightNiwrem

💻 🐛 🔌 📖 💡 👀 🧑‍🏫
Muthu Kumar
Muthu Kumar

👀
EdJoPaTo
EdJoPaTo

🔌 📖 🤔 👀 🐛 💻
Amir Zouerami
Amir Zouerami

📖 🔌 💡
Roj
Roj

📖 👀 🚇 🌍 💻 🤔 🧑‍🏫 💡
jokasimr
jokasimr

🐛
Ciki Momogi
Ciki Momogi

📖 🌍
AndreoliBR
AndreoliBR

👀
Kirill Loskutov
Kirill Loskutov

📖 🐛 🤔 🎨 💬 👀 💻 🔌
Andrew Lane
Andrew Lane

🐛 👀
code-withAshish
code-withAshish

📖 💬 🐛 👀
Stephane Mensah
Stephane Mensah

🐛 🔌
Asaku01
Asaku01

📖
ppsimn
ppsimn

🐛
Satont
Satont

🔌 📖
deptyped
deptyped

💡 📖 🐛 🌍
Jacek Nowacki
Jacek Nowacki

📖 💻 🐛 👀 🤔
Outvi V
Outvi V

💻
Ikko Ashimine
Ikko Ashimine

📖
Yevhen Denesiuk
Yevhen Denesiuk

👀 🐛 💻
prastian
prastian

🐛 💻
Sayem Chowdhury
Sayem Chowdhury

🤔
kospra
kospra

🤔 💻
Chimit
Chimit

📖
Calsi
Calsi

📖
Jonas Zohren
Jonas Zohren

🐛 💻
linbuxiao
linbuxiao

📖 🌍
JiquanWang99
JiquanWang99

📖 🌍
Borhan Hafez
Borhan Hafez

🔌
WingLim
WingLim

📖 🌍 💻 🔌 🤔
taotie111
taotie111

📖 🌍
Merlin
Merlin

📖
Darvesh
Darvesh

🐛 💻 👀
dcdunkan
dcdunkan

🐛 💻 🔌 👀 📖 🤔 🚇 🔧 🧑‍🏫 🚧
Kid
Kid

📖 🌍
Slava Fomin II
Slava Fomin II

🐛 📖
Kiko Beats
Kiko Beats

📖
Vsevolod
Vsevolod

💻 🤔 👀
Habemuscode
Habemuscode

👀 📖 🌍 🚧
Nikita Kolmogorov
Nikita Kolmogorov

🔌
Vitaliy Meshchaninov
Vitaliy Meshchaninov

🐛 💻
Дилян Палаузов
Дилян Палаузов

🐛 💻
lmx-Hexagram
lmx-Hexagram

📖
Ilya Semenov
Ilya Semenov

🤔 👀 💻
abdollahzadehAli
abdollahzadehAli

📖 💡
Saeed Nasiri
Saeed Nasiri

📖
Hesoyam
Hesoyam

📖
yrzam
yrzam

🐛
drmikecrowe
drmikecrowe

👀
Martin
Martin

📖 🐛 👀
Pavel
Pavel

💡
Thor 雷神 Schaeff
Thor 雷神 Schaeff

💡
x066it
x066it

🐛 👀
kolay
kolay

👀
Evgeny Nepomnyashchiy
Evgeny Nepomnyashchiy

👀
Ananta Krsna dasa
Ananta Krsna dasa

📖
Mighty Ali
Mighty Ali

💻 👀 🤔
三三
三三

🐛 💻
Roz
Roz

🐛 💻 👀 🚇 🤔 🧑‍🏫
Dani Haro
Dani Haro

💻 🔌 📖
Ryukaizen
Ryukaizen

📖
Alisher Ortiqov
Alisher Ortiqov

📖
Tony Tkachenko
Tony Tkachenko

📖
Ra
Ra

💻
sartoshi-foot-dao
sartoshi-foot-dao

📖
Yoel Navas E.
Yoel Navas E.

🤔
Vitor Gomes
Vitor Gomes

🐛 💻
Aditya
Aditya

🐛 👀
Udit Karode
Udit Karode

👀
Mike Rockétt
Mike Rockétt

👀 🐛
Srinivasa IK Varanasi
Srinivasa IK Varanasi

💻
abdoo9
abdoo9

🐛 💻
ak4zh
ak4zh

👀 🤔 💻
Nikolay Lapshin
Nikolay Lapshin

💻
Aquatica
Aquatica

📖 💬
Fa Dzikri
Fa Dzikri

👀 📖 🌍
Chandler Lattin
Chandler Lattin

💻 👀 🔌
Sergey Parfenyuk
Sergey Parfenyuk

🐛
Émerson Felinto
Émerson Felinto

🐛
Petr Stankin
Petr Stankin

🐛
Maxim Lebedev
Maxim Lebedev

🤔 💻
Madnex
Madnex

📖
Svyatoslav Tupchienko
Svyatoslav Tupchienko

💻
Vladislav Deryabkin
Vladislav Deryabkin

🐛 💻 👀
Kashyap Sharma
Kashyap Sharma

💡
AlexOwl
AlexOwl

🐛 💻
Shrimadhav U K
Shrimadhav U K

💻
Binamra Lamsal
Binamra Lamsal

🤔
gertminov
gertminov

📖
Stephan Psaras
Stephan Psaras

🐛
shevernitskiy
shevernitskiy

🐛 👀
mrmaster009
mrmaster009

📖
Andrey Zontov
Andrey Zontov

🐛 💻 💬 🤔 📖 🌍
Abbass Al-Musawi
Abbass Al-Musawi

📖
ArunR
ArunR

🐛 💻
NDA
NDA

🐛 🤔 💻
MatyiFKBT
MatyiFKBT

📖
Chris Andrew C. L.
Chris Andrew C. L.

🐛 💻 👀
Islam Kiiasov
Islam Kiiasov

💻
Shane Avery Sistoza
Shane Avery Sistoza

🤔 💻 ⚠️
Maicol
Maicol

💻
Nazar Antoniuk
Nazar Antoniuk

📖 🌍 🚧
Aleksei Ivanov
Aleksei Ivanov

👀
Vladislav Ponomarev
Vladislav Ponomarev

⚠️ 💻 📦
Louie Tan
Louie Tan

👀
Leandro Vargas
Leandro Vargas

🐛 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

awesome-grammY

A collection of community projects leveraging the grammY ecosystem.
184
star
2

examples

Examples to kickstart your journey with grammY.
TypeScript
111
star
3

web-app

Building blocks for Telegram Web Apps.
TypeScript
72
star
4

storages

Storage adapters for grammY sessions.
TypeScript
48
star
5

conversations

Conversational interfaces for grammY.
TypeScript
44
star
6

website

The grammY documentation website.
TypeScript
43
star
7

stateless-question

Ask stateless questions to users with privacy mode enabled.
TypeScript
40
star
8

types

Type declarations of the Telegram Bot API.
TypeScript
38
star
9

nestjs

grammY integration for NestJS.
TypeScript
36
star
10

telegram.tools

Web-based tools for Telegram developers.
TypeScript
33
star
11

i18n

Internationalization for grammY powered by Fluent.
TypeScript
30
star
12

components

Ready-to-use components for getting user input.
TypeScript
28
star
13

menu

Interactive menus for grammY.
TypeScript
27
star
14

ratelimiter

Limit the amount of handled messages.
TypeScript
22
star
15

runner

Scale bots that use long polling to receive updates.
TypeScript
18
star
16

validator

Validation logic for Web Apps and login widgets.
TypeScript
17
star
17

vscode

The grammY VS Code extension.
TypeScript
16
star
18

parse-mode

Safely format messages and keep their source code maintainable.
TypeScript
15
star
19

fluent

Internationalization for grammY powered by Fluent.
TypeScript
14
star
20

hydrate

Hydration plugin for API calls and context objects.
TypeScript
11
star
21

auto-chat-action

Automate sending chat actions.
TypeScript
11
star
22

commands

Work-in-progress plugin for managing commands with grammY.
TypeScript
11
star
23

auto-thread

Send messages in forums properly.
TypeScript
10
star
24

chat-members

Store chats, users, and chat memberships.
TypeScript
9
star
25

transformer-throttler

Throttling transformer for grammY.
TypeScript
9
star
26

docs-bot

A bot for browsing the grammY documentation website.
TypeScript
9
star
27

emoji

Helpers for sending emojis.
TypeScript
9
star
28

files

Handle and download received media files.
TypeScript
9
star
29

create-grammy

Command-line grammY scaffolding tool.
Go
9
star
30

plugin-template

Starting point for plugin development.
TypeScript
8
star
31

history

TypeScript
8
star
32

link-checker

Tool for checking, reporting and even fixing broken links in grammY's documentation.
TypeScript
8
star
33

storage-firestore

Google Firestore storage adapter
TypeScript
7
star
34

router

Router middleware for grammY.
TypeScript
7
star
35

translations-bot

Internal bot used in the translation workflow.
TypeScript
7
star
36

auto-retry

A transformer function for retrying requests.
TypeScript
7
star
37

free-session-backend

Backend of the free session storage.
TypeScript
7
star
38

tools

A collection of web-based tools to help in the bot development process. [Unmaintained. Succeeded by telegram.tools.]
TypeScript
7
star
39

storage-deta

Deta.sh Base storage adapter for grammY
TypeScript
6
star
40

opentelemetry

Work-in-progress integration with OpenTelemetry for collecting metrics and monitoring bots.
TypeScript
6
star
41

storage-free

Free storage for grammY sessions
TypeScript
5
star
42

awilix

Work-in-progress integration with Awilix to write composable and testable bots.
TypeScript
5
star
43

debug

TypeScript
4
star
44

storage-supabase

Supabase storage adapter
TypeScript
4
star
45

storage-denodb

DenoDB database storage adapter for grammY
TypeScript
3
star
46

.github

This repository configures the organization’s profile and other organization-wide settings.
3
star
47

noraids

30.01.2024. Try harder next time 😈
TypeScript
3
star
48

guard-bot

Simple captcha bot for the group chat
TypeScript
1
star