Find out my own user ID for sending a message using the Telegram API

For Telegram, how can I find out my own user ID ( chat_id ) for use with the Telegram API?

I want to send myself a message through the Telegram API, for example like this:

 https://api.telegram.org/bot<BOTID>/sendMessage 
+10
source share
4 answers

Send a message to your bot, then extract the update using:

 https://api.telegram.org/bot<BOTID>/getUpdates 

In the json returned string you will find chat_id / user_id.
In the same chat with the bot, chat_id is equal to user_id.
Now you can send your message:

 https://api.telegram.org/bot<BOTID>/sendMessage?chat_id="yourchatid"&text="Hello!" 
+14
source

You can use Json Dump Bot .

The corresponding output section will look like:

 { "message": { "from": { "id": WHAT_YOU_ARE_LOOKING_FOR, "is_bot": false, "first_name": "Paolo", "language_code": "it" } } } 

or: https://t.me/userinfobot

+5
source

An easier way is to go to the Telegram web version and go to the chat whose identifier you want to find out. It will be in the url, which is in the form:

 https://web.telegram.org/#/im?p=u<ID>_<something> 

This also works for groups, but their identifiers are negative, so if the URL looks like

 https://web.telegram.org/#/im?p=g1234567 

then the chat group id is 1234567.

+1
source

The placeholder is actually a token, not a key. Of course, you already know what it is and can use it?

https://core.telegram.org/bots/api#authorizing-your-bot

0
source

All Articles