The ButtonList
widget displays a set of Button
s. Buttons can display text, an icon, or both text and an icon.
Each Button
supports an OnClick
action that occurs when users click the button. For example
- Open a hyperlink with
OpenLink
, such as a hyperlink to the Google Chat developer documentation,https://developers.google.com/chat
. - Run an action that runs a custom function, like calling an API.
You can prevent users from clicking a button by setting "disabled": "true"
.
For accessibility, buttons support alternative text.
Example 1: a button that opens a link and a button that runs a custom function
The following image displays a card consisting of a ButtonList
widget consisting of two Button
s. One button opens the Google Chat developer documentation in a new tab. The other button runs a custom function called goToView()
and passes one parameter: viewType="Bird Eye View"
.

ButtonList
widget displaying two Button
s.
Here's the card's JSON:
JSON
{
"cardsV2": [
{
"cardId": "exampleCard",
"card": {
"sections": [
{
"widgets": [
{
"buttonList": {
"buttons": [
{
"text": "Open a hyperlink",
"onClick": {
"openLink": {
"url": "https://developers.google.com/chat",
}
}
},
{
"text": "Run a custom function",
"onClick": {
"action": {
"function": "goToView",
"parameters": [
{
"key": "viewType",
"value": "BIRD EYE VIEW",
}
],
}
}
}
]
}
}
]
}
]
}
}
]
}
Example 2: a button with custom color and a deactivated button
The following image displays a card consisting of a ButtonList
widget consisting of two Button
s. One button uses the Color
field to customize the button's background color. The other button is deactivated with the Disabled
field, which prevents the user from clicking the button and executing the function.

ButtonList
widget displaying two Button
s.
Here's the card's JSON:
JSON
{
"cards_v2":[
{
"card_id":"exampleCard",
"card":{
"sections":[
{
"widgets":[
{
"buttonList":{
"buttons":[
{
"text":"View documentation hyperlink",
"onClick":{
"openLink":{
"url":"https://developers.google.com/chat"
}
},
"color":{
"red":0,
"green":0,
"blue":1,
"alpha":0.5
}
},
{
"text":"Button disabled",
"onClick":{
"openLink":{
"url":"https://developers.google.com/chat"
}
},
"disabled":true
}
]
}
}
]
}
]
}
}
]
}
Example 3: buttons that display icons
The following image displays a card consisting of a ButtonList
widget with two icon Button
s. One button uses the [knownIcon]((https://developers.google.com/chat/api/guides/message-formats/cards#builtinicons))
field to display Google Chat's built-in email icon. The other button uses the iconUrl
field to display a custom widget icon.

ButtonList
widget displaying two icon Button
s.
Here's the card's JSON:
JSON
{
"cards_v2": [
{
"card_id": "exampleCard",
"card": {
"sections": [
{
"widgets": [
{
"buttonList": {
"buttons": [
{
"icon": {"knownIcon": "EMAIL",},
"onClick": {
"action": {
"function": "sendEmail",
"parameters": [
{
"key": "emailContent",
"value": "Email value",
}
],
}
}
},
{
"icon": {"iconUrl": "https://developers.google.com/chat/images/quickstart-app-avatar.png",},
"onClick": {
"action": {
"function": "inviteBot",
"parameters": [
{
"key": "botType",
"value": "Bot value",
}
],
}
}
},
]
}
}
]
}
]
}
}
]
}
Example 4: Buttons with an icon and text
The following image displays a card consisting of a ButtonList
widget that prompts the user to send an email. The first button displays an email icon and the second button displays text. The user can click on either the icon or text button to execute the sendEmail
function.

ButtonList
widget displaying two Button
s.
Here's the card's JSON:
JSON
{
"cards_v2": [
{
"card_id": "exampleCard",
"card": {
"sections": [
{
"widgets": [
{
"buttonList": {
"buttons": [
{
"icon": {"knownIcon": "EMAIL",},
"onClick": {
"action": {
"function": "sendEmail",
"parameters": [
{
"key": "emailContent",
"value": "Email value",
}
],
}
}
},
{
"text": "Send email",
"onClick": {
"action": {
"function": "sendEmail",
"parameters": [
{
"key": "sendEmailType",
"value": "email value",
}
],
}
}
},
]
}
}
]
}
]
}
}
]
}
ButtonList
JSON representation and fields
JSON representation |
---|
{
"buttons": [
{
object (
|
Fields | |
---|---|
buttons[]
|
An array of buttons. |
Button
JSON representation and fields
JSON representation |
---|
{ "text": string, "icon": { object ( |
Fields | |
---|---|
text
|
The text displayed inside the button. |
icon
|
The icon image. If both
|
color
|
If set, the button is filled with a solid background color and the font color changes to maintain contrast with the background color. For example, setting a blue background will likely result in white text. If unset, the image background is white and the font color is blue.
For red, green and blue, the value of each field is a
Optionally set alpha, which sets a level of transparency using this equation:
For alpha, a value of 1 corresponds with a solid color, and a value of 0 corresponds with a completely transparent color. For example, the following color represents a half transparent red:
|
onClick
|
Required. The action to perform when the button is clicked, such as opening a hyperlink or running a custom function. |
disabled
|
If
|
altText
|
The alternative text used for accessibility. Set descriptive text that lets users know what the button does. For example, if a button opens a hyperlink, you might write: "Opens a new browser tab and navigates to the Google Chat developer documentation at https://developers.google.com/chat" . |
Icon
An icon displayed in a widget on a card.
JSON representation |
---|
{ "altText": string, "imageType": enum ( |
Fields | |
---|---|
altText
|
Optional. A description of the icon used for accessibility. If unspecified, the default value "Button" is provided. As a best practice, you should set a helpful description for what the icon displays, and if applicable, what it does. For example,
If the icon is set in a
|
imageType
|
The crop style applied to the image. In some cases, applying a
|
Union field
icons
. The icon displayed in the widget on the card.
icons
can be only one of the following:
|
|
knownIcon
|
Display one of the built-in icons provided by Google Workspace.
For example, to display an airplane icon, specify
For a full list of supported icons, see built-in icons . |
iconUrl
|
Display a custom icon hosted at an HTTPS URL. For example:
Supported file types include
|
ImageType
The shape used to crop the image.
Enums | |
---|---|
SQUARE
|
Default value. Applies a square mask to the image. For example, a 4x3 image becomes 3x3. |
CIRCLE
|
Applies a circular mask to the image. For example, a 4x3 image becomes a circle with a diameter of 3. |
Onclick
Represents how to respond when users click an interactive element on a card, such as a button.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field
|
|
action
|
If specified, an action is triggered by this
|
openLink
|
If specified, this
|
openDynamicLinkAction
|
An add-on triggers this action when the action needs to open a link. This differs from the
|
card
|
A new card is pushed to the card stack after clicking if specified. Supported by Google Workspace Add-ons, but not Chat apps. |
Action
An action that describes the behavior when the form is submitted. For example, an Apps Script can be invoked to handle the form. If the action is triggered, the form values are sent to the server.
JSON representation |
---|
{ "function": string, "parameters": [ { object ( |
Fields | |
---|---|
function
|
A custom function to invoke when the containing element is clicked or othrwise activated. For example usage, see Create interactive cards . |
parameters[]
|
List of action parameters. |
loadIndicator
|
Specifies the loading indicator that the action displays while making the call to the action. |
persistValues
|
Indicates whether form values persist after the action. The default value is
If
If
|
interaction
|
Optional. Required when opening a dialog . What to do in response to an interaction with a user, such as a user clicking button on a card message.
If unspecified, the app responds by executing an
By specifying an
When specified, a loading indicator is not shown. Supported by Chat apps, but not Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client. |
ActionParameter
List of string parameters to supply when the action method is invoked. For example, consider three snooze buttons: snooze now, snooze 1 day, snooze next week. You might use action method = snooze(), passing the snooze type and snooze time in the list of string parameters.
To learn more, see CommonEventObject .
JSON representation |
---|
{ "key": string, "value": string } |
Fields | |
---|---|
key
|
The name of the parameter for the action script. |
value
|
The value of the parameter. |
LoadIndicator
Specifies the loading indicator that the action displays while making the call to the action.
Enums | |
---|---|
SPINNER
|
Displays a spinner to indicate that content is loading. |
NONE
|
Nothing is displayed. |
Interaction
Optional. Required when opening a dialog .
What to do in response to an interaction with a user, such as a user clicking button on a card message.
If unspecified, the app responds by executing an
action
- like opening a link or running a function - as normal.
By specifying an
interaction
, the app can respond in special interactive ways. For example, by setting
interaction
to
OPEN_DIALOG
, the app can open a
dialog
.
When specified, a loading indicator is not shown.
Supported by Chat apps, but not Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client.
Enums | |
---|---|
INTERACTION_UNSPECIFIED
|
Default value. The
action
executes as normal.
|
OPEN_DIALOG
|
Opens a dialog , a windowed, card-based interface that Chat apps use to interact with users. Only supported by Chat apps in response to button-clicks on card messages. Not supported by Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client. |
OpenLink
Represents an
onClick
event that opens a hyperlink.
JSON representation |
---|
{ "url": string, "openAs": enum ( |
Fields | |
---|---|
url
|
The URL to open. |
openAs
|
How to open a link. Not supported by Chat apps. |
onClose
|
Whether the client forgets about a link after opening it, or observes it until the window closes. Not supported by Chat apps. |