Create your bot with BotFather
BotFather is Telegram’s official bot for creating and managing bots.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.Create a new bot
Send the BotFather will ask you for two pieces of information:
/newbot command to BotFather.- Bot name - The display name for your bot (e.g., “My Support Bot”)
- Bot username - A unique username ending in “bot” (e.g., “my_support_bot”)
Save your bot token
After creation, BotFather will send you a message containing your bot token:Copy the token and add it to your
.env file:.env
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.Create a supergroup
The bot requires a supergroup (not a regular group) with Forum/Topics enabled.
- In Telegram, create a new group
- Add at least one member (you can remove them later)
- Go to group settings → Group Type → Convert to Supergroup
If you already have a supergroup, you can use it. Skip to the next step to enable Topics.
Enable Forum/Topics
Topics (also called Forums) allow the bot to create separate conversation threads for each user.
- Open the supergroup
- Tap the group name at the top to open settings
- Go to Group Type or Permissions
- Enable Topics (the toggle should turn blue/green)
Add your bot to the group
- Open the supergroup
- Tap the group name → Add Members
- Search for your bot by username (e.g.,
@my_support_bot) - Add the bot to the group
Promote bot to administrator
The bot needs administrator permissions to manage topics and send messages.
- Open the supergroup settings
- Go to Administrators → tap on your bot
- 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
main.py:39 when initializing the TopicManager:support_bot/main.py
Get the group ID
You need the supergroup’s chat ID for theOPERATOR_GROUP_ID configuration variable.
Add a bot to get the ID
The easiest way to get the group ID is using a helper bot.
- Method 1: Using @RawDataBot
- Method 2: Using @getidsbot
- Method 3: Using your bot
- Add @RawDataBot to your operator group
- The bot will immediately send a message with the group information
- Look for
"chat": {"id": -1001234567890} - Copy the negative number (including the minus sign)
Add to configuration
Add the group ID to your
.env file:.env
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.Test your setup
Verify that everything is configured correctly before running the bot.Send a test message
- Open a private chat with your bot
- Send
/startor any message - Check your operator group - a new topic should be created
- 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.
Troubleshooting
Bot doesn't respond to messages
Bot doesn't respond to messages
Possible causes:
- Bot token is incorrect or invalid
- Bot is not running (check console for errors)
- Bot was blocked or stopped by the user
- Verify
BOT_TOKENin.envmatches the token from @BotFather - Check the bot process is running with
LOG_LEVEL=DEBUG - Try sending
/startto restart the conversation
Topics are not being created
Topics are not being created
Possible causes:
- Topics/Forum is not enabled on the group
- Bot doesn’t have “Manage Topics” permission
- The group is not a supergroup
- Wrong
OPERATOR_GROUP_IDin configuration
- 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_IDmatches your group’s ID
Operator replies don't reach users
Operator replies don't reach users
Possible causes:
- Replying outside of a topic (replies must be in the user’s topic)
- The original message was not mirrored by the bot
- User blocked the bot
- 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
Can't get the group ID
Can't get the group ID
Possible causes:
- Helper bot doesn’t have permission to send messages
- Using a regular group instead of a supergroup
- 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
Permission denied errors
Permission denied errors
Error in logs:orSolutions:
- 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.”