Telegram bot: How to mention user by its id (not its username)

telegramtelegram-bot

I am creating a telegram bot and using sendMessage method to send the messages.
it is easy to mention user using @username, But how to mention user when they don't have username?

If using the telegram app/web, we can mentioned the user by @integer_id (name), and telegram app/web will convert it into clickable text. integer_id will be generated automatically when we select the user, after typing @.

another background:
I am trying to use forceReply and I want to target user, if they have username, I can easily target them, by mentioning them on the text on sendMessage method.

the bot I am creating is a "quiz" like bot. where each player need to take turn, and the bot is sending them the question, each msg from bot will target different player.

NOTE: I am not disabling the Privacy Mode, I don't want telegram bombing my server with msg I don't need. it was overloading my cheap nasty server. so, disabling it not an option.

I am open for other solution, where the bot can listen to selected player.

thanks.

UPDATE 21/10:
I've spoke to BotSupport for telegram, they said, for now Bots can't mention user without username.

so in my case, I still keep using forceReply, and also, gave a short msg to user which doesn't have username to set it up, so they can get the benefit from forceReply function.

Best Answer

According to official documentation it is possible to mention user by its numerical id with markup:

[inline mention of a user](tg://user?id=123456789)

Related Topic