Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error on creating Chat card message from example

I'm trying to create a card to use in a Google Chat message.

I've pasted the JSON example from the Google Chat reference in the Card Builder , but on running it in the builder, I get an `Unknown field in Card JSON` error.

What could be the cause?

Solved Solved
0 15 1,565
1 ACCEPTED SOLUTION

if you put only code inside "card" it work.

Try this

{
"header": {
"title": "Sasha",
"subtitle": "Software Engineer",
"imageUrl":
"https://developers.google.com/chat/images/quickstart-app-avatar.png",
"imageType": "CIRCLE",
"imageAltText": "Avatar for Sasha",
},
"sections": [
{
"header": "Contact Info",
"collapsible": true,
"uncollapsibleWidgetsCount": 1,
"widgets": [
{
"decoratedText": {
"startIcon": {
"knownIcon": "EMAIL"
},
"text": "sasha@example.com"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "PERSON"
},
"text": "<font color=\"#80e27e\">Online</font>"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "PHONE"
},
"text": "+1 (555) 555-1234"
}
},
{
"buttonList": {
"buttons": [
{
"text": "Share",
"onClick": {
"openLink": {
"url": "https://example.com/share"
}
}
},
{
"text": "Edit",
"onClick": {
"action": {
"function": "goToView",
"parameters": [
{
"key": "viewType",
"value": "EDIT"
}
]
}
}
}
]
}
}
]
}
]
}

View solution in original post

15 REPLIES 15

can you please post the response you are sending to Google chat?

I started pasting the code example in Dialogflow console as a Custom Payload, but that gave me a lot of 'unexpected comma' errors. So I figured I'd try pasting it in Card Builder, but then I got the errors 'Unknown field' errors.

if you put only code inside "card" it work.

Try this

{
"header": {
"title": "Sasha",
"subtitle": "Software Engineer",
"imageUrl":
"https://developers.google.com/chat/images/quickstart-app-avatar.png",
"imageType": "CIRCLE",
"imageAltText": "Avatar for Sasha",
},
"sections": [
{
"header": "Contact Info",
"collapsible": true,
"uncollapsibleWidgetsCount": 1,
"widgets": [
{
"decoratedText": {
"startIcon": {
"knownIcon": "EMAIL"
},
"text": "sasha@example.com"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "PERSON"
},
"text": "<font color=\"#80e27e\">Online</font>"
}
},
{
"decoratedText": {
"startIcon": {
"knownIcon": "PHONE"
},
"text": "+1 (555) 555-1234"
}
},
{
"buttonList": {
"buttons": [
{
"text": "Share",
"onClick": {
"openLink": {
"url": "https://example.com/share"
}
}
},
{
"text": "Edit",
"onClick": {
"action": {
"function": "goToView",
"parameters": [
{
"key": "viewType",
"value": "EDIT"
}
]
}
}
}
]
}
}
]
}
]
}

Thanks @calle , no errors now.

Follow up question: for the Default Welcome intent I now have a text response, and use the code above for the Google Assistant integration (2nd tab under Responses) as a custom payload – see screenshot.

However, interacting through Google Chat still gets me the plain text version. How can I solve this?

Screenshot 2023-12-20 at 16.38.57.png

 

 

hi! I think you have to test this in a real chat

I am! But when interacting through Google Chat I get the default text version, not the channel specific one. 

That could be cause becaused the channel id is not correct

Xavi

I’m going to check that, thanks!

@xavidop & @calle thanks for jumping in to help out! @richardk1 keep us posted on if things work out for you.

Cheers,

Roderick 

It wasn't a channel ID problem in the end but a mistake in the configuration (I confused Google Assistant with Google Chat).

Still have problems with delivering the custom payload but I'll post that seperately to not make this more convoluted than it already is 🙂

sounds good!

Remember to close the threads with a solution too! just replied to the other thread

Already marked at as Solved. Do I need to do anything else?

all good then!
Thanks!

Hi, I have integrated the card with google chat to know the quality of the response given my bot, I want to know how to update the card once anyone has interacted with it.