How to use quick replies with attachment
Asked Answered
S

4

8

In official documentation of quick replies says:

Quick Replies work with all message types including text message, image and template attachments.

But when i try send it with template_type: button, I got error:

{
    "error": {
        "message": "(#100) Only one of text or attachment can be specified",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "H8w+ZfRbBub"
    }
}

That I try to send:

{
    "recipient": {"id": "234567890"},
    "message": {
        "text": "TEXT_MESSAGE",
        "quick_replies": [
            {
                "content_type": "text",
                "title": "SOME_TITLE_1",
                "payload": "PAY_LOAD_1"
            },
            {
            "content_type": "text",
            "title": "SOME_TITLE_2",
            "payload": "PAY_LOAD_2"
            }
        ],
        "attachment": {
            "type": "template",
            "payload": {
                "template_type": "button",
                "text": "TEXT_MESSAGE",
                "buttons": [
                    {
                        "title": "READ_MORE_BUTTON",
                        "type": "postback",
                        "payload": "look:1:c"
                    }
                ]
            }
        }
    }
}

when I sent without message.text, I got error:

{
    "error": {
        "message": "(#100) Cannot use both CTA and quick reply",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "C0DDxGzaUUj"
    }
}

What is CTA?

How send quick replies with attachment?

Seidel answered 8/7, 2016 at 13:15 Comment(5)
Oh I realize now that I was using a generic template as normal, and not trying to send the trio of: text, buttons, quick replies. Did you find a way to do this or a workaround?Xavierxaviera
@Xavierxaviera not realy. I can send two different messages only.Seidel
So do you have to send a button message and then wait for the delivery and then send the quick replies? And is there even a way to send quick replies without some other sort of information?Xavierxaviera
Same problem here... Facebook documentation sucks so much!Repetend
answer by Sajin gets directly to the point #42673031Sarcastic
C
7

This message structure should work for sending an image attachment with quick replies:

{
    "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"
            }
        ]
    }
}

Hope that helps dmitry.

Costard answered 3/9, 2016 at 21:41 Comment(0)
B
4

try this way. It will insert both buttons and quick replies but button will be at top and quick replies will be at the bottom

"message":{
    "quick_replies":[
        {"content_type":"text",
        "title":"title1",
        "payload":"SUPPLEMENT_1"},
        {"content_type":"text",
        "title":"title2",
        "payload":"PAYLOAD_1"
        }
    ],
 "attachment":{
  "type":"template",
  "payload":{
    "template_type":"button",
    "text":"your text",
    "buttons":[
      {
        "type":"postback",
        "title":"Confirm",
        "payload":"USER_DEFINED_PAYLOAD"
      }
    ]
  }
 }
}
Barcelona answered 25/1, 2017 at 12:9 Comment(0)
R
2

So, I've got your same problem and I did some searches around.

What does CTA stands for?

First of all, CTA stands for Call-To-Action. These are the buttons you create with a request for a Button Template, Generic Template or with the Persistent Menu Thread Settings.

It seems that, although as you said FB official documentation explicitly states that Quick Replies are supported with ANY template, for some reason this doesn't include the Button template.

Why is that?

It seems logical to me that the Button Template should be used to present the user with a choice, same thing that the Quick Replies do, so it would be redundant.

Why is that not documented?

I'm assuming that it's probably due to the fact that the Messenger Platform API is still in beta and there are lots of changes from day to day. Personally, I'm working on a Java framework for doing Facebook Messenger bots and I'm finding that many things are not very well documented and often the error messages you get back are misleading. So, you should probably accept the fact that the Button Template and Quick Replies doesn't work together. Quick Replies works with any other template or with text messages though.

Repetend answered 28/8, 2016 at 14:6 Comment(0)
H
0

This worked for me while using dialogflow

{
  "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"
      }
    ]
  }
}
Hiatt answered 27/5, 2019 at 5:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.