Class ChatResponse

  • ChatResponse is the response object for a card message in Google Chat, available only for Google Chat apps.

  • You can create a ChatResponse using CardService.newChatResponseBuilder(), adding text and cards using setText() and addCardsV2().

  • The printJson() method is available for debugging and prints the JSON representation of the ChatResponse object.

ChatResponse

The response object for a card message in Google Chat.

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

// Creates a card message in Chat.
constcardHeader=CardService.newCardHeader()
.setTitle('Card Header Title')
.setSubtitle('Card Header Subtitle');
constcard=CardService.newCardBuilder().setHeader(cardHeader).build();
constchatResponse=
CardService.newChatResponseBuilder()
.setText('Example text')
.addCardsV2(
CardService.newCardWithId().setCardId('card_id').setCard(card))
.build();
console.log(chatResponse.printJson());

Methods

MethodReturn typeBrief description
printJson() StringPrints the JSON representation of this object.

Detailed documentation

printJson()

Prints the JSON representation of this object. This is for debugging only.

Return

String

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.