目前,当调用意图时,我正在调用一个 webhook 并从 Web 服务获得响应,如下所示的 json 结构。
{
"speech": "this text is spoken out loud if the platform supports voice interactions",
"displayText": "this text is displayed visually"
}
这只是文本。或者,例如,我必须得到什么响应才能显示列表。
我尝试了对话流文档的富消息部分。这些结构不起作用。
匹配一个意图时,您都可以要求 DialogFlow 将请求发送到特定端点。显然必须编写代码的终结点。
这将允许您检索匹配的意图以及匹配的参数和上下文,并对这些进行一些有用的工作。
如何在对话流中使用消息对象
Kommunicate - 自定义 Webhook 对话流集成示例
使用 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
}
}]
}
要在回复中添加"Google 列表中的操作",您需要在回复中使用"data
"字段,以包含应说的内容richResponse
,以及包含列表信息的systemIntent
。
您可以在他们的 github 示例存储库中看到更多示例,但这里是显示列表的示例:
{
"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"
}
]
}
}
}
}
}
}