I have gone through many forums and API of telegram also.
But could not get the proper answer.
Well here is my main question.
I have list of users with their mobile numbers in my database and from all those, I want to send them messages on their telegram. So for that I will need their chat ID. How can I retrieve that by their MobileNumber? If I will have chat id, I am able to send message to them by using the following reference.
Telegram php example send message
I have visited the following link to get the chat id by manually from BOT by user itself. But I want automatic from script.
How to obtain Telegram chat_id for a specific user?
Thanks.
3
Answers
You can’t use bots to find a user on Telegram using their phone number.
I’m not familiar with PHP. but there is a way to do this:
As you know you can send a contact in telegram bot using its phoneNumber and a firsName (Doesn’t need to be the real first name of the contact who owns that number).
After sending the contact to a chatID(no matter what chatID you choose, can be your own personal chat ID), you can look for its UserID.
In C# I used this piece of code to see whether a phone number exists in telegram or not and it worked very well.
I believe this can be done in PHP too.
By Telegram bot you can send messages only to users that started chat with your bot. you can obtain their chat_id (not phone number) from received query.
So you can not send message to another people even if you have their phone numbers.