Class ChatResponse
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
ChatAntwort
Das Antwortobjekt für eine Kartennachricht in Google Chat.
Nur für Google Chat-Apps verfügbar. Nicht verfügbar für Google Workspace-Add-ons.
// 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());
Methoden
Methode | Rückgabetyp | Kurzbeschreibung |
printJson() | String | Die JSON-Darstellung dieses Objekts wird ausgegeben. |
Detaillierte Dokumentation
printJson()
Die JSON-Darstellung dieses Objekts wird ausgegeben. Diese Option ist nur für die Fehlerbehebung gedacht.
Rückflug
String
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-07-26 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eChatResponse\u003c/code\u003e is an object used for card messages specifically within Google Chat apps, not add-ons.\u003c/p\u003e\n"],["\u003cp\u003eIt facilitates building responses containing text and cards with customizable headers and content using methods like \u003ccode\u003eaddCardsV2()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the \u003ccode\u003eprintJson()\u003c/code\u003e method to debug and view the JSON structure of the constructed response for verification.\u003c/p\u003e\n"]]],["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"],null,["# Class ChatResponse\n\nChatResponse\n\nThe response object for a card message in Google Chat.\n\nOnly available for Google Chat apps. Not available for Google Workspace add-ons.\n\n```javascript\n// Creates a card message in Chat.\nconst cardHeader = CardService.newCardHeader()\n .setTitle('Card Header Title')\n .setSubtitle('Card Header Subtitle');\n\nconst card = CardService.newCardBuilder().setHeader(cardHeader).build();\n\nconst chatResponse =\n CardService.newChatResponseBuilder()\n .setText('Example text')\n .addCardsV2(\n CardService.newCardWithId().setCardId('card_id').setCard(card))\n .build();\n\nconsole.log(chatResponse.printJson());\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------|-------------|------------------------------------------------|\n| [printJson()](#printJson()) | `String` | Prints the JSON representation of this object. |\n\nDetailed documentation\n----------------------\n\n### `print``Json()`\n\nPrints the JSON representation of this object. This is for debugging only.\n\n#### Return\n\n\n`String`"]]