I want mention users even those which do not have a username.
If a user has set up a username I return
Hi @username
as an answer but if a user does not have one I can't do that.
I tried using the unique User ID e.g.
@5642166
but that did not work.
How can I achieve that?
So, the easiest way to do it is talking to [@userinfobot](https://telegram.me/userinfobot). If you need to find somebody else's ID, forward a message to the bot. Click on the group you want and see the url displayed on your browser. If it's a __public__ group, you can simply use it's `@name` as an id.
Getting StartedOpen the telegram app and search for @BotFather. Click on the start button or send “/start”. Then send “/newbot” message to set up a name and a username. After setting name and username BotFather will give you an API token which is your bot token.
On Telegram, you've got your Telegram ID, and then you've got your Telegram user ID. The former is the name that you chose. To change your Telegram ID, go to the hamburger menu (three horizontal lines) and then go to Settings. The same goes on your mobile app, go to the hamburger menu, then go to Settings.
According to official documentation it is possible to mention user by its numerical id with markup:
Markdown style
To use this mode, pass Markdown in the
parse_mode
field when usingsendMessage
. Use the following syntax in your message:
[inline mention of a user](tg://user?id=123456789)
and you can also use HTML
style :
HTML style
To use this mode, pass HTML in the parse_mode field when using sendMessage. The following tags are currently supported:
<a href="tg://user?id=123456789">inline mention of a user</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With