如何在 Google Assistant 中显示来自 Dialogflow Webhook 的表格卡片



我已经设置了一个 ASP.NET MVC 4 Web API来处理dialogflow的实现。我的目标是与 Google Assistant 集成并显示表格卡片作为响应。我正在通过谷歌行动控制台模拟器进行测试。

我根据我在这里发现的内容,在GoogleCloudDialogflowV2IntentMessagePayload字段中添加了表格卡片详细信息:

如何在对话流履行中添加表格卡?

来自我的 API Webhook 的履行响应最终看起来像这样:

{
"followupEventInput": {
"languageCode": null,
"name": null,
"parameters": null,
"ETag": null
},
"fulfillmentMessages": [
{
"basicCard": null,
"card": null,
"carouselSelect": null,
"image": null,
"linkOutSuggestion": null,
"listSelect": null,
"payload": {
"google": {
"expectUserResponse": false,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Simple Response TEST",
"ssml": "Simple Response TEST SSML",
"displayText": "Simple Response TEST DISPLAY"
}
},
{
"tableCard": {
"title": "Title",
"subtitle": "Subtitle",
"image": {
"url": "https://www.google.org/static/logo_googledotorg.svg",
"accessibilityText": "Image Accessibility Text TEST"
},
"columnProperties": [
{
"header": "BanksID",
"horizontalAlignment": "LEADING"
},
{
"header": "Name",
"horizontalAlignment": "LEADING"
}
],
"rows": [
{
"cells": [
{
"text": "3"
},
{
"text": "Bank 1 TEST"
}
],
"dividerAfter": false
}
],
"buttons": [
{
"title": "Weblink Title",
"openUrlAction": {
"url": "https://www.google.org",
"urlTypeHint": "URL_TYPE_HINT_UNSPECIFIED"
}
}
]
}
}
]
}
}
},
"platform": null,
"quickReplies": null,
"simpleResponses": {
"simpleResponses": [
{
"displayText": "Simple Response DISPLAY TEST",
"ssml": "Simple Response TEST SSML",
"textToSpeech": "Simple Response TEST",
"ETag": null
}
],
"ETag": null
},
"suggestions": null,
"text": null,
"ETag": null
}
],
"fulfillmentText": "TEST successful.",
"outputContexts": [
{
"lifespanCount": 5,
"name": "banks",
"parameters": {
"TForView": "rra",
"DBVerb": "rra",
"TForView.original": "",
"DBVerb.original": ""
},
"ETag": null
}
],
"payload": null,
"source": null,
"ETag": null
}

问题是我在模拟器中看不到表格卡。我的JSON响应格式可能不正确,所以谷歌助理无法正确解释它,但我不知道如何更改它。我不知道正确的格式是什么。或者也许我错过了别的东西。

如何在 Google 助理中通过 Webhook 响应显示表格卡片?

任何帮助/其他想法表示赞赏。

通过查看对话流控制台>诊断信息>履行状态。

我发现在GoogleCloudDialogflowV2IntentMessage中,我同时设置了SimpleResponses字段和Payload字段;而Google Assistant不太喜欢这样。因此,我将SimpleResponses字段设置为null,然后在 Google 操作模拟器上获得所需的显示响应。

SimpleResponses已经添加到Payload字段中,Google Assistant对此没有问题,只是设置了PayloadSimpleResponses

最新更新