CardService provides the ability to create generic cards used across different Google extensibility products, such as Google Workspace 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
Property | Type | Description |
---|---|---|
BorderType | BorderType | The BorderType enumeration. |
ComposedEmailType | ComposedEmailType | The ComposedEmailType enumeration. |
ContentType | ContentType | The ContentType enumeration. |
GridItemLayout | GridItemLayout | The GridItemLayout enumeration. |
HorizontalAlignment | HorizontalAlignment | The HorizontalAlignment enumeration. |
Icon | Icon | The Icon enumeration. |
ImageCropType | ImageCropType | The ImageCropType enumeration. |
ImageStyle | ImageStyle | The ImageStyle enumeration. |
LoadIndicator | LoadIndicator | The LoadIndicator enumeration. |
OnClose | OnClose | The OnClose enumeration. |
OpenAs | OpenAs | The OpenAs enumeration. |
SelectionInputType | SelectionInputType | The SelectionInputType enumeration. |
TextButtonStyle | TextButtonStyle | The TextButtonStyle enumeration. |
UpdateDraftBodyType | UpdateDraftBodyType | The UpdateDraftBodyType enumeration. |
Methods
Detailed documentation
newActionResponseBuilder()
Creates a new ActionResponseBuilder
.
Return
ActionResponseBuilder
— An empty ActionResponse builder.
newAttachment()
newAuthorizationAction()
newAuthorizationException()
Creates a new AuthorizationException
.
Return
AuthorizationException
— An empty AuthorizationException.
newBorderStyle()
newCalendarEventActionResponseBuilder()
Creates a new CalendarEventActionResponseBuilder
.
Return
CalendarEventActionResponseBuilder
— An empty CalendarEventActionResponseBuilder
.
newCardAction()
newCardBuilder()
newCardHeader()
newCardSection()
newComposeActionResponseBuilder()
Creates a new ComposeActionResponseBuilder
.
Return
ComposeActionResponseBuilder
— An empty ComposeActionResponse builder.
newDatePicker()
newDateTimePicker()
newDecoratedText()
newDivider()
Creates a new Divider
. The following sample builds a simple card with 2 paragraphs
separated by a divider.
function buildCard() { let cardSection1TextParagraph1 = CardService.newTextParagraph() .setText('Hello world!'); let cardSection1Divider1 = CardService.newDivider(); let cardSection1TextParagraph2 = CardService.newTextParagraph() .setText('Hello world!'); let cardSection1 = CardService.newCardSection() .addWidget(cardSection1TextParagraph1) .addWidget(cardSection1Divider1) .addWidget(cardSection1TextParagraph2); let card = CardService.newCardBuilder() .addSection(cardSection1) .build(); return card; }
Return
Divider
— A divider.
newDriveItemsSelectedActionResponseBuilder()
Creates a new DriveItemsSelectedActionResponseBuilder
.
Return
DriveItemsSelectedActionResponseBuilder
— An empty DriveItemsSelectedActionResponseBuilder
.
newEditorFileScopeActionResponseBuilder()
Creates a new EditorFileScopeActionResponseBuilder
.
Return
EditorFileScopeActionResponseBuilder
— An empty EditorFileScopeActionResponseBuilder
.
newImageButton()
newImageComponent()
newImageCropStyle()
newNotification()
newSelectionInput()
newSuggestions()
newSuggestionsResponseBuilder()
Creates a new SuggestionsResponseBuilder
.
Return
SuggestionsResponseBuilder
— An empty SuggestionsResponse builder.
newTextButton()
newTextParagraph()
newTimePicker()
newUniversalActionResponseBuilder()
Creates a new UniversalActionResponseBuilder
.
Return
UniversalActionResponseBuilder
— An empty UniversalActionResponse builder.
newUpdateDraftActionResponseBuilder()
Creates a new UpdateDraftActionResponseBuilder
.
Return
UpdateDraftActionResponseBuilder
— An empty UpdateDraftActionResponseBuilder.
newUpdateDraftBccRecipientsAction()
Creates a new UpdateDraftBccRecipientsAction
;
Return
UpdateDraftBccRecipientsAction
— An empty UpdateDraftBccRecipientsAction.
newUpdateDraftBodyAction()
newUpdateDraftCcRecipientsAction()
Creates a new UpdateDraftCcRecipientsAction
.
Return
UpdateDraftCcRecipientsAction
— An Empty UpdateDraftCcRecipientsAction.
newUpdateDraftSubjectAction()
Creates a new UpdateDraftSubjectAction
.
Return
UpdateDraftSubjectAction
— An empty UpdateDraftSubjectAction.
newUpdateDraftToRecipientsAction()
Creates a new UpdateDraftToRecipientsAction
.
Return
UpdateDraftToRecipientsAction
— An empty UpdateDraftToRecipientsAction.