Open-source Telegram support bot: users chat with the bot in private messages, while operators work inside a forum-enabled supergroup (Topics).
For each user, the bot automatically creates a separate forum topic and mirrors the entire conversation there. Operator replies from the topic are sent back to the user’s private chat.
- One user → one forum topic for operators
- Bidirectional message forwarding (user ↔ operators)
- Reply mirroring across chats (reply in topic ↔ reply in private chat)
- Automatic topic creation
- SQLite for routing + reply mapping, optional message history
- Built with aiogram 3
- Python 3.10+ (recommended 3.11+)
- An operator supergroup with Forum / Topics enabled
- Bot permissions in the supergroup:
- Manage Topics
- Permission to send messages
- Create a virtual environment and install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Create a .env file based on .env.example and set:
- BOT_TOKEN
- OPERATOR_GROUP_ID — supergroup ID (e.g. -100...)
- DB_PATH — SQLite database path (required for routing)
- LOG_MESSAGES — set to 0 to disable message history logging
- Run the bot:
python -m support_bot- A user sends a message to the bot in private chat.
- The bot creates (or finds) a forum topic in OPERATOR_GROUP_ID linked to that user.
- All user messages are mirrored into that topic.
- Replies are mirrored when the original message exists on the other side.
- SQLite stores routing and reply links. Message history is stored in SQLite (DB_PATH). Set LOG_MESSAGES=0 to disable history logging.
The bot works only with supergroups that have Topics (Forum) enabled. If topics are not being created, check that the bot has the Manage Topics permission.
MIT