Google Assistant Dialogflow API V2 Webhook ETag错误 [英] Google Assistant Dialogflow API V2 webhook ETag error
问题描述
我正在尝试使用以下代码返回简单的文本回复并在Google Assistant应用中显示基本卡:
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;
}
从Google Dialogflow界面调用webhook端点时出现以下错误:
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." }
我找不到有关ETag问题的任何信息.我正在使用标准的Google.Apis.Dialogflow.v2 NuGet软件包和V2 API Dialogflow代理.
I cannot find any information regarding ETag issue. I'm using standard Google.Apis.Dialogflow.v2 NuGet package and V2 API Dialogflow agent.
如果我不使用GoogleCloudDialogflowV2WebhookResponse并使用自定义类,则在序列化为JSON时无需基本卡就可以正常工作.
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>"}],}}],}
我希望使用GoogleCloudDialogflowV2WebhookResponse.
I would prefer to use GoogleCloudDialogflowV2WebhookResponse.
推荐答案
根据 https://www.nuget.org/packages/Google.Cloud.Dialogflow.V2/1.0.0-beta01 而不是 https://www.nuget.org/packages/Google.Apis.Dialogflow. v2/.
意识到Gooogle.Cloud软件包仍是预发行版本,因此如果您在Visual Studio中使用NuGet软件包管理器UI,则必须在安装时指定版本,或单击小的包括预发行版本"复选框.
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.
更新:Google.Cloud库确实可以正常工作.
Update: The Google.Cloud library does work as expected.
这篇关于Google Assistant Dialogflow API V2 Webhook ETag错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!