如何在Google Assistant中从Dialogflow Webhook显示表格卡片 [英] How to display a Table Card from Dialogflow Webhook in Google Assistant
问题描述
我已经设置了ASP.NET MVC 4 Web API来处理对话框流程的实现。我的目标是与Google Assistant集成并显示一张表格卡片作为回应。我正在通过Google Actions Console模拟器进行测试。
我已在 GoogleCloudDialogflowV2IntentMessage
中添加了表格卡片详细信息有效载荷
字段,根据我在这里找到的内容:
我的API Webhook的实现响应最终看起来像这样:
{
followupEventInput: {
languageCode:null,
name:null,
parameters:null,
ETag:null
},
fulfillmentMessages:[
{
basicCard:空,
card:空,
carouselSelect:空,
image:空,
linkOutSuggestion:空,
listSelect:空,
有效载荷:{
google:{
expectUserResponse:false,
richResponse:{
items:[
{
simpleResponse:{
textToSpeech:简单响应测试,
ssml:简单响应测试SSML,
displayText:简单响应测试显示
}
},
{
tableCard:{
title:标题,
subtitle:字幕,
image:{
url: https://www.google。 org / static / logo_googledotorg.svg,
accessibilityText:图片可访问性文本测试
},
columnProperties:[
{
header : BanksID,
horizontalAlignment:领先
},
{
标头:名称,
水平对齐:领先
}
],
行:[
{
cells: [
{
text: 3
},
{
text: Bank 1 TEST
}
],
dividerAfter:假
}
],
按钮:[
{
title: Weblink Title,
openUrlAction:{
url: https://www.google.org,
urlTypeHint: URL_TYPE_HINT_UNSPECIFIED
}
}
]
}
}
]
}
}
},
platform:null,
quickReplies:null,
simpleResponses:{
simpleResponses:[
{
displayText:简单响应显示测试,
ssml:简单响应测试SSML,
textToSpeech:简单响应测试,
ETag:空
}
],
ETag:空
},
建议:空,
文本:null,
ETag:null
}
],
fulfillmentText:测试成功。,
outputContexts :[[
{
lifespanCount:5,5,
name: banks,
parameters:{
TForView: rra,
DBVerb: rra,
TForView.original:,
DBVerb.original:
},
ETag :null
}
],
有效负载:null,
源:null,
ETag:空
}
问题是我没有看到桌牌在模拟器中。我的JSON响应格式可能不正确,因此Google助手无法正确解释它,但我不知道如何更改它。我不知道正确的格式是什么。也许我还想念其他东西。
如何通过Webhook响应在Google Assistant中显示表格卡片?
任何帮助/其他想法都得到赞赏。
通过查看Dialogflow控制台>诊断信息>履行状态。 / p>
我发现在 GoogleCloudDialogflowV2IntentMessage
中,我同时设置了 SimpleResponses
字段和 Payload
字段;而Google Assistant并非如此。因此,我已经将 SimpleResponses
字段设置为 null
,然后在Google Actions Simulator上获得了所需的显示响应。 / p>
简单响应
已添加到有效载荷
字段中, Google Assistant并没有遇到麻烦,只需设置有效负载
和 SimpleResponses
即可。
I've setup a ASP.NET MVC 4 Web API to handle dialogflow fulfillment. My goal is to integrate with Google Assistant and display a Table Card as a response. I'm testing through the Google Actions Console Simulator.
I've added the Table Card details in the GoogleCloudDialogflowV2IntentMessage
Payload
field, based on what I've found out here:
How to add Table Card in Dialogflow Fulfillment?
The Fulfillment Response from my API Webhook ends up looking something like this:
{
"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
}
Problem is I'm not seeing the Table Card in the simulator. The format of my JSON response is probably not correct, so Google Assistant can't interpret it correctly, but I don't know how to change it. I don't know what the correct format is. Or perhaps I'm missing something else.
How can I display a Table Card in Google Assistant from a Webhook Response?
Any help / other ideas appreciated.
By looking at the Dialogflow Console > DIAGNOSTIC INFO > FULFILLMENT STATUS.
I found out that in the GoogleCloudDialogflowV2IntentMessage
I'm setting both the SimpleResponses
field and the Payload
field; and Google Assistant didn't quite like that. So I've set the SimpleResponses
field to null
and then got the desired display response on the Google Actions Simulator.
The SimpleResponses
is already added into the Payload
field and Google Assistant didn't have trouble with that, just the fact that both Payload
and SimpleResponses
were set.
这篇关于如何在Google Assistant中从Dialogflow Webhook显示表格卡片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!