Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sometimes bot can't mention user by id

Tags:

telegram-bot

I am writing an address book bot for my company group chat. The main idea of the bot is an ability to search users telegram contacts. For example /find <first name & last name> search bot's database and reply mention of a founded user, so people can contact with that person, clicking on its mention (via [inline mention of a user](tg://user?id=123456789)).
The problem is sometimes bot get ENTITY_MENTION_USER_INVALID. Furthermore, after few minutes, mention of that user can be successful. As a workaround, I try to use @userName instead of mentions by userId, but now I have another trouble: not all the people have @userName.
So the question is: How to avoid ENTITY_MENTION_USER_INVALID error?

like image 508
RoninDev Avatar asked Nov 21 '17 11:11

RoninDev


1 Answers

As said here:

These mentions are only guaranteed to work if the user has contacted the bot in the past or is a member in the group where he was mentioned.

You can only mention users that at least started the bot.

like image 95
Alireza Afzal Aghaei Avatar answered Sep 30 '22 15:09

Alireza Afzal Aghaei