![](https://private-user-images.githubusercontent.com/26162440/259665736-c4371683-3e99-4b1c-ae8e-11ccbea78f4b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA3OTcwOTksIm5iZiI6MTcyMDc5Njc5OSwicGF0aCI6Ii8yNjE2MjQ0MC8yNTk2NjU3MzYtYzQzNzE2ODMtM2U5OS00YjFjLWFlOGUtMTFjY2JlYTc4ZjRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzEyVDE1MDYzOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEwY2UwZWFhMzUyNzczODRlNGVlMTg4MDBlMWEwNjc3ZDA1ZTA4OWIwNDFiZmEwMTgzYjQwOWM3ZjU1MzExNDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.KSKqf9r4-LWlK6Wt7yKWyq6Xf8wtgfjRnjAkITcbx90)
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:
-
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.
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 --no-commit --allow-unrelated-histories
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 --no-commit --allow-unrelated-histories
Branch: example/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/prisma -X theirs --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. |