Awesome
grammY examples
This repository contains various bots and setups to help you get started with grammY.
- Contact @BotFather to create a bot and get its token.
- Clone the repository.
- Paste your bot’s token to the source files of the examples you would like to
run (e.g.
./echo.ts
). - Run
npm install
from the root. - Run the examples this way:
npm run bot <name>
# For example, to run the echo example:
npm run bot echo
Hello World (echo
)
A simple bot that echoes the text messages it receives.
Send a Single Message (send-message
)
Not a real bot, only an illustration of sending a single message once. Might be useful in scripts.
Nested Menus (menu
)
Advanced menu example bot that lets you manage different dishes (Pasta, Pizza, Sushi, Entrecôte) via a nested menu structure. It shows how to build more complex menus when all the data is generated at runtime.
Menus with Media (menu-with-photo
)
Similar to the nested menu example, but with photos.
Menus with Conversation (menu-with-conversation
)
Similar to the nested menu example, but with buttons that enter conversations (short chats that can ask the user for additional information).
Sessions (stats
)
Full-blown example bot that counts messages in a chat and stores the statistics in session objects.
Lazy Sessions (stats-lazy
)
Full-blown example bot that counts photos in a chat and stores the statistics using lazy sessions. The advantage of lazy sessions is that the storage is only queried whenever data is actually needed.
(Note that this bot stores data in-memory, it does not connect to a database. Therefore, using lazy sessions does not make much sense. This bot is only an illustratation on how to use them.)
Runner Example (runner
)
Illustrates how to use the grammY runner
to run large bots.
Fastify Example (fastify
)
Simple example for using grammY
with
Fastify
and
Ngrok
Scaling Example (scaling
)
NOTE: This example is not endorsement of any directory structure. See
Awesome grammY
for live examples
instead.
A minimal example bot that demonstrates how various grammY objects can be
orchestrated together, including
custom context flavors
,
transformers
,
sessions with initial data
,
composers
,
and
routers
.
Deno Deploy Example »
Example bot that can run on Deno Deploy.
Supabase Edge Functions Example »
Example bot that can run on Supabase Edge Functions.
Vercel Serverless Node.js Example »
Example bot using Node.js on Vercel Serverless Functions.
Vercel Serverless Deno Example »
Example bot using Deno on Vercel Serverless Functions.
Vercel Serverless Bun Example »
Example bot using Bun on Vercel Serverless Functions.
Vercel Edge Runtime Example »
Example bot using Vercel Edge Functions.
AWS Lambda Example »
Example bot that can run using AWS Lambda.
Docker Example (Deno) »
Example Deno bot that can run using Docker.
Docker Example (Node.js) »
Example Node.js bot that can run using Docker.
Local Bot API Example »
Use Docker to setup a local Bot API server and run your bot on it.
Local Bot API with HTTPS Example »
Use Docker to setup a local Bot API server with a self-signed TLS certificate, and run your bot on it.
Please Contribute
We could have some more examples here, for example:
- command handling
- filter queries
- inline keyboards
- file support
and other things.