0

我想根据 webhook 响应和建议芯片来指导用户。从 webhook 示例中,我看到以下结构:

"fulfillment": {
  "speech": "Today in Boston: Fair, the temperature is 37 F",
  "source": "apiai-weather-webhook-sample",
  "displayText": "Today in Boston: Fair, the temperature is 37 F"
}

但是,如果我想建议用户下一步可以请求继续对话,那么我如何在 webhook 响应中传递建议芯片?

4

1 回答 1

4

您显示的响应是基本的 API.AI 响应格式。但是,Actions on Google 对此进行了扩展,主要使用 data.google 字段,如下所示:

{
  "speech":"This is a simple response with suggestion chips",
  "data": {
    "google":
    {
      "expectUserResponse":true,
      "richResponse":
      {
        "items":
        [
          {
            "simpleResponse":
            {
              "textToSpeech":"This is a simple response for with suggestion chips"
            }
          }
        ],
        "suggestions":
        [
          {
            "title":"Option 1"
          },
          {
            "title":"Option 2"
          }
        ]
      }
    }
  }
}

需要注意的是,这仅显示针对 Google 操作应用程序的建议,它不会对 Facebook 等内容执行任何操作。

于 2017-06-06T06:52:55.137 回答