如何在Dialogflow的webhook响应中集成Google Actions响应? [英] How can I integrate the Google Actions responses in a webhook response in Dialogflow?

查看:124
本文介绍了如何在Dialogflow的webhook响应中集成Google Actions响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚如何嵌入Google Actions响应,例如卡旋转木马,在DialogFlow的Webhook响应中。

I am trying to figure out how I can embed Google Actions responses, such as the cards carousel, in a webhook response for DialogFlow.

https://developers.google.com/actions/dialogflow/webhook ,我发现了以下信息:

On https://developers.google.com/actions/dialogflow/webhook, I found the following information:

Dialogflow Webhook的响应格式包含标准Dialogflow Webhook响应内容和 data.google对象,该对象非常类似于标准对话Webhook响应,但具有以下一般区别。

The response format of the Dialogflow webhook contains the standard Dialogflow webhook response contents and a data.google object that closely resembles a standard conversation webhook response with the following general differences.

因此,我尝试使用 data.google 结构扩展webhook响应,如下所示:

So I tried extending the webhook response with a data.google structure as following:

{
   "fulfillmentText":"Please select any card you like.",
   "data":{
      "google":{
         ...
      }
   }
}

控制台,出现以下错误:

Webhook调用失败。错误:无法解析webhook JSON响应:找不到字段:消息google.cloud.dialogflow.v2beta1.WebhookResponse中的数据。

查找的定义 WebhookResponse ,看来确实没有 data 字段。

我正在转圈。我的问题基本上是:如何用Google Actions响应丰富Dialogflow webhook响应?

I am going around in circles. My question is basically: how can I enrich Dialogflow webhook responses with Google Actions responses?

推荐答案

Google上的Actions文档仍然参考到Dialogflow V1协议文档中,而Google的node.js库仅支持V1协议。既然听起来您正在尝试使用Dialogflow V2 Beta,则需要更改JSON格式。

The documentation for Actions on Google still refers to the Dialogflow V1 protocol documentation and the node.js library from Google only supports the V1 protocol. Since it sounds like you're trying to use Dialogflow V2 Beta, you need to change how you've formatted the JSON.

而不是使用 data.google 数据结构,如V1中一样,V2Beta使用 payload.google 字段(即 payload 对象中包含 google 对象)。 (请参阅响应下的 https://dialogflow.com/docs/fulfillment#requirements 部分,然后点击V2标签。)

Instead of using the data.google data structure, as in V1, V2Beta uses the payload.google field (that is, a payload object that has a google object in it). (See https://dialogflow.com/docs/fulfillment#requirements under the "Response" section and click on the V2 tab.)

payload.google 字段将被设置为相同的内容, data.google 字段的内容设置为。

The payload.google field would be set to the same thing the contents of the data.google field was set to.

这篇关于如何在Dialogflow的webhook响应中集成Google Actions响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆