Google Assistant Dialogflow API V2 webhook ETag error

别等时光非礼了梦想. 提交于 2019-12-02 10:54:18

问题


I'm trying to return simple text response and display a basic card within Google Assistant app using the following code:

public GoogleCloudDialogflowV2WebhookResponse Search(GoogleCloudDialogflowV2WebhookRequest request)
    {
        GoogleCloudDialogflowV2WebhookResponse whr = new GoogleCloudDialogflowV2WebhookResponse();

        whr.FulfillmentMessages = new List<GoogleCloudDialogflowV2IntentMessage>();

        whr.FulfillmentMessages.Add(new GoogleCloudDialogflowV2IntentMessage()
        {                
            Platform = "ACTIONS_ON_GOOGLE",
            SimpleResponses = new GoogleCloudDialogflowV2IntentMessageSimpleResponses()
            {
               SimpleResponses = new List<GoogleCloudDialogflowV2IntentMessageSimpleResponse>()
               {
                   new GoogleCloudDialogflowV2IntentMessageSimpleResponse()
                   {
                       DisplayText = "sample text",
                       Ssml = "<speak>sample text</speak>"
                   }
               }
            },
            BasicCard = new GoogleCloudDialogflowV2IntentMessageBasicCard()
            {             
                Title = "sample title",
                Subtitle = "sample subtitle",
                FormattedText = "sample formatted text",
                Image = new GoogleCloudDialogflowV2IntentMessageImage()
                {                 
                    ImageUri = "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
                    AccessibilityText = "sample image"
                }
            }
        });

        return whr;
    }

I getting the following error when webhook endpoint is invoked from the Google Dialogflow interface:

webhookStatus": {
"code": 3,
"message": "Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: ETag in message google.cloud.dialogflow.v2beta1.Intent.Message.Image." }

I cannot find any information regarding ETag issue. I'm using standard Google.Apis.Dialogflow.v2 NuGet package and V2 API Dialogflow agent.

If I don't use GoogleCloudDialogflowV2WebhookResponse and use custom class, that when serialized to JSON works fine without basic card.

{ "fulfillmentText": "test from API", "fulfillmentMessages": [ { "platform": "ACTIONS_ON_GOOGLE", "simpleResponses": { "simpleResponses": [ { "displayText": "test", "ssml": "<speak>test</speak>"}],}}],}

I would prefer to use GoogleCloudDialogflowV2WebhookResponse.


回答1:


According to https://github.com/google/google-api-dotnet-client/issues/1234, use https://www.nuget.org/packages/Google.Cloud.Dialogflow.V2/1.0.0-beta01 instead of https://www.nuget.org/packages/Google.Apis.Dialogflow.v2/.

Realize that the Gooogle.Cloud package is still pre-release so you will have to specify version when installing or click the little "include prerelease" checkbox if you are using the NuGet Package Manager UI in Visual Studio.

I haven't tried it yet myself so your mileage may vary. I will update once I've tried it.

Update: The Google.Cloud library does work as expected.



来源:https://stackoverflow.com/questions/50242125/google-assistant-dialogflow-api-v2-webhook-etag-error

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