skip to Main Content

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?

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search