def send_list_template( self, recipient_id=None, user_ref=None, phone_number=None, elements=None, buttons=None, quick_replies=None, ): """Sends a list template to the recipient. # Arguments recipient_id: page specific id of the recipient user_ref: optional. user_ref from the checkbox plugin phone_number: Optional. Phone number of the recipient with the format +1(212)555-2368. Your bot must be approved for Customer Matching to send messages this way. elements: Array of objects that describe items in the list. Minimum of 2 elements required. Maximum of 4 elements is supported. buttons: Button to display at the bottom of the list. Maximum of 1 button is supported. quick_replies: An array of objects the describe the quick reply buttons to send. A maximum of 11 quick replies are supported. """ list_template_payload = ListTemplatePayload( dict(template_type="list", elements=elements, buttons=buttons) ) attachment = Attachment(dict(type="template", payload=list_template_payload)) message = Message({"quick_replies": quick_replies, "attachment": attachment}) response = self._post(message, recipient_id, user_ref, phone_number) return response
def send_generic_template( self, recipient_id=None, user_ref=None, phone_number=None, elements=None, quick_replies=None, ): """Sends a generic template to the recipient. # Arguments recipient_id: page specific id of the recipient user_ref: optional. user_ref from the checkbox plugin phone_number: Optional. Phone number of the recipient with the format +1(212)555-2368. Your bot must be approved for Customer Matching to send messages this way. elements: An array of element objects that describe instances of the generic template to be sent. Specifying multiple elements will send a horizontally scrollable carousel of templates. A maximum of 10 elements is supported. quick_replies: An array of objects the describe the quick reply buttons to send. A maximum of 11 quick replies are supported. """ generic_template_payload = GenericTemplatePayload( dict(template_type="generic", elements=elements) ) attachment = Attachment(dict(type="template", payload=generic_template_payload)) message = Message({"quick_replies": quick_replies, "attachment": attachment}) response = self._post(message, recipient_id, user_ref, phone_number) return response
def send_button_template( self, recipient_id=None, user_ref=None, phone_number=None, text=None, quick_replies=None, buttons=None, ): """Sends a button template to the recipient. # Arguments recipient_id: page specific id of the recipient user_ref: optional. user_ref from the checkbox plugin phone_number: Optional. Phone number of the recipient with the format +1(212)555-2368. Your bot must be approved for Customer Matching to send messages this way. text: UTF-8-encoded text of up to 640 characters. Text will appear above the buttons. quick_replies: An array of objects the describe the quick reply buttons to send. A maximum of 11 quick replies are supported. buttons: Set of 1-3 buttons that appear as call-to-actions. """ button_template_payload = ButtonTemplatePayload( dict(template_type="button", text=text, buttons=buttons) ) attachment = Attachment(dict(type="template", payload=button_template_payload)) message = Message({"quick_replies": quick_replies, "attachment": attachment}) response = self._post(message, recipient_id, user_ref, phone_number) return response
def send_receipt_template( self, recipient_id=None, user_ref=None, phone_number=None, recipient_name=None, elements=None, order_number=None, currency=None, payment_method=None, timestamp=None, address=None, summary=None, adjustments=None, quick_replies=None, ): """Sends a receipt template to the recipient. # Arguments recipient_id: page specific id of the recipient user_ref: optional. user_ref from the checkbox plugin phone_number: Optional. Phone number of the recipient with the format +1(212)555-2368. Your bot must be approved for Customer Matching to send messages this way. elements: Optional. Array of a maximum of 100 element objects that describe items in the order. Sort order of the elements is not guaranteed. order_number: The order number. Must be unique. currency: The currency of the payment. payment_method: The payment method used. Providing enough information for the customer to decipher which payment method and account they used is recommended. This can be a custom string, such as, "Visa 1234". timestamp: Optional. Timestamp of the order in seconds. address: Optional. The shipping address of the order. summary: The payment summary. adjustments: Optional. An array of payment objects that describe payment adjustments, such as discounts. quick_replies: An array of objects the describe the quick reply buttons to send. A maximum of 11 quick replies are supported. """ receipt_template_payload = ReceiptTemplatePayload( dict( template_type="receipt", recipient_name=recipient_name, elements=elements, order_number=order_number, currency=currency, payment_method=payment_method, timestamp=timestamp, address=address, summary=summary, adjustments=adjustments, ) ) attachment = Attachment(dict(type="template", payload=receipt_template_payload)) message = Message({"quick_replies": quick_replies, "attachment": attachment}) response = self._post(message, recipient_id, user_ref, phone_number) return response
def send_file( self, recipient_id=None, user_ref=None, phone_number=None, url=None, quick_replies=None, ): """Sends a file to the recipient. # Arguments recipient_id: page specific id of the recipient user_ref: Optional. user_ref from the checkbox plugin url: URL of the file quick_replies: An array of objects the describe the quick reply buttons to send. A maximum of 11 quick replies are supported. """ attachment = Attachment( dict(type="file", payload=RichMediaPayload(dict(url=url))) ) message = Message({"quick_replies": quick_replies, "attachment": attachment}) response = self._post(message, recipient_id, user_ref, phone_number) return response