Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use quick replies with attachment

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?

like image 617
Dmitry Avatar asked Jul 08 '16 13:07

Dmitry


3 Answers

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.

like image 130
Allan Berger Avatar answered Oct 19 '22 18:10

Allan Berger


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"
      }
    ]
  }
 }
}
like image 25
Dimuth Ruwantha Avatar answered Oct 19 '22 19:10

Dimuth Ruwantha


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.

like image 2
Aurasphere Avatar answered Oct 19 '22 20:10

Aurasphere