Class ChatResponse
聊天回复
Google Chat 中卡片消息的响应对象。
仅适用于 Google Chat 应用。不适用于 Google Workspace 插件。
// Creates a card message in Chat.
const cardHeader = CardService.newCardHeader()
.setTitle('Card Header Title')
.setSubtitle('Card Header Subtitle');
const card = CardService.newCardBuilder().setHeader(cardHeader).build();
const chatResponse =
CardService.newChatResponseBuilder()
.setText('Example text')
.addCardsV2(
CardService.newCardWithId().setCardId('card_id').setCard(card))
.build();
console.log(chatResponse.printJson());
详细文档
printJson()
输出此对象的 JSON 表示法。这仅用于调试。
返回
String
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-30。
[null,null,["最后更新时间 (UTC):2025-01-30。"],[[["`ChatResponse` is an object used for card messages specifically within Google Chat apps, not add-ons."],["It facilitates building responses containing text and cards with customizable headers and content using methods like `addCardsV2()`."],["Developers can utilize the `printJson()` method to debug and view the JSON structure of the constructed response for verification."]]],["The `ChatResponse` object, exclusive to Google Chat apps, facilitates the creation of card messages. It is not for Google Workspace add-ons. You can build card messages using methods like `newCardHeader()` and `newCardBuilder()`. `newChatResponseBuilder()` builds the ChatResponse by adding text and cards. `printJson()` outputs the JSON representation of the constructed `ChatResponse` object, for debugging purposes.\n"]]