![](https://private-user-images.githubusercontent.com/26162440/259665736-c4371683-3e99-4b1c-ae8e-11ccbea78f4b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyMDY3MTIsIm5iZiI6MTcyMzIwNjQxMiwicGF0aCI6Ii8yNjE2MjQ0MC8yNTk2NjU3MzYtYzQzNzE2ODMtM2U5OS00YjFjLWFlOGUtMTFjY2JlYTc4ZjRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODA5VDEyMjY1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0N2RhMzgxZjU5ZWRiNDU5NWFkYTIyMzNmYTMwOWE5NmNiNTRmMzc0MzRhODllYzRlMDI5OGRiODQ4MzU3MDQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.3IXAcA-ufmRkbj9XhcrCDexJtBxKhLEZyTPCvrd8_ik)
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 [email protected]: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 [email protected]: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 [email protected]: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 [email protected]: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 [email protected]: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 [email protected]: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 [email protected]: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 | Description |
---|---|
NODE_ENV | Node environment (development or production) |
LOG_LEVEL | Log level |
BOT_SERVER_HOST | Server address (default 0.0.0.0) |
BOT_SERVER_PORT | Server port (default 80) |
BOT_ALLOWED_UPDATES | List of update types to receive |
BOT_TOKEN | Token, get it from @BotFather |
BOT_WEBHOOK | Webhook endpointWill be used to setup webhook in production mode. |
BOT_ADMIN_USER_ID | Administrator user IDCommands, such as/setcommands , will only be available to the user with this ID. |