I’m working on a Telegram bot project and need to figure out how to obtain chat IDs from phone numbers. My use case involves getting the chat IDs for multiple phone numbers quickly and efficiently. What methods are available for this task? I’ve been searching for solutions but haven’t found a clear approach yet. Are there any API endpoints or bot methods that can help me map phone numbers to their corresponding chat IDs? I’m particularly interested in batch processing since I need to handle several contacts at once. Any code examples or best practices would be really helpful for my implementation.
Nope, you can’t convert phone numbers to chat IDs with Telegram’s Bot API. They block this for privacy reasons - bots can’t just look up users by phone number. The only way that works is getting users to message your bot first. Once they start a chat, you can grab their chat ID and link it to whatever info they share. Users have to opt in, which is how Telegram wants it. For bulk stuff, set up a registration flow. Have people message your bot with a command or use an invite link. You’ll build your chat ID list naturally without breaking privacy rules.
There’s no way to convert phone numbers to chat IDs using Telegram’s Bot API. They built it this way on purpose to stop spam and protect privacy. I hit the same wall building a notification system at work. Here’s what actually worked: make users contact your bot first. I set up a web form that grabbed phone numbers and spit out unique codes. Users then had to message those codes to the bot to finish signing up. This let me connect their phone numbers to chat IDs in my database without breaking Telegram’s rules. Takes longer than you’d want, but it’s the only method that actually works and keeps you compliant.
yep, telegram has these restrictions for privacy. you can’t just get chat IDs from numbers. best bet is to use deep links or get users to message your bot to start the interaction. that’s how you can collect those chat IDs securely.