I am following this tutorial for making a dialogflow chatbot on Facebook. I have made a carousel and quick replies for two separate actions. How can I send a carousel followed by quick replies for one same action?
Using Dialogflow's node.js fulfillment library , you can call agent.add
multiple times to build up a response containing multiple elements.
To build a Facebook carousel, you could do something like the following within the fulfillment for your intent:
agent.add(new Payload('FACEBOOK', <object for Facebook carousel>));
agent.add(new Suggestion('first quick reply'));
agent.add(new Suggestion('second quick reply'));
Your message object can have an attachment
property (an object) for the carousel, and a quick_replies
property (an array) for the quick replies. . For example:
let messageObject = {
recipient: {
id: recipientId
},
message: {
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [
{
title: title,
image_url: imageUrl,
buttons: [
{
type: "web_url",
url: buttonUrl,
title: buttonTitle
}
]
}
]
}
},
quick_replies: [
{
"title": firstQuickReplyTitle,
"payload": firstQuickReplyPayload,
"content_type": "text"
},
{
"title": secondQuickReplyTitle,
"payload": secondQuickReplyPayload,
"content_type": "text"
}
]
}
}
See Messenger docs — Quick replies , Messenger docs — Generic template .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.