Comment on page
How to Setup a Telegram Bot
Notes: Creating a bot is streamlined by Telegram’s Bot API, which gives the tools and framework required to integrate your code.
Related Resources:
Search "BotFather" at your Telegram, message @BotFather on Telegram to register a name for your bot and receive its API token.
Your bot token is its unique identifier – store it in a secure place, and only share it with people who need direct access to the bot. Everyone who has your token will have full control over your bot.



Option 1: Invite a bot named @getuseridbot into the Telegram Chat, and the Chat ID will be automatically returned by the bot (remember to remove the bot after obtaining the Chat ID).

Option 2: Use Telegram API to search for the Chat ID
- Step 1: Invite the bot you created to a designated Telegram chat, and then send a message in that Telegram chat.
- Step 2: Enter https://api.telegram.org/botToken/getUpdates in your browser (replace the red text with the API token provided by @BotFather), and you will receive the following JSON
{"ok":true,"result":[{"update_id":586790674,
"channel_post":{"message_id":6,"sender_chat":{"id":-1001805125122,"title":"blocktest","type":"channel"},"chat":{"id":-1001805125122,"title":"blocktest","type":"channel"},"date":1695698471,"text":"hihi"}}]}
After sorting, the information is shown as follows:
{
"ok": true,
"result": [ {
"update_id": 586790674,
"channel_post": {
"message_id": 6,
"sender_chat": {
"id": -1001805125122,
"title": "blocktest",
"type": "channel"
},
"chat": {
"id": -1001805125122,
"title": "blocktest",
"type": "channel"
},
"date": 1695698471,
"text": "hihi"
}
}]
}
Step 3: Find the Chat ID from "chat:" id":-1001805125122.
Last modified 2mo ago