pimax/fb-messenger-php

How do I include a Quick Reply in a Structured Message

Closed this issue · 7 comments

According to the Facebook docs, you can include QuickReplies in your structured data.

https://www.facebook.com/business/help/1646890868956360

How do I achieve this using this library!

Great library, by the way!!!

Hi Thanks for the quick response.

From the link, I don't see any sample code or any discussion on how to achieve this...

Example will follow shortly

Thank-you @wittfabian . Will wait...

Sorry to bother @wittfabian ... still waiting for the example

For the impatient the short version.
Should work.

                    $bot->send(new StructuredMessage($message['sender']['id'],
                        StructuredMessage::TYPE_GENERIC,
                        [
                            'elements' => [
                                new MessageElement("First item", "Item description", "", [
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'),
                                    new MessageButton(MessageButton::TYPE_WEB, 'Web link', 'http://facebook.com')
                                ]),
                                new MessageElement("Second item", "Item description", "", [
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'),
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'Second button')
                                ]),
                                new MessageElement("Third item", "Item description", "", [
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'First button'),
                                    new MessageButton(MessageButton::TYPE_POSTBACK, 'Second button')
                                ])
                            ]
                        ],
                        [ 
                        	new QuickReplyButton(QuickReplyButton::TYPE_TEXT, 'First button','THIS PARAM is required, atleast put a whitespace!') 
                        ]
                    ));

Lol. Sorry...

Much appreciated though! Thanks for your support and your awesome library!

Sincerely,
The Impatient