Class ChatActionResponse

  • ChatActionResponse is a class used by Google Chat apps to configure how their responses are posted.

  • This class is exclusively available for Google Chat apps and not for Google Workspace add-ons.

  • Key methods include setting a dialog action, the response type, an updated widget for autocomplete, or a URL for authentication or configuration.

  • Each method returns the ChatActionResponse object for method chaining.

ChatActionResponse

A class that represents the parameters that a Chat app can use to configure how its response is posted.

Only available for Google Chat apps. Not available for Google Workspace add-ons.

constcard=CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Card title'))
.build();
constdialog=CardService.newDialog().setBody(card);
constdialogAction=CardService.newDialogAction().setDialog(dialog);
constchatActionResponse=CardService.newChatActionResponse()
.setResponseType(CardService.Type.DIALOG)
.setDialogAction(dialogAction);

Methods

MethodReturn typeBrief description
setDialogAction(dialogAction) ChatActionResponse Sets the dialog action to an event related to a dialog.
setResponseType(responseType) ChatActionResponse The type of Chat app response.
setUpdatedWidget(updatedWidget) ChatActionResponse Sets the updated widget, used to provide autocomplete options for a widget.
setUrl(url) ChatActionResponse The URL for users to authenticate or configure.

Detailed documentation

setDialogAction(dialogAction)

Sets the dialog action to an event related to a dialog.

constcard=CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Card title'))
.build();
constdialog=CardService.newDialog().setBody(card);
constdialogAction=CardService.newDialogAction().setDialog(dialog);
constchatActionResponse=CardService.newChatActionResponse()
.setResponseType(CardService.Type.DIALOG)
.setDialogAction(dialogAction);

Parameters

NameTypeDescription
dialogActionDialogAction The dialog action to set.

Return

ChatActionResponse — This object, for chaining.


setResponseType(responseType)

The type of Chat app response.

constchatActionResponse=CardService.newChatActionResponse().setResponseType(
CardService.Type.DIALOG,
);

Parameters

NameTypeDescription
responseTypeResponseType The response type.

Return

ChatActionResponse — This object, for chaining.


setUpdatedWidget(updatedWidget)

Sets the updated widget, used to provide autocomplete options for a widget.

constupdatedWidget=
CardService.newUpdatedWidget()
.addItem(
'Contact 1',
'contact-1',
false,
'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
'Contact one description',
)
.addItem(
'Contact 2',
'contact-2',
false,
'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
'Contact two description',
)
.addItem(
'Contact 3',
'contact-3',
false,
'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
'Contact three description',
)
.addItem(
'Contact 4',
'contact-4',
false,
'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
'Contact four description',
)
.addItem(
'Contact 5',
'contact-5',
false,
'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
'Contact five description',
);
constactionResponse=
CardService.newChatActionResponse()
.setUpdatedWidget(updatedWidget)
.setResponseType(CardService.ResponseType.UPDATE_WIDGET);
Only available for Google Chat apps. Not available for Google Workspace add-ons.

Parameters

NameTypeDescription
updatedWidgetUpdatedWidget The updated widget to be set.

Return

ChatActionResponse — This object, for chaining.


setUrl(url)

The URL for users to authenticate or configure. Only for the REQUEST_CONFIG response type.

constchatActionResponse=CardService.newChatActionResponse()
.setResponseType(CardService.Type.REQUEST_CONFIG)
.setUrl('https://www.google.com');

Parameters

NameTypeDescription
urlStringThe URL to send.

Return

ChatActionResponse — This object, for chaining.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年01月30日 UTC.