A production-ready Telegram support bot built with grammY, TypeScript, MongoDB, and Redis.
- Support Routing --- Automated admin assignment with request queueing
- Message Threading --- Full message mapping & history
- Multi-language --- English + Farsi, extensible
- Redis Sessions --- Fast session storage & rate limiting
- Structured Logging --- Pino logging with file or stdout mode
- Production Ready --- Error handling, graceful shutdown, Docker support
- Broadcasts --- Admins can broadcast text, photos, or videos to all non-admin, non-blocked users from the admin menu
- User Blocking --- Admins can block or unblock users from the support user card; blocked users cannot open support or receive broadcasts
- Node.js + TypeScript
- grammY (bot framework)
- MongoDB + Mongoose
- Redis + ioredis
- Pino (logging)
- Docker & Docker Compose (deployment)
- Node.js 16+
- MongoDB instance
- Redis instance
- Telegram bot token from @BotFather
git clone <repository-url>
cd telegram-bot-starter-main
npm installCreate a .env file:
TOKEN=your_bot_token
MONGO=mongodb://localhost:27017/telehelp
REDIS_URL=redis://localhost:6379
BOT_ADMINS=123456789
DEBUG=true
LOG_FILE_PATH=logs/app.lognpm run devSend /start to your bot to test.
TOKEN=your_bot_token
MONGO=mongodb://mongo:27017/telehelp
REDIS_URL=redis://redis:6379
BOT_ADMINS=123456789
DEBUG=false
LOG_FILE_PATH=npm run docker:compose:upLogs:
docker-compose logs -f botStop:
npm run docker:compose:down| Variable | Description | Required |
|---|---|---|
TOKEN |
Telegram bot token | Yes |
MONGO |
MongoDB URL | Yes |
REDIS_URL |
Redis URL | No |
BOT_ADMINS |
Comma-separated admin IDs | No |
DEBUG |
Enable debug logs | No |
LOG_FILE_PATH |
Path to log file (empty=stdout) | No |
/start/support/endsupport/help/language
/supportlist/cancelreply/closestuck
In addition to commands, admins have access to an inline Admin Menu (shown after /start), which includes:
- Support Requests --- View users currently assigned to you and open their user card (reply, history, close, block/unblock)
- Broadcast --- Enter broadcast mode and send a text message, photo, or video to all non-admin, non-blocked users (use
/cancelbroadcastto exit)
| Script | Description |
|---|---|
npm run dev |
Development mode |
npm run build |
Build TypeScript |
npm run start |
Run production build |
npm run lint |
Lint code |
npm run lint:fix |
Fix lint issues |
npm run docker:compose:up |
Start Docker stack |
npm run docker:compose:down |
Stop Docker stack |
| Issue | Fix |
|---|---|
| Bot not responding | Check bot token & .env |
| Mongo/Redis failing | Ensure services are running |
| TypeScript errors | Run npm run build for details |
| Docker errors | Ensure Docker daemon is running |
MIT License --- see LICENSE.
Made with ❤️ using grammY • TypeScript • MongoDB • Redis
