I can not send messages using the username of the destination, for example: @user
When I try to send, the following message appears:
TelegramResponseException in TelegramResponseException.php line 58:
Bad Request: chat not found
Has anyone ever come across this?
@username as chat_id can only be used to send messages to channels and supergroups. It is not possible to send messages to private chats using username.
https://core.telegram.org/bots/api/#sendmessage
@danilopinotti if you're looking to simply send a message to a specific user, you need to provide your bot with the user's ID. To get the user's ID, use @userinfobot in telegram client for that user. It will return user's handle, ID and the name.
Here is a link: https://t.me/userinfobot
You can try this on telegram.php
'bots' => [
'common' => [
'username' => 'Your_BOT',
'token' => 'YourTokenBOT-ex:1234567:ABCDEFGHIKLMNOPZ',
],
Most helpful comment
@usernameaschat_idcan only be used to send messages to channels and supergroups. It is not possible to send messages to private chats using username.https://core.telegram.org/bots/api/#sendmessage