Conditional Actions

If this, then that

Conditional actions are a meta action type which check a condition and dispatch one action if it's true, and another if it's false.

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.

Configuration

The following fields are available in the action configuration:

  • condition [string, required]: the condition 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.

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 and the action will only proceed if the condition passes.

Example Config

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

Last updated