Search code examples
c#telegramtelegram-bot

Can I get a phone number by user id via Telegram Bot API?


I am using Telegram Bot API for sending instant messages to users. I have installed nuget package. This package is recommend by telegram developers.

I have created a telegram bot and successfully got access to it by using code. When I send messsage to bot, bot gets some info about sender.

enter image description here

I need the phone numbers of users to identify them in our system and send the information back to them.

My question is Can i get a user phone number by telegramUserId?

I'm doing it for user convenience. If I could to get a user phone number I should't have to ask for it from the user.

Now my command like this:

debt 9811201243

I want

debt

Solution

  • It's possible with bots 2.0 check out bot api docs.

    https://core.telegram.org/bots/api#keyboardbutton

    https://core.telegram.org/bots/2-0-intro#locations-and-numbers