Bot starter template based on grammY bot framework.
- Scalable structure
- Config loading and validation
- Internationalization, language changing
- Graceful shutdown
- Logger (powered by pino)
- Fast and low overhead server (powered by fastify)
- Ready-to-use deployment setups:
- Examples:
- Prisma ORM
- grammY plugins:
- Web Apps:
-
Create a new repository using this template.
-
Create an environment variables file:
cp .env.example .env
-
Set BOT_TOKEN environment variable in
.env
file. -
Launch bot
Development mode:
# 1. Install dependencies npm i # 2. Run bot (in watch mode) npm run dev
Production mode:
# 1. Install dependencies npm i --only=prod # 2. Set NODE_ENV to production and change BOT_WEBHOOK to the actual URL to receive updates # 3. Run bot npm start # or npm run start:force # if you want to skip type checking
npm run lint
— Lint source code.npm run format
— Format source code.npm run typecheck
— Runs type checking.npm run dev
— Starts the bot in development mode.npm run start
— Starts the bot.npm run start:force
— Starts the bot without type checking.
Docker (docker.com)
Branch: deploy/docker-compose (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge deployment setup
git merge template/deploy/docker-compose -X theirs --squash --no-commit --allow-unrelated-histories
Vercel (vercel.com)
Branch: deploy/vercel (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge deployment setup
git merge template/deploy/vercel -X theirs --squash --no-commit --allow-unrelated-histories
Prisma ORM (prisma.io)
Branch: example/orm-prisma (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge example
git merge template/example/orm-prisma -X theirs --squash --no-commit --allow-unrelated-histories
grammY conversations (grammy.dev/plugins/conversations)
Branch: example/plugin-conversations (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge example
git merge template/example/plugin-conversations -X theirs --squash --no-commit --allow-unrelated-histories
grammY runner (grammy.dev/plugins/runner)
Branch: example/plugin-runner (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge example
git merge template/example/plugin-runner -X theirs --squash --no-commit --allow-unrelated-histories
Web App (Vite, TypeScript)
Branch: example/webapp (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge example
git merge template/example/webapp -X theirs --squash --no-commit --allow-unrelated-histories
Branch: example/webapp-vue (open diff)
Use in your project:
- Add the template repository as a remote
git remote add template git@github.com:bot-base/telegram-bot-template.git
git remote update
- Merge example
git merge template/example/webapp-vue -X theirs --squash --no-commit --allow-unrelated-histories
Variable | Type | Description |
---|---|---|
NODE_ENV | String | Application environment (development or production ) |
BOT_TOKEN | String | Token, get it from @BotFather. |
BOT_WEBHOOK | String | Webhook endpoint, used to configure webhook in production environment. |
LOG_LEVEL | String |
Optional.
Application log level.
See Pino docs for a complete list of available log levels. Defaults to info .
|
BOT_SERVER_HOST | String |
Optional. Server address. Defaults to 0.0.0.0 .
|
BOT_SERVER_PORT | Number |
Optional. Server port. Defaults to 80 .
|
BOT_ALLOWED_UPDATES | Array of String |
Optional. A JSON-serialized list of the update types you want your bot to receive. See Update for a complete list of available update types. Defaults to an empty array (all update types except chat_member ).
|
BOT_ADMIN_USER_ID |
Number or Array of Number |
Optional. Administrator user ID. Commands such as /setcommands will only be available to a user with this ID. Defaults to an empty array. |