Class CardService

CardService

CardService provides the ability to create generic cards used across different Google extensibility products, such as Gmail add-ons.


 return CardService.newCardBuilder()
          .setHeader(CardService.newCardHeader().setTitle("CardTitle"))
          .build();
 

Or you can return multiple Cards like so:


 return [
   CardService.newCardBuilder().build(),
   CardService.newCardBuilder().build(),
   CardService.newCardBuilder().build()
 ]
 

The following shows how you could define a card with a header, text, an image and a menu item:


 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();
 }
 

Properties

PropertyTypeDescription
ComposedEmailTypeComposedEmailTypeThe ComposedEmailType enumeration.
IconIconThe Icon enumeration.
ImageStyleImageStyleThe ImageStyle enumeration.
LoadIndicatorLoadIndicatorThe LoadIndicator enumeration.
NotificationTypeNotificationTypeThe NotificationType enumeration.
OnCloseOnCloseThe OnClose enumeration.
OpenAsOpenAsThe OpenAs enumeration.
SelectionInputTypeSelectionInputTypeThe SelectionInputType enumeration.

Methods

MethodReturn typeBrief description
newAction()ActionCreates a new Action.
newActionResponseBuilder()ActionResponseBuilderCreates a new ActionResponseBuilder.
newAuthorizationAction()AuthorizationActionCreates a new AuthorizationAction.
newAuthorizationException()AuthorizationExceptionCreates a new AuthorizationException.
newButtonSet()ButtonSetCreates a new ButtonSet.
newCardAction()CardActionCreates a new CardAction.
newCardBuilder()CardBuilderCreates a new CardBuilder.
newCardHeader()CardHeaderCreates a new CardHeader.
newCardSection()CardSectionCreates a new CardSection.
newComposeActionResponseBuilder()ComposeActionResponseBuilderCreates a new ComposeActionResponseBuilder.
newImage()ImageCreates a new Image.
newImageButton()ImageButtonCreates a new ImageButton.
newKeyValue()KeyValueCreates a new KeyValue.
newNavigation()NavigationCreates a new Navigation.
newNotification()NotificationCreates a new Notification.
newOpenLink()OpenLinkCreates a new OpenLink.
newSelectionInput()SelectionInputCreates a new SelectionInput.
newSuggestions()SuggestionsCreates a new Suggestions.
newSuggestionsResponseBuilder()SuggestionsResponseBuilderCreates a new SuggestionsResponseBuilder.
newSwitch()SwitchCreates a new Switch.
newTextButton()TextButtonCreates a new TextButton.
newTextInput()TextInputCreates a new TextInput.
newTextParagraph()TextParagraphCreates a new TextParagraph.
newUniversalActionResponseBuilder()UniversalActionResponseBuilderCreates a new UniversalActionResponseBuilder.

Detailed documentation

newAction()

Creates a new Action.

Return

Action — an empty Action.


newActionResponseBuilder()

Creates a new ActionResponseBuilder.

Return

ActionResponseBuilder — an empty ActionResponse builder


newAuthorizationAction()

Creates a new AuthorizationAction.

Return

AuthorizationAction — an empty AuthorizationAction();


newAuthorizationException()

Creates a new AuthorizationException.

Return

AuthorizationException — an empty AuthorizationException.


newButtonSet()

Creates a new ButtonSet.

Return

ButtonSet — an empty ButtonSet.


newCardAction()

Creates a new CardAction.

Return

CardAction — an empty CardAction.


newCardBuilder()

Creates a new CardBuilder.

Return

CardBuilder — an empty Card builder.


newCardHeader()

Creates a new CardHeader.

Return

CardHeader — an empty CardHeader.


newCardSection()

Creates a new CardSection.

Return

CardSection — an empty CardSection.


newComposeActionResponseBuilder()

Creates a new ComposeActionResponseBuilder.

Return

ComposeActionResponseBuilder — an empty ComposeActionResponse builder


newImage()

Creates a new Image.

Return

Image — an empty Image.


newImageButton()

Creates a new ImageButton.

Return

ImageButton — an empty ImageButton.


newKeyValue()

Creates a new KeyValue.

Return

KeyValue — an empty KeyValue.


newNavigation()

Creates a new Navigation.

Return

Navigation — an empty Navigation.


newNotification()

Creates a new Notification.

Return

Notification — an empty Notification.


newOpenLink()

Creates a new OpenLink.

Return

OpenLink — an empty OpenLink.


newSelectionInput()

Creates a new SelectionInput.

Return

SelectionInput — an empty SelectionInput.


newSuggestions()

Creates a new Suggestions.

Return

Suggestions — an empty Suggestions.


newSuggestionsResponseBuilder()

Creates a new SuggestionsResponseBuilder.

Return

SuggestionsResponseBuilder — an empty SuggestionsResponse builder


newSwitch()

Creates a new Switch.

Return

Switch — an empty Switch.


newTextButton()

Creates a new TextButton.

Return

TextButton — an empty TextButton.


newTextInput()

Creates a new TextInput.

Return

TextInput — an empty TextInput.


newTextParagraph()

Creates a new TextParagraph.

Return

TextParagraph — an empty TextParagraph.


newUniversalActionResponseBuilder()

Creates a new UniversalActionResponseBuilder.

Return

UniversalActionResponseBuilder — an empty UniversalActionResponse builder

Send feedback about...

Apps Script
Apps Script