How Can I Generate a Telegram Bot Token and Retrieve Group ID or Channel ID?
Integrating Telegram with Social Media Auto Publish (SMAP) requires a bot token and the IDs of the group or channel where the bot will operate.
This guide provides a step-by-step process to create a Telegram bot, retrieve its token, and obtain the necessary group or channel IDs.
Note :While MyChatInfoBot can retrieve both group and channel IDs without the newly created bot being added, the bot must be present in the channels and groups in order to publish to them using the bot token.
Follow the instructions below to seamlessly set up your Telegram bot and ensure smooth integration.
Sections Overview
- Generating a Telegram Bot Token
How to create a new bot using @BotFather and obtain the unique token required for integration using this newly created bot. - Adding the Bot and Retrieving the Channel ID
How to set the newly created bot as an admin in a Telegram channel and retrieve the channel ID using MyChatInfoBot. The bot must be added to the channel to publish using the token. - Adding the Bot and Retrieving Group ID
How to add the newly created bot to a Telegram group and use MyChatInfoBot to fetch the group ID. The bot must be added to publish using the token.
Generating a Telegram Bot Token
1. Start a Chat with @BotFather
Open the Telegram app or https://web.telegram.org/ and search for @BotFather
.
Start a conversation by clicking on the “Start” button
2. Create a New Bot
Type /newbot
in the chat and press Enter.
Follow the instructions to set a name and username for your bot. Ensure the username ends with “bot” (e.g., MyNewBot_bot
).
3. Receive Your Bot Token
After creating the bot, @BotFather will provide a unique token.
Save this token securely as it is required for integrating your bot with other applications.
Click the link to the bot from the @BotFather chat window, and start the newly created bot as shown below:
Adding the Bot and Retrieving the Channel ID
1. Add the Bot to the Channel
- Add the newly created bot to the Telegram channel where you want it to operate.
- Open the channel info by double-tapping the channel name and clicking the Edit icon.
Click the user icon .
Select the Administrators option
Click the user icon and choose the bot to add it as an administrator.
Add it as an administrator.
Configure the necessary permissions for the bot.
2. Get the Channel ID using MyChatInfoBot
Search for @MyChatInfoBot
and start a conversation
Start the bot
Forward a message from the channel to @MyChatInfoBot
to retrieve the channel ID.
Include a “-” prefix when using the channel ID in the Telegram settings of SMAP (e.g., -100123456789
).
Adding the Bot and Retrieving Group ID
1. Add the Bot to the Group :
-Add the newly created bot to the Telegram group where you want it to operate.
Navigate to the Administrators section in the group settings.
Click on the user icon to add the bot as an administrator.
Add new bot as Admin
2. Get the Group ID using MyChatInfoBot
Add MyChatInfoBot to the group to retrieve the Group id.
Get the Group ID
Include a “-” prefix when using the group ID in the Telegram settings of SMAP (e.g., -100123456789
).
You can now use the bot token and the retrieved group or channel IDs to integrate Telegram with Social Media Auto Publish (SMAP).