Card
Di seguito è riportato un esempio di carta per i componenti aggiuntivi.
function createCard() { return CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('CardTitle')) .build(); }
In alternativa, puoi restituire più carte in questo modo:
function createCards() { return [ CardService.newCardBuilder().build(), CardService.newCardBuilder().build(), CardService.newCardBuilder().build(), ]; }
Di seguito viene mostrato come definire una scheda con un'intestazione, un testo, un'immagine e una voce di menu:
function createWidgetDemoCard() { return CardService.newCardBuilder() .setHeader( CardService.newCardHeader() .setTitle('Widget demonstration') .setSubtitle('Check out these widgets') .setImageStyle(CardService.ImageStyle.SQUARE) .setImageUrl('https://www.example.com/images/headerImage.png'), ) .addSection( CardService.newCardSection() .setHeader('Simple widgets') // optional .addWidget( CardService.newTextParagraph().setText( 'These widgets are display-only. ' + 'A text paragraph can have multiple lines and ' + 'formatting.', ), ) .addWidget( CardService.newImage().setImageUrl( 'https://www.example.com/images/mapsImage.png', ), ), ) .addCardAction( CardService.newCardAction().setText('Gmail').setOpenLink( CardService.newOpenLink().setUrl('https://mail.google.com/mail'), ), ) .build(); }
Esempio di scheda delle app di chat.
const cardHeader = CardService.newCardHeader() .setTitle('Sasha') .setSubtitle('Software Engineer') .setImageUrl( 'https://developers.google.com/chat/images/quickstart-app-avatar.png', ) .setImageStyle(CardService.ImageStyle.CIRCLE) .setImageAltText('Avatar for Sasha'); const cardSection = CardService.newCardSection() .setHeader('Contact Info') .setCollapsible(true) .setNumUncollapsibleWidgets(1) .addWidget( CardService.newDecoratedText() .setStartIcon( CardService.newIconImage().setIcon(CardService.Icon.EMAIL)) .setText('sasha@example.com'), ) .addWidget( CardService.newDecoratedText() .setStartIcon( CardService.newIconImage().setIcon(CardService.Icon.PERSON)) .setText('<font color="#80e27e">Online</font>'), ) .addWidget( CardService.newDecoratedText() .setStartIcon( CardService.newIconImage().setIcon(CardService.Icon.PHONE)) .setText('+1 (555) 555-1234'), ) .addWidget( CardService.newButtonSet() .addButton( CardService.newTextButton().setText('Share').setOpenLink( CardService.newOpenLink().setUrl( 'https://example.com/share'), ), ) .addButton( CardService.newTextButton() .setText('Edit') .setOnClickAction( CardService.newAction() .setFunctionName('goToView') .setParameters({viewType: 'EDIT'}), ), ), ); const card = CardService.newCardBuilder() .setHeader(cardHeader) .addSection(cardSection) .build();
Proprietà
| Proprietà | Tipo | Descrizione | 
|---|---|---|
| Border | Border | L'enumerazione Border. | 
| Chip | Chip | L'enumerazione Chip. | 
| Composed | Composed | L'enumerazione Composed. | 
| Content | Content | L'enumerazione Content. | 
| Expression | Expression | L'enumerazione Expression. | 
| Expression | Expression | L'enumerazione Expression. | 
| Grid | Grid | L'enumerazione Grid. | 
| Horizontal | Horizontal | L'enumerazione Horizontal. | 
| Icon | Icon | L'enumerazione Icon. | 
| Image | Image | L'enumerazione Image. | 
| Image | Image | L'enumerazione Image. | 
| Image | Image | L'enumerazione Image. | 
| Input | Input | L'enumerazione Input. | 
| Load | Load | L'enumerazione Load. | 
| On | On | L'enumerazione On. | 
| Open | Open | L'enumerazione Open. | 
| Selection | Selection | L'enumerazione Selection. | 
| Text | Text | L'enumerazione Text. | 
| Update | Update | L'enumerazione Update. | 
| Visibility | Visibility | L'enumerazione Visibility. | 
| Workflow | Workflow | L'enumerazione Workflow. | 
Metodi
Documentazione dettagliata
new
Crea un nuovo Action.
Indietro
Action: un builder ActionResponse vuoto.
new
Crea un nuovo Action.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi Google Workspace.
const actionStatus = CardService.newActionStatus() .setStatusCode(CardService.Status.OK) .setUserFacingMessage('Success');
Indietro
Action: un ActionStatus vuoto.
new
new
new
Crea un nuovo Authorization.
Indietro
Authorization: un'AuthorizationException vuota.
new
new
Crea un nuovo Calendar.
Indietro
Calendar: un Calendar vuoto.
new
new
new
new
new
Crea un nuovo Card. Questo parametro viene utilizzato per inviare una scheda in un messaggio di Google Chat. L'ID scheda
è un identificatore univoco per una scheda in un messaggio quando vengono inviate più schede.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi Google Workspace.
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);
Indietro
Card: un Card vuoto.
new
Crea un Carousel.
const carousel = CardService.newCarousel() .addCarouselCard(CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('The first text paragraph in carousel'))) .addCarouselCard(CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('The second text paragraph in carousel'))) .addCarouselCard(CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('The third text paragraph in carousel')))
Indietro
Carousel: un carosello vuoto.
new
Crea un nuovo Carousel.
const carouselCard = CardService.newCarouselCard().addWidget( CardService.newTextParagraph().setText('Text paragraph in carousel'));
Indietro
Carousel: un chip vuoto.
new
Crea un nuovo Chat.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi Google Workspace.
const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .build(); const dialog = CardService.newDialog().setBody(card); const dialogAction = CardService.newDialogAction().setDialog(dialog); const chatActionResponse = CardService.newChatActionResponse() .setResponseType(CardService.ResponseType.DIALOG) .setDialogAction(dialogAction);
Indietro
Chat: un Chat vuoto.
new
Crea un nuovo Chat.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi Google Workspace.
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();
Indietro
Chat: un ChatResponseBuilder vuoto.
new
new
Crea un nuovo Chip.
Disponibile per le app Google Chat. Nell'anteprima per sviluppatori per i componenti aggiuntivi di Google Workspace.
const chip = CardService.newChip(); // Finish building the text chip... const chipList = CardService.newChipList() .setLayout(CardService.ChipListLayout.WRAPPED) .addChip(chip);
Indietro
Chip: un elenco di chip vuoto.
new
Crea un nuovo Collapse.
Disponibile per le app Google Chat. Nell'anteprima per sviluppatori per i componenti aggiuntivi di Google Workspace.
const collapseControl = CardService.newCollapseControl() .setHorizontalAlign(CardService.HorizontalAlignment.START) .setExpandButton(CardService.newTextButton().setText('Expand')) .setCollapseButton(CardService.newTextButton().setText('Collapse'));
Indietro
Collapse: un controllo CollapseControl vuoto.
new
Crea un nuovo Column.
Disponibile per le app Google Chat e i componenti aggiuntivi di Google Workspace.
const columnWidget = CardService.newTextParagraph(); const column = CardService.newColumn() .setHorizontalSizeStyle( CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE) .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER) .setVerticalAlignment(CardService.VerticalAlignment.CENTER) .addWidget(columnWidget);
Indietro
Column: una colonna vuota.
new
Crea un nuovo insieme di Columns.
Disponibile per le app Google Chat e i componenti aggiuntivi di Google Workspace.
const firstColumn = CardService.newColumn() .setHorizontalSizeStyle( CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE) .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER) .setVerticalAlignment(CardService.VerticalAlignment.CENTER); const secondColumn = CardService.newColumn() .setHorizontalSizeStyle( CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE) .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER) .setVerticalAlignment(CardService.VerticalAlignment.CENTER); const columns = CardService.newColumns() .addColumn(firstColumn) .addColumn(secondColumn) .setWrapStyle(CardService.WrapStyle.WRAP);
Indietro
Columns: un insieme vuoto di colonne.
new
Crea un nuovo Compose.
Indietro
Compose: un builder ComposeActionResponse vuoto.
new
new
new
new
Crea un nuovo Dialog.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi Google Workspace.
const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .build(); // Sets the card of the dialog. const dialog = CardService.newDialog().setBody(card);
Indietro
new
Crea un nuovo Dialog.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi Google Workspace.
const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card title')) .build(); const dialog = CardService.newDialog().setBody(card); const dialogAction = CardService.newDialogAction().setDialog(dialog);
Indietro
Dialog: un Dialog vuoto.
new
Crea un nuovo Divider. L'esempio seguente crea una semplice scheda con due paragrafi
separati da un divisore.
function buildCard() { const cardSection1TextParagraph1 = CardService.newTextParagraph().setText('Hello world!'); const cardSection1Divider1 = CardService.newDivider(); const cardSection1TextParagraph2 = CardService.newTextParagraph().setText('Hello world!'); const cardSection1 = CardService.newCardSection() .addWidget(cardSection1TextParagraph1) .addWidget(cardSection1Divider1) .addWidget(cardSection1TextParagraph2); const card = CardService.newCardBuilder().addSection(cardSection1).build(); return card; }
Indietro
Divider: un divisore.
new
Crea un nuovo Drive.
Indietro
Drive: un Drive vuoto.
new
Crea un nuovo Editor.
Indietro
Editor: un Editor vuoto.
new
Crea un nuovo Host e restituisce un Host vuoto.
Indietro
new
new
new
new
Crea un nuovo Link.
const decoratedText = CardService.newDecoratedText().setTopLabel('Hello').setText('Hi!'); const cardSection = CardService.newCardSection().addWidget(decoratedText); const card = CardService.newCardBuilder().addSection(cardSection).build(); const linkPreview = CardService.newLinkPreview().setPreviewCard(card).setTitle( 'Smart chip title');
Indietro
Link: un'anteprima link vuota.
new
Crea un nuovo Material.
Disponibile per le app Google Chat e i componenti aggiuntivi di Google Workspace.
const materialIcon = CardService.newMaterialIcon().setName('check_box').setFill(true); const cardSection = CardService.newCardSection(); cardSection.addWidget( CardService.newDecoratedText() .setStartIcon(CardService.newIconImage().setMaterialIcon(materialIcon)) .setText('sasha@example.com'), ); const card = CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle('Card Title')) .addSection(cardSection) .build();
Indietro
Material: un oggetto MaterialIcon vuoto.
new
new
Crea un nuovo Overflow.
Disponibile per le app Google Chat. Nell'anteprima per sviluppatori per i componenti aggiuntivi di Google Workspace.
const overflowMenuItem = CardService.newOverflowMenuItem(); // Finish building the overflow menu item... const overflowMenu = CardService.newOverflowMenu().addMenuItem(overflowMenuItem);
Indietro
Overflow: un OverflowMenu vuoto.
new
Crea un nuovo Overflow.
Disponibile per le app Google Chat. Nell'anteprima per sviluppatori per i componenti aggiuntivi di Google Workspace.
const overflowMenuItem = CardService.newOverflowMenuItem() .setStartIcon( CardService.newIconImage().setIconUrl( 'https://www.google.com/images/branding/googleg/1x/googleg_standard_color_64dp.png', ), ) .setText('Open Link') .setOpenLink( CardService.newOpenLink().setUrl('https://www.google.com'));
Indietro
Overflow: una voce di menu extra vuota.
new
new
new
Crea un nuovo Suggestions.
Indietro
Suggestions: uno strumento per la creazione di SuggestionsResponse vuoto.
new
new
new
new
Crea un nuovo Universal.
Indietro
Universal: un builder UniversalActionResponse vuoto.
new
Crea un nuovo Update.
Indietro
Update: un UpdateDraftActionResponseBuilder vuoto.
new
Crea un nuovo Update.
Indietro
Update: un'azione UpdateDraftBccRecipientsAction vuota.
new
Crea un nuovo Update.
Indietro
Update: un'azione UpdateDraftBodyAction vuota.
new
Crea un nuovo Update.
Indietro
Update: un'azione Empty UpdateDraftCcRecipientsAction.
new
Crea un nuovo Update.
Indietro
Update: un'azione UpdateDraftSubjectAction vuota.
new
Crea un nuovo Update.
Indietro
Update: un'azione UpdateDraftToRecipientsAction vuota.
new
Crea un nuovo Validation.
Disponibile per le app Google Chat e i componenti aggiuntivi di Google Workspace.
const validation = CardService.newValidation().setCharacterLimit(5).setInputType( CardService.InputType.EMAIL);
Indietro
Validation: una convalida vuota.