Webhook响应"建议芯片"

时间:2017-06-06 02:21:54

标签: webhooks actions-on-google api-ai

我想引导基于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响应中传递建议芯片?

1 个答案:

答案 0 :(得分:4)

您显示的响应是基本的API.AI响应格式。但是,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等内容做任何事情。