JEFF
JEFF

Reputation: 161

Get the userid in telegram

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?

Upvotes: 1

Views: 14255

Answers (2)

wowkin2
wowkin2

Reputation: 6355

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 the user_id which you are looking for.

Upvotes: -1

Beppe C
Beppe C

Reputation: 13973

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

update.message.from_user.id

When processing a Callback Query

update.callback_query.from_user.id

Upvotes: 4

Related Questions