一条 Google Chat 消息。
适用于扩展 Google Chat 的 Google Workspace 加载项。
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);
方法
| 方法 | 返回类型 | 简介 |
|---|---|---|
add | Chat | 设置消息的卡片。 |
set | Chat | 设置消息的文本。 |
详细文档
add Card With Id(cardWithId)
设置消息的卡片。
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);
参数
| 名称 | 类型 | 说明 |
|---|---|---|
card | Card | 要设置的 cardWithId。 |
返回
Chat - 此对象,用于链式调用。
set Text(text)
设置消息的文本。
const message = AddOnsResponseService.newChatMessage().setText("Example text");
参数
| 名称 | 类型 | 说明 |
|---|---|---|
text | String | 消息的文本部分。 |
返回
Chat - 此对象,用于链式调用。