我在看一些非常流行的机器人,比如“卫报”,我注意到每当你从它那里得到一个通用的模板回复时,它也会显示一些快速回复按钮(见附图)。 “The Guardian Bot”是如何做到这一点的?他如何结合快速回复和通用模板?一定是涉及到两条消息。
最佳答案
这在 Dialogflow 中对我有用,在后端返回类似的 Json 对象以实现结果:
{
"facebook": {
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"Welcome!",
"image_url":"https://petersfancybrownhats.com/company_image.png",
"subtitle":"We have the right hat for everyone.",
"default_action": {
"type": "web_url",
"url": "https://petersfancybrownhats.com/view?item=103",
"webview_height_ratio": "tall"
},
"buttons":[
{
"type":"web_url",
"url":"https://petersfancybrownhats.com",
"title":"View Website"
},{
"type":"postback",
"title":"Start Chatting",
"payload":"DEVELOPER_DEFINED_PAYLOAD"
}
]
}
]
}
},
"quick_replies":[
{
"content_type":"text",
"title":"Search",
"payload":"<POSTBACK_PAYLOAD>",
"image_url":"http://example.com/img/red.png"
},
{
"content_type":"location"
}
]
}
}
关于bots - Facebook 信使平台 : generic template with quick replies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44820020/