dialogflow-es - Dialogflow 从 webhook 更改表面
问题描述
我正在尝试从我的 webhook 发送响应以触发更改到另一个表面的过程,但 Google 上的 Actions 总是抛出:
必须设置 MalformedResponse 'final_response'。
而且它不是很有帮助。
这是我返回的 JSON:
{
"payload": {
"google": {
"expectUserResponse": true,
"conversationToken": "{\"data\":{}}",
"userStorage": "{\"data\":{}}",
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER"
}
}
]
}
},
"possibleIntents": [
{
"intent": "actions.intent.NEW_SURFACE",
"inputValueData": {
"@type": "type.googleapis.com/google.actions.v2.NewSurfaceValueSpec",
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
}
],
"context": "Sure, I have some sample images for you.",
"notificationTitle": "Sample Images"
}
}
]
}
]
}
}
}
在 Dialogflow 上,我设置了 2 个意图;一个返回此处指定的 json 的意图,以及带有事件 actions_intent_NEW_SURFACE 的另一个意图,所以我知道用户对更改表面的问题的反应。
我一直在阅读这些网站:
https://developers.google.com/actions/assistant/surface-capabilities#multi-surface_conversations
https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/WebhookResponse
https://developers.google.com/actions/build/json/dialogflow-webhook-json#dialogflow-response-body
在 Google 上的操作,带有 actions.intent.NEW_SURFACE 的 webhook 响应(这似乎与我有同样的问题,但 OP 没有写响应。)
但他们都没有让我对这件事有所了解。
解决方案
您似乎正在尝试发送完整的 Action SDK 正文作为 Dialogflow 响应的一部分。虽然payload.google
JSON 部分包含类似于Action SDK 响应的对象,但存在一些差异。您可以查看https://developers.google.com/actions/build/json/dialogflow-webhook-json#dialogflow-response-body了解使用帮助程序时响应应该是什么的完整示例,但我认为您的响应需要像
{
"payload": {
"google": {
"expectUserResponse": true,
"userStorage": "{\"data\":{}}",
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.NEW_SURFACE",
"inputValueData": {
"@type": "type.googleapis.com/google.actions.v2.NewSurfaceValueSpec",
"capabilities": [
"actions.capability.SCREEN_OUTPUT"
],
"context": "Sure, I have some sample images for you.",
"notificationTitle": "Sample Images"
}
}
}
}
}
推荐阅读
- javascript - 角度:无错误但未在材料表中显示数据
- angular - 查询字符串格式传递用户名和密码
- javascript - jQuery .toggleClass() 在打开类后不会关闭类
- azure - 无法将 Azure-DevOps 与 Azure 容器注册表连接
- php - 在查找数组数据上实现的 Foreach 只找到一个数据
- bash - 如何将管道阶段变量传递给makefile
- html - 如何通过 html/css 实现这样的元素
- kubernetes - Cluster-autoscaler 不会触发 Daemonset 部署的扩展
- r - R 检查数据框中是否存在元素并返回其索引
- php - 如何以月、年的格式显示已经保存在 sql 中的 html 月标记输入?