How do I include a Quick Reply in a Structured Message
Closed this issue · 7 comments
tinonetic commented
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!!!
wittfabian commented
tinonetic commented
Hi Thanks for the quick response.
From the link, I don't see any sample code or any discussion on how to achieve this...
wittfabian commented
Example will follow shortly
tinonetic commented
Thank-you @wittfabian . Will wait...
tinonetic commented
Sorry to bother @wittfabian ... still waiting for the example
wittfabian commented
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!')
]
));
tinonetic commented
Lol. Sorry...
Much appreciated though! Thanks for your support and your awesome library!
Sincerely,
The Impatient