0.31.0 (latest) 0.30.0 0.29.0 0.28.0 0.27.0 0.23.0 0.20.0 0.19.0 0.18.0 0.17.1 0.16.1 0.15.0 0.14.0 0.13.1 0.12.1 0.11.2 0.10.0 0.9.0 0.8.1 0.7.2 0.6.1 0.5.0 0.4.0 0.3.0 0.2.0 0.1.4 Reference documentation and code samples for the Google Apps Chat V1 Client class Action.

An action that describes the behavior when the form is submitted.

For example, you can invoke an Apps Script script to handle the form.
If the action is triggered, the form values are sent to the server.
[Google Workspace add-ons and Chat
apps](https://developers.google.com/workspace/extend):

Generated from protobuf message `google.apps.card.v1.Action`

## Namespace

Google \\ Apps \\ Card \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ function` | `string` A custom function to invoke when the containing element is clicked or otherwise activated. For example usage, see [Read form data](https://developers.google.com/workspace/chat/read-form-data). |
| `↳ parameters` | `array<Action\ActionParameter>` List of action parameters. |
| `↳ load_indicator` | `int` Specifies the loading indicator that the action displays while making the call to the action. |
| `↳ persist_values` | `bool` Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. To let the user make changes while the action is being processed, set [`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) to `NONE`. For [card messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/create#create) in Chat apps, you must also set the action's [`ResponseType`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#responsetype) to `UPDATE_MESSAGE` and use the same [`card_id`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#CardWithId) from the card that contained the action. If `false`, the form values are cleared when the action is triggered. To prevent the user from making changes while the action is being processed, set [`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) to `SPINNER`. |
| `↳ interaction` | `int` Optional. Required when opening a [dialog](https://developers.google.com/workspace/chat/dialogs). What to do in response to an interaction with a user, such as a user clicking a button in a card message. If unspecified, the app responds by executing an `action`---like opening a link or running a function---as normal. By specifying an `interaction`, the app can respond in special interactive ways. For example, by setting `interaction` to `OPEN_DIALOG`, the app can open a [dialog](https://developers.google.com/workspace/chat/dialogs). When specified, a loading indicator isn't shown. If specified for an add-on, the entire card is stripped and nothing is shown in the client. [Google Chat apps](https://developers.google.com/workspace/chat): |
| `↳ required_widgets` | `string[]` Optional. Fill this list with the names of widgets that this Action needs for a valid submission. If the widgets listed here don't have a value when this Action is invoked, the form submission is aborted. [Google Workspace add-ons and Chat apps](https://developers.google.com/workspace/extend): |
| `↳ all_widgets_are_required` | `bool` Optional. If this is true, then all widgets are considered required by this action. [Google Workspace add-ons and Chat apps](https://developers.google.com/workspace/extend): |

### getFunction

A custom function to invoke when the containing element is
clicked or otherwise activated.

For example usage, see [Read form
data](https://developers.google.com/workspace/chat/read-form-data).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setFunction

A custom function to invoke when the containing element is
clicked or otherwise activated.

For example usage, see [Read form
data](https://developers.google.com/workspace/chat/read-form-data).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getParameters

List of action parameters.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<Action\ActionParameter>` |   |

### setParameters

List of action parameters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<Action\ActionParameter>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getLoadIndicator

Specifies the loading indicator that the action displays while
making the call to the action.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [LoadIndicator](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Card.V1.Action.LoadIndicator.md.txt). |

### setLoadIndicator

Specifies the loading indicator that the action displays while
making the call to the action.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [LoadIndicator](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Card.V1.Action.LoadIndicator.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getPersistValues

Indicates whether form values persist after the action. The default value
is `false`.

If `true`, form values remain after the action is triggered. To let the
user make changes while the action is being processed, set
[`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator)
to `NONE`. For [card
messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/create#create)
in Chat apps, you must also set the action's
[`ResponseType`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#responsetype)
to `UPDATE_MESSAGE` and use the same
[`card_id`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#CardWithId)
from the card that contained the action.
If `false`, the form values are cleared when the action is triggered.
To prevent the user from making changes while the action is being
processed, set
[`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator)
to `SPINNER`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setPersistValues

Indicates whether form values persist after the action. The default value
is `false`.

If `true`, form values remain after the action is triggered. To let the
user make changes while the action is being processed, set
[`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator)
to `NONE`. For [card
messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/create#create)
in Chat apps, you must also set the action's
[`ResponseType`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#responsetype)
to `UPDATE_MESSAGE` and use the same
[`card_id`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#CardWithId)
from the card that contained the action.
If `false`, the form values are cleared when the action is triggered.
To prevent the user from making changes while the action is being
processed, set
[`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator)
to `SPINNER`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getInteraction

Optional. Required when opening a
[dialog](https://developers.google.com/workspace/chat/dialogs).

What to do in response to an interaction with a user, such as a user
clicking a button in a card message.
If unspecified, the app responds by executing an `action`---like opening a
link or running a function---as normal.
By specifying an `interaction`, the app can respond in special interactive
ways. For example, by setting `interaction` to `OPEN_DIALOG`, the app can
open a [dialog](https://developers.google.com/workspace/chat/dialogs). When
specified, a loading indicator isn't shown. If specified for
an add-on, the entire card is stripped and nothing is shown in the client.
[Google Chat apps](https://developers.google.com/workspace/chat):

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [Interaction](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Card.V1.Action.Interaction.md.txt). |

### setInteraction

Optional. Required when opening a
[dialog](https://developers.google.com/workspace/chat/dialogs).

What to do in response to an interaction with a user, such as a user
clicking a button in a card message.
If unspecified, the app responds by executing an `action`---like opening a
link or running a function---as normal.
By specifying an `interaction`, the app can respond in special interactive
ways. For example, by setting `interaction` to `OPEN_DIALOG`, the app can
open a [dialog](https://developers.google.com/workspace/chat/dialogs). When
specified, a loading indicator isn't shown. If specified for
an add-on, the entire card is stripped and nothing is shown in the client.
[Google Chat apps](https://developers.google.com/workspace/chat):

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [Interaction](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Card.V1.Action.Interaction.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRequiredWidgets

Optional. Fill this list with the names of widgets that this Action
needs for a valid submission.

If the widgets listed here don't have a value when this Action is invoked,
the form submission is aborted.
[Google Workspace add-ons and Chat
apps](https://developers.google.com/workspace/extend):

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Protobuf\RepeatedField<string>` |   |

### setRequiredWidgets

Optional. Fill this list with the names of widgets that this Action
needs for a valid submission.

If the widgets listed here don't have a value when this Action is invoked,
the form submission is aborted.
[Google Workspace add-ons and Chat
apps](https://developers.google.com/workspace/extend):

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getAllWidgetsAreRequired

Optional. If this is true, then all widgets are considered required by
this action.

[Google Workspace add-ons and Chat
apps](https://developers.google.com/workspace/extend):

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setAllWidgetsAreRequired

Optional. If this is true, then all widgets are considered required by
this action.

[Google Workspace add-ons and Chat
apps](https://developers.google.com/workspace/extend):

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |