Example #1
0
 def sendGenericMessage(self, recipient_id):
     #       make button for first element in template
     btns1 = [
         element.button(
             "web_url", "Open Web URL",
             "https://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy"
         ),
         element.button("postback", "Call Postback",
                        "Payload for first bubble"),
     ]
     #       make first element for template with btns1
     elmnt1 = element.element(
         "42", "Next-generation guides",
         "https://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy",
         "https://localhost/static/fbbot/falling_down.gif", btns1)
     #       make template with elements list
     template = GenericTemplate(recipient_id, [elmnt1])
     #       adding a new element for template
     elmnt2 = template.add_element("books", "books collection",
                                   "https://www.books.com/",
                                   "https://localhost/fbbot/books.png")
     #       adding buttons for elmnt2
     template.add_button_to(elmnt2, "web_url", "Open Web URL",
                            "https://www.oculus.com/en-us/touch/")
     template.add_button_to(elmnt2, "postback", "Call Postback",
                            "Payload for second bubble")
     #       get data in template for callSendAPI
     msg_data = template.get_data()
     self.callSendAPI(msg_data)
Example #2
0
 def sendButtonMessage(self, recipient_id):
     text = "This is test text"
     buttons = [
         element.button("web_url", "Open Web URL",
                        "https://www.oculus.com/en-us/rift/"),
         element.button("postback", "Trigger Postback",
                        "DEVELOPER_DEFINED_PAYLOAD"),
         element.button("phone_number", "Call Phone Number", "+55555555555")
     ]
     template = ButtonTemplate(recipient_id, text, buttons)
     msg_data = template.get_data()
     self.callSendAPI(msg_data)
Example #3
0
 def add_button_to(self, element_ref, button_type, title, metadata):
     index = self.elements.index(element_ref)
     self.elements[index]['buttons'].append(
         element.button(button_type, title, metadata))
     return self.elements[index]['buttons'][-1]
Example #4
0
 def add_button_by_element_index(self, index, button_type, title, metadata):
     self.elements[index]['buttons'].append(
         element.button(button_type, title, metadata))
     return self.elements[index]['buttons'][-1]
Example #5
0
 def add_button(self, button_type, title, metadata):
     self.buttons.append(element.button(button_type, title, metadata))