List_card 在 AoG 中将项目标题而不是键传递给下一个查询
List_card in AoG passing item title to the next query instead of key
在一个应用程序中,我返回类型为 list_card
的消息,其中带有用于 intent 的选项键。
这是示例查询的 json:
{
"id": "275212ef-cf97-4576-afa7-facfbc044ada",
"timestamp": "2017-07-17T17:36:03.655Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "who is Sneha",
"action": "cp.name_search",
"actionIncomplete": false,
"parameters": {
"keyword": "Sneha"
},
"contexts": [
{
"name": "cpname_search-followup",
"parameters": {
"keyword.original": "Sneha",
"keyword": "Sneha"
},
"lifespan": 2
},
{
"name": "cpuid_search-followup",
"parameters": {
"keyword.original": "Sneha",
"keyword": "Sneha"
},
"lifespan": 1
}
],
"metadata": {
"intentId": "86bd1a17-8e9a-4956-b270-5fb4ac952f5f",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"webhookResponseTime": 135,
"intentName": "cp.name_search"
},
"fulfillment": {
"speech": "Searching...",
"source": "agent",
"messages": [
{
"type": "simple_response",
"platform": "google",
"textToSpeech": "Here are the search results. \nWant anything else?"
},
{
"type": "list_card",
"platform": "google",
"title": "Search results",
"items": [
{
"optionInfo": {
"key": "uid 72",
"synonyms": []
},
"title": "Sneha Vasista",
"description": "Srinivas Institute of Technology",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2053",
"synonyms": []
},
"title": "Sneha Bhat",
"description": "Canara Engineering College",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2114",
"synonyms": []
},
"title": "Sneha Sajan",
"description": "P.A College of Engineering",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2320",
"synonyms": []
},
"title": "Sneha ",
"description": "sdit",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2363",
"synonyms": []
},
"title": "Sneha ",
"description": "Srinivas School of Engineering, Mukka",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
}
]
},
{
"type": "0",
"speech": "Here are the search results."
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "e6aa9e52-a9e1-481a-adb5-476c5b386e02"
}
现在的问题是,当我在 AoG 模拟器中点击列表项时,它将 title
项传递给下一个查询。
但是在 Api.ai 模拟器 中进行测试时,它表现良好并将 key
传递给下一个查询。
这里可能是什么问题?
有什么提示吗?
您需要做的是直接在当前意图下设置回退意图。
例如,如果您显示来自默认欢迎意图的列表,您可以执行以下操作。
单击 "Add follow-up intent" 并选择回退。
不要忘记在回退意图中设置操作并启用 webhook。
现在,您应该能够使用以下代码从回退意图中检索答案。
const param = app.getContextArgument('actions_intent_option','OPTION').value;
如果您正在使用 API.AI,那么它将作为 actions_intent_OPTION
事件出现在 Intent 中。
一个好的解决方案是让 Intent 发送带有 OutputContext 的列表。然后创建一个特定的后备意图,其中 actions_intent_OPTION
作为事件,你想要的 action
作为该上下文,它应该处理语音和新闻响应。
你会在 ["originalRequest"]["data"]["inputs"][0]["arguments"][0]["textValue"]
处找到你的 option_key
而不是参数。
您还可以在 actions_intent_option
上下文中查看响应值。
在一个应用程序中,我返回类型为 list_card
的消息,其中带有用于 intent 的选项键。
这是示例查询的 json:
{
"id": "275212ef-cf97-4576-afa7-facfbc044ada",
"timestamp": "2017-07-17T17:36:03.655Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "who is Sneha",
"action": "cp.name_search",
"actionIncomplete": false,
"parameters": {
"keyword": "Sneha"
},
"contexts": [
{
"name": "cpname_search-followup",
"parameters": {
"keyword.original": "Sneha",
"keyword": "Sneha"
},
"lifespan": 2
},
{
"name": "cpuid_search-followup",
"parameters": {
"keyword.original": "Sneha",
"keyword": "Sneha"
},
"lifespan": 1
}
],
"metadata": {
"intentId": "86bd1a17-8e9a-4956-b270-5fb4ac952f5f",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"webhookResponseTime": 135,
"intentName": "cp.name_search"
},
"fulfillment": {
"speech": "Searching...",
"source": "agent",
"messages": [
{
"type": "simple_response",
"platform": "google",
"textToSpeech": "Here are the search results. \nWant anything else?"
},
{
"type": "list_card",
"platform": "google",
"title": "Search results",
"items": [
{
"optionInfo": {
"key": "uid 72",
"synonyms": []
},
"title": "Sneha Vasista",
"description": "Srinivas Institute of Technology",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2053",
"synonyms": []
},
"title": "Sneha Bhat",
"description": "Canara Engineering College",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2114",
"synonyms": []
},
"title": "Sneha Sajan",
"description": "P.A College of Engineering",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2320",
"synonyms": []
},
"title": "Sneha ",
"description": "sdit",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
},
{
"optionInfo": {
"key": "uid 2363",
"synonyms": []
},
"title": "Sneha ",
"description": "Srinivas School of Engineering, Mukka",
"image": {
"url": "//www.curlpad.com/assets/img/custom_images/user.png"
}
}
]
},
{
"type": "0",
"speech": "Here are the search results."
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "e6aa9e52-a9e1-481a-adb5-476c5b386e02"
}
现在的问题是,当我在 AoG 模拟器中点击列表项时,它将 title
项传递给下一个查询。
但是在 Api.ai 模拟器 中进行测试时,它表现良好并将 key
传递给下一个查询。
这里可能是什么问题?
有什么提示吗?
您需要做的是直接在当前意图下设置回退意图。
例如,如果您显示来自默认欢迎意图的列表,您可以执行以下操作。
单击 "Add follow-up intent" 并选择回退。
不要忘记在回退意图中设置操作并启用 webhook。
现在,您应该能够使用以下代码从回退意图中检索答案。
const param = app.getContextArgument('actions_intent_option','OPTION').value;
如果您正在使用 API.AI,那么它将作为 actions_intent_OPTION
事件出现在 Intent 中。
一个好的解决方案是让 Intent 发送带有 OutputContext 的列表。然后创建一个特定的后备意图,其中 actions_intent_OPTION
作为事件,你想要的 action
作为该上下文,它应该处理语音和新闻响应。
你会在 ["originalRequest"]["data"]["inputs"][0]["arguments"][0]["textValue"]
处找到你的 option_key
而不是参数。
您还可以在 actions_intent_option
上下文中查看响应值。