rehabstudio / fbmessenger

A python library to communicate with the Facebook Messenger API's
Other
114 stars 51 forks source link

Sending a message to a specific user by ID #60

Closed Loukious closed 5 years ago

Loukious commented 5 years ago

Would you like assistance or advice? Assistance. Issue description I can't seem to be able to send a message to a specific user after getting his ID Steps to reproduce I get the recipient_id through sender=self.get_user_id() Then why I try to use self.send({'text': "msg"}, sender, 'RESPONSE') it fails with the error: ValueError: '2595091087229339' is not a valid 'messaging_type' It seems like it's handling the variable sender as if it's the messaging_type not recipient_id Any idea what am I doing wrong?

wittfabian commented 5 years ago

For MessengerClient you need: send(self, payload, recipient_id, messaging_type='RESPONSE', notification_type='REGULAR', timeout=None, tag=None)

For BaseMessenger you need: send(self, payload, messaging_type='RESPONSE', notification_type='REGULAR', timeout=None, tag=None)

In BaseMessenger, the recipient_id is handled via the last_message.

Loukious commented 5 years ago

Solved. Thanks a lot.