我想在不使用Webhook的情况下使用Dialogflow创建一个Mockup Facebook Bot。
可以在Dialogflow中定义特定于通道的答案。您可以在其中选择预定义的响应类型或自定义有效负载。简单按钮的自定义有效负载有效,但是当我尝试创建caroussel时,什么也没有发生。
https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic#carousel
我在哪里可以找到Dialogflow支持的内容和不支持的内容?如何使用自定义有效载荷来构建卡鲁塞尔卡?
{
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Welcome!",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
"subtitle": "We have the right hat for everyone.",
"default_action": {
"type": "web_url",
"url": "https://commons.wikimedia.org/wiki/File:Example.png",
"messenger_extensions": false,
"webview_height_ratio": "tall",
"fallback_url": "https://website.com/"
},
"buttons": [
{
"type": "web_url",
"url": "https://commons.wikimedia.org/wiki/File:Example.png",
"title": "View Website"
},
{
"type": "postback",
"title": "Start Chatting",
"payload": "DEVELOPER_DEFINED_PAYLOAD"
}
]
}
]
}
}
}
}
答案 0 :(得分:1)
如果您从JSON中删除 messenger_extensions 和 fallback_url ,它应该可以正常工作。
通过在dialogflow中使用自定义有效负载,只要您发送正确的对应频道json,所有内容都受支持
这是轮播(多个元素)的经过工作测试的示例
{
"facebook":{
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"Welcome!",
"image_url":"https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
"subtitle":"We have the right hat for everyone.",
"default_action":{
"type":"web_url",
"url":"https://www.google.com/",
"webview_height_ratio":"tall"
},
"buttons":[
{
"type":"web_url",
"url":"https://www.google.com/",
"title":"View Website"
},
{
"type":"postback",
"title":"Start Chatting",
"payload":"DEVELOPER_DEFINED_PAYLOAD"
}
]
},
{
"title":"Welcome!",
"image_url":"https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
"subtitle":"We have the right hat for everyone.",
"default_action":{
"type":"web_url",
"url":"https://www.google.com/",
"webview_height_ratio":"tall"
},
"buttons":[
{
"type":"web_url",
"url":"https://www.google.com/",
"title":"View Website"
},
{
"type":"postback",
"title":"Start Chatting",
"payload":"DEVELOPER_DEFINED_PAYLOAD"
}
]
},
{
"title":"Welcome!",
"image_url":"https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png",
"subtitle":"We have the right hat for everyone.",
"default_action":{
"type":"web_url",
"url":"https://www.google.com/",
"webview_height_ratio":"tall"
},
"buttons":[
{
"type":"web_url",
"url":"https://www.google.com/",
"title":"View Website"
},
{
"type":"postback",
"title":"Start Chatting",
"payload":"DEVELOPER_DEFINED_PAYLOAD"
}
]
}
]
}
}
}
}