I use Telegram API to send a message to a user with my bot. When the user sends me a message, that operation works but when I want to send a message to an user that haven't sent me any message to me before, then an error occurs (I have his user id):
{"ok":false,"error_code":400,"description":"Error: Bad Request: user not found"}
Is there a solution to solve this?
Telegram bots cannot be a conversation initiators - they can write to user only after that user sends a message to bot first: https://core.telegram.org/bots#4-how-are-bots-different-from-humans
If this error appears in a group, first you need add this bot to that group.