Open davidmann4 opened 7 years ago
also we need a smart way to handle button clicks ...hmmm
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
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)
@ramonh I am thinking of the best way of defining bubbles with code:
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!