Es un compilador para objetos ChatResponse.
Solo está disponible para las apps de Google Chat. No está disponible para los complementos de 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étodos
| Método | Tipo de datos que se devuelve | Descripción breve |
|---|---|---|
add | Chat | Establece el campo de la tarjeta del mensaje. |
build() | Chat | Compila la respuesta de acción actual y la valida. |
set | Chat | Establece el campo de respuesta de la acción del mensaje. |
set | Chat | Establece el texto del mensaje de Chat. |
Documentación detallada
addCardsV2(cardWithId)
Establece el campo de la tarjeta del mensaje. Se usa para enviar una tarjeta en un mensaje de Google Chat. Cada tarjeta está asociada a un ID único, por lo que se debe compilar un objeto CardWithId y usarlo con este método.
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();
Parámetros
| Nombre | Tipo | Descripción |
|---|---|---|
card | Card | El Card que se debe usar. |
Volver
ChatResponseBuilder: Este objeto, para encadenar.
build()
Compila la respuesta de acción actual y la valida.
Volver
ChatResponse: Es un objeto ChatResponse validado.
setActionResponse(actionResponse)
Establece el campo de respuesta de la acción del mensaje.
// 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();
Parámetros
| Nombre | Tipo | Descripción |
|---|---|---|
action | Chat | El Chat que se debe usar. |
Volver
ChatResponseBuilder: Este objeto, para encadenar.
setText(text)
Establece el texto del mensaje de Chat.
const chatResponse = CardService.newChatResponseBuilder().setText('Example text').build();
Parámetros
| Nombre | Tipo | Descripción |
|---|---|---|
text | String | Es el texto que se usará. |
Volver
ChatResponseBuilder: Este objeto, para encadenar.