Sometimes bot can't mention user by id

Viewed 2107

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?

1 Answers
Related