I’m using @username_to_id_bot
to retrieve the user_id
.
Sometimes the user doesn’t have a username.
How can I retrive in this case?
Question posted in Telegram API
A comprehensive official documentation can be found here.
A comprehensive official documentation can be found here.
2
Answers
For each user response the Telegram payload includes information like user_id and chat_id.
You can always access these navigating the JSON.
When processing a simple text response
When processing a Callback Query
If you are using web application, in address bar you can see URL like following:
https://web.telegram.org/#/im?p=u1111111111_2222222222222222222
In this case
1111111111
is theuser_id
which you are looking for.