DialogFlow Google智能助理Webhook回复:“空话语回应”

问题描述 投票:2回答:1

我在使用Dialogflow的Fulfillment / Webhook时遇到了一些麻烦。我创建了一个Intent,它接受一个参数作为输入(引脚号)。使用Webhook调用在服务器端“验证”该引脚。也就是说,选中“为此意图启用webhook调用”。该方法在成功验证时返回正消息。

只要我使用Dialogflow控制台的“立即尝试”窗口,整个场景就能完美运行。但是当我尝试在Google智能助理模拟器中测试时,它会响应:

Screen from Actions on Google page > Response

也,

Screen from Actions on Google page > Validation Errors

这是意图:

Intent screen from DialogFlow Agent page

我已设置从Webhook调用返回的响应:

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

此处的示例回复:https://dialogflow.com/docs/fulfillment

请注意,我已经检查了Error "Empty speech response"。它没有帮助。

json model-view-controller actions-on-google dialogflow
1个回答
1
投票

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

在回复Google智能助理的消息时,您应该使用speechdisplayText参数进行响应。所以等效的反应会是这样的

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

但是,如果您要在Google功能(卡片,功能请求等)上执行其他操作,或者甚至只是在与用户交谈时保持对话打开,那么您还需要使用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."
            }
          }
        ]
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.