DialogFlow Google Assistant Webhook 响应:"Empty speech response"

DialogFlow Google Assistant Webhook Response: "Empty speech response"

我在使用 Dialogflow 的 Fulfillment/Webhook 时遇到了一些问题。我创建了一个 Intent,它接受一个参数作为输入(引脚号)。使用 Webhook 调用在服务器端的 pin 是 "validated"。即勾选"Enable webhook call for this intent"。该方法 return 是成功验证的正面消息。

只要我使用 Dialogflow 控制台的 "Try it Now" window,整个场景就可以完美运行。但是当我尝试在 Google Assistant Simulator 中对其进行测试时,它会响应:

Screen from Actions on Google page > Response

此外,

Screen from Actions on Google page > Validation Errors

意图如下:

Intent screen from DialogFlow Agent page

我从 Webhook 调用设置为 return 的响应:

"messages": [
  {
    "speech": "Thanks. Your pin has been confirmed.",
    "type": 0
  }

在此处找到示例响应:https://dialogflow.com/docs/fulfillment

请注意,我已经检查过 。没用。

这是一个很好的问题,文档看起来对有效回答有点不清楚。

在回复 Google 助理的消息时,您应该使用 speechdisplayText 参数进行回复。所以等效的响应类似于

{
  "speech": "Thanks. Your pin has been confirmed.",
  "displayText": "Thank you. We have confirmed your PIN and you can proceed."
}

但是,如果您打算在 Google 功能(卡片、功能请求等)上使用 Actions 做额外的工作,或者甚至只是在与用户交谈时保持对话打开,那么您将还需要使用 data.google 对象,并且可能包括 simpleResponse 作为 reply 的一部分。这可能看起来像这样:

{
  "speech": "Thanks. Your pin has been confirmed.",
  "displayText": "Thank you. We have confirmed your PIN and you can proceed.",
  "data": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Thanks. Your pin has been confirmed.",
              "displayText": "Thank you. We have confirmed your PIN and you can proceed."
            }
          }
        ]
      }
    }
  }
}