Actions on google 如何在Dialogflow中创建包含丰富消息的响应?
当前,当调用一个intent时,我调用一个webhook并从web服务获得一个响应,如下面的json结构所示Actions on google 如何在Dialogflow中创建包含丰富消息的响应?,actions-on-google,dialogflow-es,api-ai,Actions On Google,Dialogflow Es,Api Ai,当前,当调用一个intent时,我调用一个webhook并从web服务获得一个响应,如下面的json结构所示 { "speech": "this text is spoken out loud if the platform supports voice interactions", "displayText": "this text is displayed visually" } 这仅仅是文本。或者,我必须得到什么样的响应才能显示列表(例如) 我尝试了dialogflow文档的富消
{
"speech": "this text is spoken out loud if the platform supports voice interactions",
"displayText": "this text is displayed visually"
}
这仅仅是文本。或者,我必须得到什么样的响应才能显示列表(例如)
我尝试了dialogflow文档的富消息部分。这些结构不起作用。要在谷歌列表中添加一个动作作为回复的一部分,您需要在回复中使用
数据字段,包括一个richsresponse
,以及一个包含列表信息的systemIntent
您可以在其网站上看到更多示例,但下面是一个用于显示列表的示例:
{
"data": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Choose an item"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"listSelect": {
"title": "Hello",
"items": [
{
"optionInfo": {
"key": "first title"
},
"description": "first description",
"image": {
"url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"accessibilityText": "first alt"
},
"title": "first title"
},
{
"optionInfo": {
"key": "second"
},
"description": "second description",
"image": {
"url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
"accessibilityText": "second alt"
},
"title": "second title"
}
]
}
}
}
}
}
}
每次DialogFlow匹配一个意图时,您都可以要求DialogFlow向特定端点发送请求。显然,您需要编写一个端点
这将允许您检索匹配的意图,以及匹配的参数和上下文,并对它们进行一些有用的工作
使用webhook的富消息示例
}
{
"fulfillmentMessages": [{
"payload": {
"message": "Object1",
"platform": "", // Example - Facebook, Slack...etc
{
"name": "Save Promo",
"action": {
"type": "quickReply",
"payload": {
"message": "text will be sent as message",
"replyMetadata": {
"key1": "value1"
}
}
}
},
{
"name": "Save Coupon",
"action": {
"type": "quickReply",
"payload": {
"message": "text will be sent as message",
"replyMetadata": {
"key1": "value1"
}
}
}
}
}, {
"payload": {
"message": "Object2",
"platform": "" // Example - Facebook, Slack...etc
}
}]