Skip to content

Best way to write a bubble? #21

Open

Description

@davidmann4

@ramonh I am thinking of the best way of defining bubbles with code:
spring_bot_for_messenger_1-xlarge_trans muac98d-ja8s9oi1lbgosvcxqla4yaqscerh0ndk4bq

send_bubble "http://image.com/image.png \n HEADLINE \n subheadline "
#or something like this?
send_bubble [{image: "http://", headline: "headline", description: "description"}]

also you can add buttons to them - hmm

another aproach would be content based:

send_bubble_websites --> list of urls, bots get title of websites and preview images etc ...

I am curious what you think about this topic!

Activity

  1. davidmann4 commented on Oct 11, 2016

    @davidmann4
    OwnerAuthor

    also we need a smart way to handle button clicks ...hmmm

  2. mraaroncruz commented on Oct 13, 2016

    @mraaroncruz
    Contributor

    The way button clicks (aka. postbacks) are handled in other frameworks is with a postback:MYPOSTBACK handler at the message boundaries or in the state machine.

    The messenger term for bubbles is Generic Templates. Bubbles may be misleading if you go with it. I thought you meant this https://developers.facebook.com/docs/messenger-platform/send-api-reference/sender-actions

    bussi, aaron

  3. mraaroncruz commented on Oct 13, 2016

    @mraaroncruz
    Contributor

    I like the second option with the hash. Good question about the buttons though.

    They deserve their own type. Maybe you should just wrap them and make a couple different types.

    Botstack::URLButton # or Botstack::Button::URL
    Botstack::PostbackButton # or Botstack::Button::Postback
    
    button = Botstack::Button::URL.new(title: "View Product", value: "http://example.com/peters_hat.jpg")
    
    template = Botstack::ButtonTemplate.new(message: "Choose something already!", buttons: [button])
    
    =begin
    Outputs
     {"message":{
        "attachment":{
          "type":"template",
          "payload":{
            "template_type":"button",
            "text":"Choose something already!",
            "buttons":[
              {
                "type":"web_url",
                "url":"http://example.com/peters_hat.jpg",
                "title":"View Product"
              }
            ]
          }
        }
      }}
    =end

    Downside being you'd need to define the buttons beforehand to send into reply_button but the method signature could be something like reply_button(message, buttons)

    If you were so inclined, you could even write button factory methods like

    def make_url_button(text, url)
    # and
    def make_postback_button(text, postback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions