Reputation: 61
I want to know what are the ways to get the chat id of phone numbers in telegram bot programming. I have a small project that I need to get Chatid of a group of phone numbers in telegram very fast .
Upvotes: -1
Views: 5914
Reputation: 1922
Telegram's API for now only allows bots interact with people using their ChatId.
Short Answer: There is no way provided by the API to achieve what you want.
Long Answer: You can manually add this number to your contact list and then send them a message with the link to your bot (for sure you need to send them something promising or else they will not open your bot). Once they click /start
creating a function that stores the chat_id
+ firstname
in a db so you can easily retrieve later then your bot can ask for the contact of the user so you can know which chat_id belongs to a particular phone number (if the user shares it with you then fine else at least you have the chat id which is important).
Upvotes: 1
Reputation: 2292
Sorry, you can't. Telegram bot API work in next scenario: User interact with Bot first and bot may ask for a message or for phone or for location. There is no way to send phone number and get chatId. You can ask user for a phone and in the response, you will give chat ID and Phone number of user if user will send phone number to the bot.
After it, you can campare revieved User's phone number with your database of phone number and append it with chatId.
Hope it help you.
Upvotes: 1