# Actions

Airship Actions provide a convenient way to automatically perform tasks by
name in response to push notifications, Message Center App Page interactions,
and JavaScript.


An action describes a function, which takes an optional argument
and performs a predefined task, producing an optional result.
Actions may restrict or vary the work they perform depending on the
arguments they receive, which may include type introspection and
runtime context.

The Airship SDK includes built-in actions for common tasks, and you can create custom actions to extend functionality.

For a complete list of available built-in actions, see the [Actions User Guide](https://www.airship.com/docs/guides/messaging/messages/actions/).

## Running Actions

Run actions programmatically with `Airship.Shared.actions.RunAction`. The method is asynchronous, so run it as a coroutine. The action value is passed as a JSON string, and the result is returned to the `onComplete` callback.

```csharp
// Run an action with a value
StartCoroutine(Airship.Shared.actions.RunAction("action_name", "\"action_value\"", (string result) => {
    Debug.Log("Action result: " + result);
}));

// Run an action without a value
StartCoroutine(Airship.Shared.actions.RunAction("action_name", null, (string result) => {
    Debug.Log("Action result: " + result);
}));
```


To handle errors, pass an optional `onError` callback.

```csharp
StartCoroutine(Airship.Shared.actions.RunAction(
    "action_name",
    "\"action_value\"",
    (string result) => {
        Debug.Log("Action result: " + result);
    },
    (System.Exception error) => {
        Debug.LogError("Action error: " + error.Message);
    }
));
```


## Custom Actions

Custom actions are registered with the native iOS and Android SDKs. See the native platform documentation for details:

- [iOS Actions](https://www.airship.com/docs/developer/sdk-integration/apple/actions/)
- [Android Actions](https://www.airship.com/docs/developer/sdk-integration/android/actions/)
