Documentation

Conditions & Branching

if-this-then-that — behaving differently depending on the situation

2 min read

An app needs to behave differently depending on the situation. When a list is empty, when a request fails, when a number crosses a threshold — handling these cases is what the Conditional action is for. It lets you express "if this, then that" without writing code.

How a Branch Works

A Conditional action looks at a single subject value and runs the first arm whose condition matches. The conditions available depend on the type of the subject value.

Boolean (True/False)

  • True — When the value is true
  • False — When the value is false

Number

Compares a number against a reference value.

| Operator | Meaning | |----------|---------| | == | Equal | | > | Greater than | | < | Less than | | >= | Greater than or equal | | <= | Less than or equal |

String

  • equals — Exact match
  • — Does not match
  • contains — Contains
  • starts with — Starts with
  • ends with — Ends with

HTTP Status Code

When handling the result of an API call, you branch on status code patterns (200, 2XX, 4XX, default). You can also auto-generate branches based on the response statuses declared by that API.

Else

The default arm that runs when none of the conditions match.

What Each Arm Runs

In each arm, you can write the actions to run directly (an inline flow), or reference an existing project Action Flow.

Examples

  • If the input is empty, show an Alert; otherwise, add the data.
  • If the score is >= 100, navigate to a congratulations screen; in the Else arm, leave it as is.
  • If the API response is 2XX, bind the result to the screen; if 4XX, show an error message.

If you want to compare numbers or text to get a true/false value, you can first produce a Boolean value with the Compare / Compare Text actions from Types of Actions, then branch on it.