Class ChatMessage

ChatMessage

A Google Chat message.

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

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle("Card Title"))
    .addSection(CardService.newCardSection()
      .addWidget(CardService.newTextParagraph().setText("Text paragraph")))
    .build();

const cardWithId = CardService.newCardWithId().setCardId("card_one").setCard(card);

const message = AddOnsResponseService.newChatMessage().addCardWithId(cardWithId);

Methods

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

Detailed documentation

addAccessoryWidget(accessoryWidget)

Sets the accessoryWidget for this action.

Parameters

NameTypeDescription
accessoryWidgetAccessoryWidgetThe accessoryWidget to set.

Return

ChatMessage — This object, for chaining.


addCardWithId(cardWithId)

Sets the card of the message.

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle("Card Title"))
    .addSection(CardService.newCardSection()
      .addWidget(CardService.newTextParagraph().setText("Text paragraph")))
    .build();

const cardWithId = CardService.newCardWithId().setCardId("card_one").setCard(card);

const message = AddOnsResponseService.newChatMessage().addCardWithId(cardWithId);

Parameters

NameTypeDescription
cardWithIdCardWithIdThe cardWithId to set.

Return

ChatMessage — This object, for chaining.


setText(text)

Sets the text of the message.

const message = AddOnsResponseService.newChatMessage().setText("Example text");

Parameters

NameTypeDescription
textStringThe text part of a message.

Return

ChatMessage — This object, for chaining.