Skip to main content
This guide walks you through setting up the Telegram-specific components required for the Support Bot: creating your bot, setting up the operator group with Forum/Topics, and configuring permissions.

Create your bot with BotFather

BotFather is Telegram’s official bot for creating and managing bots.
1

Start a chat with BotFather

Open Telegram and search for @BotFather, or click the link to open a chat.Click Start or send /start to begin.
2

Create a new bot

Send the /newbot command to BotFather.
/newbot
BotFather will ask you for two pieces of information:
  1. Bot name - The display name for your bot (e.g., “My Support Bot”)
  2. Bot username - A unique username ending in “bot” (e.g., “my_support_bot”)
3

Save your bot token

After creation, BotFather will send you a message containing your bot token:
Done! Congratulations on your new bot.
You will find it at t.me/your_bot_username
Use this token to access the HTTP API:
123456789:ABCDEFghijklmnopQRSTUVwxyz123456789
Keep this token secret! Anyone with your token can control your bot. Never commit it to version control or share it publicly.
Copy the token and add it to your .env file:
.env
BOT_TOKEN=123456789:ABCDEFghijklmnopQRSTUVwxyz123456789
4

Configure bot settings (optional)

You can customize your bot’s appearance:
  • /setdescription - Set a description shown in the bot’s profile
  • /setabouttext - Set the “About” text
  • /setuserpic - Upload a profile picture
  • /setcommands - Define bot commands for the menu

Create and configure the operator group

The operator group is where your support team will handle user conversations. Each user gets their own forum topic in this group.
1

Create a supergroup

The bot requires a supergroup (not a regular group) with Forum/Topics enabled.
  1. In Telegram, create a new group
  2. Add at least one member (you can remove them later)
  3. Go to group settings → Group TypeConvert to Supergroup
If you already have a supergroup, you can use it. Skip to the next step to enable Topics.
2

Enable Forum/Topics

Topics (also called Forums) allow the bot to create separate conversation threads for each user.
  1. Open the supergroup
  2. Tap the group name at the top to open settings
  3. Go to Group Type or Permissions
  4. Enable Topics (the toggle should turn blue/green)
The bot will not work without Topics enabled. Forum topics are essential for organizing user conversations.
3

Add your bot to the group

  1. Open the supergroup
  2. Tap the group name → Add Members
  3. Search for your bot by username (e.g., @my_support_bot)
  4. Add the bot to the group
4

Promote bot to administrator

The bot needs administrator permissions to manage topics and send messages.
  1. Open the supergroup settings
  2. Go to Administrators → tap on your bot
  3. Enable the following permissions:
    • Manage Topics (required) - Create and manage forum topics
    • Delete Messages (optional) - Clean up topics
    • Pin Messages (optional) - Pin important messages in topics
Manage Topics permission is critical. Without it, the bot cannot create topics for new users and will fail silently.
The required permissions are enforced by checking in main.py:39 when initializing the TopicManager:
support_bot/main.py
topics = TopicManager(db=db, operator_group_id=config.operator_group_id)

Get the group ID

You need the supergroup’s chat ID for the OPERATOR_GROUP_ID configuration variable.
1

Add a bot to get the ID

The easiest way to get the group ID is using a helper bot.
  1. Add @RawDataBot to your operator group
  2. The bot will immediately send a message with the group information
  3. Look for "chat": {"id": -1001234567890}
  4. Copy the negative number (including the minus sign)
Example response:
{
  "chat": {
    "id": -1001234567890,
    "type": "supergroup",
    "title": "Support Operators"
  }
}
2

Add to configuration

Add the group ID to your .env file:
.env
OPERATOR_GROUP_ID=-1001234567890
The ID will always be a negative number starting with -100 for supergroups. If you see a positive number or one without -100 prefix, you might have a regular group instead of a supergroup.
3

Remove helper bots (optional)

After getting the group ID, you can remove the helper bot from your operator group if desired.

Test your setup

Verify that everything is configured correctly before running the bot.
1

Verify group settings

Confirm your operator group has:
2

Verify configuration file

Check your .env file has all required values:
.env
BOT_TOKEN=123456789:ABCDEFghijklmnopQRSTUVwxyz123456789
OPERATOR_GROUP_ID=-1001234567890
DB_PATH=./support_bot.sqlite3
LOG_LEVEL=INFO
LOG_MESSAGES=1
3

Start the bot

Run the bot to test the configuration:
python -m support_bot
You should see:
INFO:support_bot:Started as @your_bot_username (id=123456789)
4

Send a test message

  1. Open a private chat with your bot
  2. Send /start or any message
  3. Check your operator group - a new topic should be created
  4. The user’s message should appear in that topic
The topic title will be the user’s name or username. All messages from that user will appear in this topic.
5

Test operator replies

  1. In the operator group, open the user’s topic
  2. Reply to the user’s message in the topic
  3. Check your private chat with the bot - your reply should appear there
The bot mirrors conversations bidirectionally. Users see operator replies as if they’re chatting directly with the bot.

Troubleshooting

Possible causes:
  1. Bot token is incorrect or invalid
  2. Bot is not running (check console for errors)
  3. Bot was blocked or stopped by the user
Solutions:
  • Verify BOT_TOKEN in .env matches the token from @BotFather
  • Check the bot process is running with LOG_LEVEL=DEBUG
  • Try sending /start to restart the conversation
Possible causes:
  1. Topics/Forum is not enabled on the group
  2. Bot doesn’t have “Manage Topics” permission
  3. The group is not a supergroup
  4. Wrong OPERATOR_GROUP_ID in configuration
Solutions:
  • Verify Topics are enabled in group settings
  • Check bot has administrator rights with “Manage Topics” permission
  • Ensure the group is converted to a supergroup
  • Verify OPERATOR_GROUP_ID matches your group’s ID
Possible causes:
  1. Replying outside of a topic (replies must be in the user’s topic)
  2. The original message was not mirrored by the bot
  3. User blocked the bot
Solutions:
  • Always reply within the user’s specific topic
  • Check that user messages are appearing in topics first
  • Verify the bot can send messages to the user
Possible causes:
  1. Helper bot doesn’t have permission to send messages
  2. Using a regular group instead of a supergroup
Solutions:
  • Ensure the helper bot can send messages in the group
  • Convert your group to a supergroup first
  • Try Method 3 (using your own bot) from the “Get the group ID” section
Error in logs:
aiogram.exceptions.TelegramForbiddenError: Forbidden: bot is not a member of the supergroup
or
aiogram.exceptions.TelegramBadRequest: Bad Request: not enough rights to manage topics
Solutions:
  • Ensure bot is added to the operator group
  • Promote bot to administrator
  • Grant “Manage Topics” permission explicitly

Requirements summary

For quick reference, here are the Telegram requirements from the source code:

Python Requirements

From README.md:18-24:
  • Python 3.10+ (recommended 3.11+)
  • Bot permissions:
    • Manage Topics
    • Permission to send messages

Group Requirements

  • Supergroup (not regular group)
  • Forum/Topics enabled
  • Bot added as administrator
  • Correct group ID in configuration
As stated in README.md:53-55: “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.”

Next steps

After completing the Telegram setup:
  1. Run the bot and start handling messages
  2. Learn how message routing works
  3. Understand the database schema

Build docs developers (and LLMs) love