Skip to content

apkuzmin/telegram-support-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Support Bot (aiogram 3 + Topics)

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.

Telegram Support Bot

Features

  • 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

Requirements

  • Python 3.10+ (recommended 3.11+)
  • An operator supergroup with Forum / Topics enabled
  • Bot permissions in the supergroup:
    • Manage Topics
    • Permission to send messages

Quick Start

  1. Create a virtual environment and install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. 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
  1. Run the bot:
python -m support_bot

How It Works

  • 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.

Notes

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.

License

MIT

About

Telegram support bot: each user → separate forum topic for operators

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages