'How to send a Telegram message to a username using bot api or telegram api?
Hi I am trying to build a website login system where users are able to log in using their telegram. I would like to achieve this workflow:
- User selects to login/sign up via telegram.
- User enters their username (@ExampleJoe).
- A 6-digit verification code is sent to them via my Telegram bot (@ExampleBot).
- The user enters the received 6-digit code into my website and is allowed to enter.
I have issues with steps 2-3 where my bot can send them a direct message (not in a group chat) with only their username. I am aware that sendMessage method in the Telegram bot API requires a chat_id and that a user_id is also suitable. However, I do not know how to get the user_id with just the user's username.
Solution 1:[1]
That's not possible with the Bot API. You'd have to use a userbot for that. Note however, that TG provides a native login widget that you can use instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CallMeStag |
