Class ActionResponseBuilder

  • ActionResponseBuilder helps create responses for actions within Google Apps Script cards.

  • It provides methods to define navigation, notifications, open links, and signal state changes when an action is performed.

  • The build() method finalizes the response and ensures its validity before execution.

  • Methods like setNavigation(), setNotification(), setOpenLink(), and setStateChanged() allow customization of the action's outcome.

  • Using an ActionResponseBuilder streamlines the process of defining how user interactions within a card trigger specific application behaviors.

ActionResponseBuilder

A builder for ActionResponse objects.

Methods

MethodReturn typeBrief description
build() ActionResponse Builds the current action response and validates it.
setNavigation(navigation) ActionResponseBuilder Sets the response to a Navigation action.
setNotification(notification) ActionResponseBuilder Sets the notification to display when the action is activated.
setOpenLink(openLink) ActionResponseBuilder Sets the URL to navigate to when the action is activated.
setStateChanged(stateChanged) ActionResponseBuilder Sets a flag to indicate that this action changed the existing data state.

Detailed documentation

build()

Builds the current action response and validates it.

Return

ActionResponse — A validated ActionResponse.

Throws

Error — if the constructed action response isn't valid.


setNavigation(navigation)

Sets the response to a Navigation action.

Parameters

NameTypeDescription
navigationNavigation The Navigation to use.

Return

ActionResponseBuilder — This object, for chaining.


setNotification(notification)

Sets the notification to display when the action is activated.

Parameters

NameTypeDescription
notificationNotification The Notification to use.

Return

ActionResponseBuilder — This object, for chaining.


Sets the URL to navigate to when the action is activated.

Parameters

NameTypeDescription
openLinkOpenLink The OpenLink to use.

Return

ActionResponseBuilder — This object, for chaining.


setStateChanged(stateChanged)

Sets a flag to indicate that this action changed the existing data state. For example, if the action created a task or updated contact information. When this flag is set to true, services such as Gmail can attempt to clear any cached state data associated with this action.

Parameters

NameTypeDescription
stateChangedBooleanWhether this action has changed the existing state data. Defaults to false.

Return

ActionResponseBuilder — This object, for chaining.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年12月02日 UTC.