Search code examples
telegramtelegram-botpython-telegram-botphp-telegram-botlua-telegram-bot

ways to get chat id of a phone number in telegram bot


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 .


Solution

  • 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).