botman / driver-facebook

BotMan Facebook Messenger Driver
MIT License
71 stars 72 forks source link

Generic template with quick replies #44

Closed johntiror closed 5 years ago

johntiror commented 6 years ago

Currently it's not possible to add quick_replies to GenericTemplate. We need to add a way to achieve this: image uploaded from ios

mpociot commented 6 years ago

Is this possible? It looks like it’s just two separate messages.

johntiror commented 6 years ago

there are not, since otherwise it'd require a title. here an example payload:

{
    "recipient": {
        "id": recipient_id
    },
    "message": {
        "attachment":{
            "type":"image",
            "payload":{
                "url": image_url
            }
        },
        "quick_replies": [
            {
                "content_type":"text",
                "title": "Next Image",
                "payload": "YOUR_DEFINED_PAYLOAD_FOR_NEXT_IMAGE"
            }
        ]
    }
}
aidonsnous commented 6 years ago

I think this doesn't depends on BotMan but facebook since facebook is the one establishing the protocol about what a generic template can integrate.

christophrumpel commented 5 years ago

Yes I agree. If anyone finds out how to hack it, please write it here.

Dipeshlohani commented 5 years ago

This worked for me

{
  "facebook": {
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
           {
            "title":"Welcome!",
            "image_url":"https://petersfancybrownhats.com/company_image.png",
            "subtitle":"We have the right hat for everyone.",
            "default_action": {
              "type": "web_url",
              "url": "https://petersfancybrownhats.com/view?item=103",
              "webview_height_ratio": "tall"
            },
            "buttons":[
              {
                "type":"web_url",
                "url":"https://petersfancybrownhats.com",
                "title":"View Website"
              },{
                "type":"postback",
                "title":"Start Chatting",
                "payload":"DEVELOPER_DEFINED_PAYLOAD"
              }              
            ]      
          }
        ]
      }
    },
     "quick_replies":[
      {
        "content_type":"text",
        "title":"Search",
        "payload":"<POSTBACK_PAYLOAD>",
        "image_url":"http://example.com/img/red.png"
      },
      {
        "content_type":"location"
      }
    ]
  }
}