Un generatore di oggetti Chat.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi di 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();
Metodi
| Metodo | Tipo restituito | Breve descrizione | 
|---|---|---|
| add | Chat | Imposta il campo della scheda del messaggio. | 
| build() | Chat | Genera la risposta all'azione corrente e la convalida. | 
| set | Chat | Imposta il campo di risposta all'azione del messaggio. | 
| set | Chat | Imposta il testo del messaggio di Chat. | 
Documentazione dettagliata
add
Imposta il campo della scheda del messaggio. Viene utilizzato per inviare una scheda in un messaggio di Google Chat. Ogni scheda è associata a un ID univoco, l'oggetto Card deve essere creato e utilizzato con questo metodo.
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();
Parametri
| Nome | Tipo | Descrizione | 
|---|---|---|
| card | Card | Il Cardda utilizzare. | 
Invio
Chat: questo oggetto, per l'accodamento.
build()
Genera la risposta all'azione corrente e la convalida.
Invio
Chat: una ChatResponse convalidata.
set
Imposta il campo di risposta all'azione del messaggio.
// 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();
Parametri
| Nome | Tipo | Descrizione | 
|---|---|---|
| action | Chat | Il Chatda utilizzare. | 
Invio
Chat: questo oggetto, per l'accodamento.
set
Imposta il testo del messaggio di Chat.
const chatResponse = CardService.newChatResponseBuilder().setText('Example text').build();
Parametri
| Nome | Tipo | Descrizione | 
|---|---|---|
| text | String | Il testo da utilizzare. | 
Invio
Chat: questo oggetto, per l'accodamento.