Class ChatMessage

ChatMessage

A Google Chat message.

Available for Google Workspace add-ons that extend Google Chat.

constcard=CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle("Card Title"))
.addSection(CardService.newCardSection()
.addWidget(CardService.newTextParagraph().setText("Text paragraph")))
.build();
constcardWithId=CardService.newCardWithId().setCardId("card_one").setCard(card);
constmessage=AddOnsResponseService.newChatMessage().addCardWithId(cardWithId);

Methods

MethodReturn typeBrief description
addAccessoryWidget(accessoryWidget) ChatMessage Sets the accessoryWidget for this action.
addCardWithId(cardWithId) ChatMessage Sets the card of the message.
setText(text) ChatMessage Sets the text of the message.

Detailed documentation

addAccessoryWidget(accessoryWidget)

Sets the accessoryWidget for this action.

Parameters

NameTypeDescription
accessoryWidgetAccessoryWidget The accessoryWidget to set.

Return

ChatMessage — This object, for chaining.


addCardWithId(cardWithId)

Sets the card of the message.

constcard=CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle("Card Title"))
.addSection(CardService.newCardSection()
.addWidget(CardService.newTextParagraph().setText("Text paragraph")))
.build();
constcardWithId=CardService.newCardWithId().setCardId("card_one").setCard(card);
constmessage=AddOnsResponseService.newChatMessage().addCardWithId(cardWithId);

Parameters

NameTypeDescription
cardWithIdCardWithId The cardWithId to set.

Return

ChatMessage — This object, for chaining.


setText(text)

Sets the text of the message.

constmessage=AddOnsResponseService.newChatMessage().setText("Example text");

Parameters

NameTypeDescription
textStringThe text part of a message.

Return

ChatMessage — 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 2026年04月13日 UTC.