Skip to content

alaleh-ki/telehelp-template

Repository files navigation

🤖 Telehelp --- Telegram Support Bot

A production-ready Telegram support bot built with grammY, TypeScript, MongoDB, and Redis.

📼 Demo

Telehelp bot in action

✨ Features

  • 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

🛠 Tech Stack

  • Node.js + TypeScript
  • grammY (bot framework)
  • MongoDB + Mongoose
  • Redis + ioredis
  • Pino (logging)
  • Docker & Docker Compose (deployment)

📋 Requirements

  • Node.js 16+
  • MongoDB instance
  • Redis instance
  • Telegram bot token from @BotFather

🚀 Local Development

Install

git clone <repository-url>
cd telegram-bot-starter-main
npm install

Configure Environment

Create 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.log

Start Bot

npm run dev

Send /start to your bot to test.


🐳 Production Deployment (Docker)

.env (production)

TOKEN=your_bot_token
MONGO=mongodb://mongo:27017/telehelp
REDIS_URL=redis://redis:6379
BOT_ADMINS=123456789
DEBUG=false
LOG_FILE_PATH=

Start

npm run docker:compose:up

Logs:

docker-compose logs -f bot

Stop:

npm run docker:compose:down

⚙️ Environment Variables

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

🎛 Commands

User

  • /start
  • /support
  • /endsupport
  • /help
  • /language

Admin

  • /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 /cancelbroadcast to exit)

🛠 Scripts

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

🔧 Troubleshooting

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

📄 License

MIT License --- see LICENSE.


Made with ❤️ using grammY • TypeScript • MongoDB • Redis

About

A robust Telegram support bot built for real support teams. Provides automated admin assignment, threaded conversations, English/Farsi language options, Redis-based session management, user blocking, broadcasts, and reliable production deployment via Docker.

Topics

Resources

License

Stars

Watchers

Forks

Contributors