From 8ad7b1664dbb64f1a023a737d7e9de220476c4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolae=20Cas=C3=AEr?= Date: Thu, 10 Jan 2019 17:06:30 +0200 Subject: [PATCH 1/2] Added Quick Replies --- pymessenger/bot.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pymessenger/bot.py b/pymessenger/bot.py index 6c62932..84eb5a0 100644 --- a/pymessenger/bot.py +++ b/pymessenger/bot.py @@ -139,6 +139,31 @@ def send_generic_message(self, recipient_id, elements, notification_type=Notific } }, notification_type) + def send_quick_reply(self, recipient_id, text, type, title='', payload='', img_url='', notification_type=NotificationType.regular): + """Send a quick reply to the specified recipient with specific type of quick reply. + https://developers.facebook.com/docs/messenger-platform/reference/send-api/quick-replies/ + Input: + recipient_id: recipient id to send to + text: Text to ask for something + type: content_type. eg: text, location, user_phone_number, user_email + title: Title of quick reply + payload: Postback payload + img_url: Icon URL for quick Reply suggestion + Output: + Response from API as + """ + return self.send_message(recipient_id, { + "text": text, + "quick_replies":[ + { + "content_type":type, + "title":title, + "payload":payload, + "image_url":img_url + } + ] + }, notification_type) + def send_button_message(self, recipient_id, text, buttons, notification_type=NotificationType.regular): """Send text messages to the specified recipient. https://developers.facebook.com/docs/messenger-platform/send-api-reference/button-template From 55768e54541916ac33394a5bd2616982f24427c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolae=20Cas=C3=AEr?= Date: Thu, 10 Jan 2019 17:23:58 +0200 Subject: [PATCH 2/2] ReadMe Update --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2092570..fdeb072 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ This wrapper has the following functions: * send_text_message(recipient_id, message) * send_message(recipient_id, message) * send_generic_message(recipient_id, elements) +* send_quick_reply(recipient_id, text, type, title, payload, img_url) * send_button_message(recipient_id, text, buttons) * send_attachment(recipient_id, attachment_type, attachment_path) * send_attachment_url(recipient_id, attachment_type, attachment_url) @@ -91,7 +92,6 @@ bot.send_image_url(recipient_id, image_url) * Structured Messages * Receipt Messages -* Quick Replies * Airlines * Tests! @@ -99,6 +99,8 @@ bot.send_image_url(recipient_id, image_url) ![Screenshot of Echo Facebook Bot](https://cloud.githubusercontent.com/assets/68039/14516627/905c84ae-0237-11e6-918e-2c2ae9352f7d.png) +![Screenshot of Echo Facebook Bot Quick Reply](https://i.imgur.com/37YkYAY.jpg) + You can find an example of an Echo Facebook Bot in ```examples/```