# Conditional Actions

Conditional actions are a meta action type which check a [condition](/conditional-targeting/intro-to-conditions.md) and dispatch one action if it's true, and another if it's false.

{% hint style="info" %}
Example use case: If the app\_version >= 3.0, show a modal message about new v3 features. If not, show alert suggesting they upgrade, including a button which links to the app store.
{% endhint %}

### Configuration

The following fields are available in the action configuration:

* `condition` \[string, required]: the [condition](/conditional-targeting/intro-to-conditions.md) to check. Example `(device_battery_state == 'charging' || device_battery_state == 'full')`.
* `passedActionName` \[string, required]: the name of the action to fire if the condition is true.
* `failedActionName` \[string, optional]: the name of the action to fire if the condition is false.

{% hint style="info" %}
If you don't have an "else"/`failedActionName` action and just want to check a condition before firing an action, you don't need to wrap your action in a conditional action. Simply specify a [`condition` string on the action](/actions-in-app-messaging/actions-overview.md) and the action will only proceed if the condition passes.
{% endhint %}

### Example Config

```
{
    "actionType": "conditional_action",
    "actionData": {
        "condition": "(device_battery_state == 'charging' || device_battery_state == 'full')",
        "passedActionName": "true_action",
        "failedActionName": "false_action"
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.criticalmoments.io/actions-in-app-messaging/conditional-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
