Compilateur pour les objets ChatResponse.
Disponible uniquement pour les applications Google Chat. Non disponible pour les modules complémentaires Google Workspace.
const cardSection = CardService.newCardSection(); cardSection.addWidget( CardService.newTextParagraph().setText('This is a text paragraph widget.'), ); const card = CardService.newCardBuilder() .setName('Card name') .setHeader(CardService.newCardHeader().setTitle('Card title')) .addSection(cardSection) .build(); const cardWithId = CardService.newCardWithId().setCardId('card_id').setCard(card); const chatResponse = CardService.newChatResponseBuilder() .addCardsV2(cardWithId) .setText('Example text') .build();
Méthodes
| Méthode | Type renvoyé | Brève description |
|---|---|---|
add | Chat | Définit le champ de carte du message. |
build() | Chat | Crée la réponse d'action actuelle et la valide. |
set | Chat | Définit le champ de réponse d'action du message. |
set | Chat | Définit le texte du message Chat. |
Documentation détaillée
addCardsV2(cardWithId)
Définit le champ de carte du message. Cette méthode permet d'envoyer une carte dans un message Google Chat. Chaque carte est associée à un ID unique. L'objet CardWithId doit être créé et utilisé avec cette méthode.
const cardSection = CardService.newCardSection(); cardSection.addWidget( CardService.newTextParagraph().setText('This is a text paragraph widget.'), ); const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .addSection(cardSection) .build(); const cardWithId = CardService.newCardWithId().setCardId('card_id').setCard(card); const chatResponse = CardService.newChatResponseBuilder().addCardsV2(cardWithId).build();
Paramètres
| Nom | Type | Description |
|---|---|---|
card | Card | Le Card à utiliser. |
Renvois
ChatResponseBuilder : cet objet, pour l'association en chaîne.
build()
setActionResponse(actionResponse)
Définit le champ de réponse d'action du message.
// Build the card. const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('card title')) .build(); // Creates the dialog. const dialog = CardService.newDialog().setBody(card); // Creates the dialog action. const dialogAction = CardService.newDialogAction().setDialog(dialog); // Creates the action response and sets the type to DIALOG. const actionResponse = CardService.newChatActionResponse() .setDialogAction(dialogAction) .setResponseType(CardService.Type.DIALOG); // Creates the Chat response and sets the action response. const chatResponse = CardService.newChatResponseBuilder() .setActionResponse(actionResponse) .build();
Paramètres
| Nom | Type | Description |
|---|---|---|
action | Chat | Le Chat à utiliser. |
Renvois
ChatResponseBuilder : cet objet, pour l'association en chaîne.
setText(text)
Définit le texte du message Chat.
const chatResponse = CardService.newChatResponseBuilder().setText('Example text').build();
Paramètres
| Nom | Type | Description |
|---|---|---|
text | String | Le texte à utiliser. |
Renvois
ChatResponseBuilder : cet objet, pour l'association en chaîne.