How can I integrate the Google Actions responses in a webhook response in Dialogflow?

你。 提交于 2019-12-02 08:43:22

问题


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

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

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.

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

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

When testing in the console, I get the following error:

Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: data in message google.cloud.dialogflow.v2beta1.WebhookResponse.

Looking to the definition of WebhookResponse, it looks like there is indeed no data field.

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


回答1:


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.

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.)

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



来源:https://stackoverflow.com/questions/49067142/how-can-i-integrate-the-google-actions-responses-in-a-webhook-response-in-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!