ChatMessage

A Google Chat [message](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages).

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

```javascript
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

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#addAccessoryWidget(AccessoryWidget)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#` | Sets the accessoryWidget for this action. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#addCardWithId(CardWithId)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#` | Sets the card of the message. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#setText(String)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#` | Sets the text of the message. |

## Detailed documentation

### `addAccessoryWidget(accessoryWidget)`

Sets the accessoryWidget for this action.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `accessoryWidget` | `https://developers.google.com/apps-script/reference/add-ons-response-service/accessory-widget` | The accessoryWidget to set. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#` --- 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

| Name | Type | Description |
|---|---|---|
| `cardWithId` | `https://developers.google.com/apps-script/reference/card-service/card-with-id.html` | The cardWithId to set. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#` --- This object, for chaining.

*** ** * ** ***

### `setText(text)`

Sets the text of the message.

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

#### Parameters

| Name | Type | Description |
|---|---|---|
| `text` | `String` | The text part of a message. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/chat-message#` --- This object, for chaining.