arrow_back
Back

MadelineProto sendMessage: messaging users and bots

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

Send a message with messages->sendMessage:

use danog\MadelineProto\API;

$api = new API('session.file');

// Message to a bot:
$api->messages->sendMessage(['peer' => '@btc_tickets_bot', 'message' => 'Hello! How are you?']);

// Message to a user:
$api->messages->sendMessage(['peer' => '@AlexxxxMz', 'message' => 'Hello! When is the pump?']);

For peer you can pass a username in @username form. That works the same way for users and for bots.

code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

MadelineProto get_full_info: extended chat and channel details

arrow_forward