错误 "Empty speech response"

Error "Empty speech response"

我尝试在 Google 上连接 DialogFlowActions,所以我创建了一些意图,连接了服务,添加了显式和隐式调用等,但是当我在模拟器 https://console.actions.google.com/project/[projectId]/simulator/ 中尝试机器人时,它总是给我错误:

"Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response"

即使输入类型是 "KEYBOARD"。

到目前为止我尝试了什么:

不幸的是,文档没有说明这个错误。有什么想法吗?

这里是 Actions 集成错误的屏幕截图:

这是完整的调试输出:

{
  "agentToAssistantDebug": {
    "agentToAssistantJson": {
      "message": "Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response",
      "apiResponse": {
        "id": "c12e1389-e887-49d4-b399-a332188ca946",
        "timestamp": "2018-01-27T03:55:30.931Z",
        "lang": "en-us",
        "result": {},
        "status": {
          "code": 200,
          "errorType": "success"
        },
        "sessionId": "1517025330705"
      }
    }
  },
  "assistantToAgentDebug": {
    "assistantToAgentJson": {
      "user": {
        "userId": "USER_ID",
        "locale": "en-US",
        "lastSeen": "2018-01-27T03:55:03Z"
      },
      "conversation": {
        "conversationId": "1517025330705",
        "type": "NEW"
      },
      "inputs": [
        {
          "intent": "actions.intent.MAIN",
          "rawInputs": [
            {
              "inputType": "KEYBOARD",
              "query": "Talk to Mica, the Hipster Cat Bot"
            }
          ]
        }
      ],
      "surface": {
        "capabilities": [
          {
            "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
          },
          {
            "name": "actions.capability.WEB_BROWSER"
          },
          {
            "name": "actions.capability.AUDIO_OUTPUT"
          },
          {
            "name": "actions.capability.SCREEN_OUTPUT"
          }
        ]
      },
      "isInSandbox": true,
      "availableSurfaces": [
        {
          "capabilities": [
            {
              "name": "actions.capability.AUDIO_OUTPUT"
            },
            {
              "name": "actions.capability.SCREEN_OUTPUT"
            }
          ]
        }
      ]
    },
    "curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=TOKEN' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: AUTH_TOKEN'  -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"USER_ID\",\"locale\":\"en-US\",\"lastSeen\":\"2018-01-27T03:55:03Z\"},\"conversation\":{\"conversationId\":\"1517025330705\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to Mica, the Hipster Cat Bot\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}'"
  },
  "sharedDebugInfo": [
    {
      "name": "ResponseValidation",
      "subDebugEntry": [
        {
          "debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
          "name": "UnparseableJsonResponse"
        }
      ]
    }
  ]
}

另外 "debugInfo" 听起来像是一个内部问题:

"API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\"."

这是欢迎意图的屏幕截图:

ps。 我花了很长时间才弄清楚,

"Query pattern is missing for custom intent"

意思是 - 所以我只是在这里记录它:在对话流 - 意图 - "User says" 中,当你想将它设置为查询参数时,你必须双击文本输入字段中的一个词 - 这似乎Google.

上的操作需要

Google 支持上的操作帮助我解决了这个问题:

我需要添加一个文本作为对用于显式调用的意图的默认响应。

这件事发生在我身上。如果您刚刚在 Dialogflow 控制台中添加的 Intent 发生这种情况,并且您正在使用 Webhook fulfillment 执行操作,请检查 Intent 的 fulfillment 设置并确保 Webhook fulfillment 滑块处于打开状态。显然,新的意图不会自动获得 webhook 实现:您必须逐个选择每个意图(或者至少,这是我的经验)。

我在尝试开发自己的 WebHook 时遇到了这个错误。我首先通过查看 Nginx 日志来验证我的代码是否被调用,之后我知道我的 JSON 输出中存在问题,因为我的输出基于过时的示例。

可在此处找到 API 的 V1 和 V2 的(最新)文档: https://dialogflow.com/docs/fulfillment/how-it-works

dialogflow webhook v2 的这个示例响应 API 帮助我解决了这个错误:

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "this is a simple response"
            }
          }
        ]
      }
    }
  }
}

来源:https://github.com/dialogflow/fulfillment-webhook-json/blob/master/responses/v2/ActionsOnGoogle/RichResponses/SimpleResponse.json

您可以在上面链接的官方 github 存储库中找到更多示例。

我在 运行 通过代码实验室教程 (https://codelabs.developers.google.com/codelabs/actions-1/index.html#4) 时得到了这个,并且没有将我的意图命名为与 webhook 脚本中引用的名称相同的名称:

另一种可能性是,如果您有如下文本回复(即使是空回复):

然后您需要单击响应旁边的垃圾桶将其清除以使用 webhook。

我也遇到过这种情况。 我的问题是我在实现 index.js 中使用了 SimpleResponse 而没有引用它。所以我的解决方案是在 index.js:

中添加这样的 SimpleResponse
const {dialogflow, SimpleResponse} = require('actions-on-google');

因此,请始终检查您是否没有使用任何依赖项,而无需将其包含在您的 js 文件中。 可能不是问题的最常见原因,但也可能是。