我已经设置了ASP.NET MVC 4 Web API来处理dialogflow实现。我的目标是与Google Assistant集成并显示一张表格卡片作为回应。我正在通过Google Actions Console模拟器进行测试。
根据我在这里发现的信息,我已经在GoogleCloudDialogflowV2IntentMessage
Payload
字段中添加了表格卡片的详细信息:
How to add Table Card in Dialogflow Fulfillment?
我的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响应在Google Assistant中显示表格卡片?
任何帮助/其他想法都表示赞赏。
答案 0 :(得分:0)
通过查看Dialogflow控制台>诊断信息>履行状态。
我发现在GoogleCloudDialogflowV2IntentMessage
中同时设置了SimpleResponses
字段和Payload
字段;和Google助手不太一样。因此,我将SimpleResponses
字段设置为null
,然后在Google Actions Simulator上获得了所需的显示响应。
SimpleResponses
已添加到Payload
字段中,而Google Assistant并没有遇到任何麻烦,只需设置Payload
和SimpleResponses
即可。