A modern, production-ready Telegram bot skeleton for services, notifications, and lightweight order management.
Built withpython-telegram-bot
(async),SQLAlchemy
, andhttpx
. Fully containerized and easy to deploy on any small VPS.
- User-friendly commands:
/start
→ Welcome & orientation/help
→ Clear, scannable list of all commands/order
→ Guided multi-step order placement (title, qty, optional note)/status <id>
→ Live status lookup (external API integration)/history
→ Review last 3–5 orders/contact
→ Leave a support message
- Persistent storage: SQLite (via SQLAlchemy) for orders & message logs
- Admin-ready: Easy to extend with admin-only commands (e.g.,
/ping
) - Rate limiting: Built-in per-user cooldown to prevent spam
- External API stub: Mock-first design for order status endpoint
- Deployment ready: Dockerfile + docker-compose.yml provided
- Clean architecture: Clear separation of handlers, services, and models
# 1. Clone repository
git clone https://github.com/yourname/telegram-service-bot.git
cd telegram-service-bot
# 2. Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment
cp .env.example .env # edit with your values
# 5. Run the bot
python -m src.bot
# Build & start
docker compose up -d --build
# View logs
docker compose logs -f
Variable | Required | Default | Description |
---|---|---|---|
BOT_TOKEN |
✅ | — | Telegram BotFather token |
ADMIN_IDS |
Optional | — | Comma-separated list of admin user IDs |
EXTERNAL_API_BASE |
Optional | — | Base URL of external API for /status |
EXTERNAL_API_KEY |
Optional | — | API key if required by external API |
DATABASE_URL |
Optional | sqlite:///data.db |
Database URL (SQLite/Postgres) |
RATE_LIMIT_SECONDS |
Optional | 3 |
Per-user rate limit (seconds) |
telegram-service-bot/
├─ src/
│ ├─ bot.py # App entrypoint
│ ├─ config.py # Environment config
│ ├─ handlers/ # Command handlers
│ ├─ models/ # SQLAlchemy models
│ ├─ services/ # API + storage utilities
│ └─ middleware/ # Rate limiting
├─ tests/ # (future) Unit tests
├─ requirements.txt
├─ Dockerfile
├─ docker-compose.yml
└─ README.md
- Keep your
BOT_TOKEN
and API keys in.env
only (never commit). - Enable Privacy Mode in BotFather.
- Validate user input (title, qty, etc.).
- Use rate limiting to reduce spam & abuse.
- v0.1 → Core features (this release)
- v0.2 → Webhook support (Caddy/Nginx, HTTPS)
- v0.3 → Admin dashboard (FastAPI)
- v0.4 → Push notifications (status changes, inventory alerts)
- v1.0 → Multi-language support + CI/CD pipeline
Pull requests and issues are welcome! Please:
- Use English for all code, comments, and commit messages.
- Follow PEP8 + project conventions.
- Keep feature branches small and focused.
Released under the MIT License. See LICENSE for details.
Telegram Service/Notify Bot — designed for reliability, clarity, and quick iteration.
“Simple flows, real persistence, and production focus from day one.”