FlowsGuide

Conditions: if, else if, else

A Condition node lets a flow choose. It holds an if test, any number of else if tests and an else; when the run reaches it, the tests are checked in order, the first one that is true runs its branch, and every other branch is skipped. Below the branches the flow joins back into one line and carries on.

What you will learn
  • Add a Condition node and fill its if / else if / else branches
  • Write a branch test that returns true or false
  • Read results after the join, whichever branch ran
  • See the taken path and the skipped branches on a run

One node, one path

On the canvas a Condition node opens into columns, one per branch. Each column starts with a pill — if true, else if, else, or the name you give it — that shows its test underneath, and holds the steps of that branch. All columns close into one end cap, the join; the step under the join runs after whichever branch ran. An empty branch is allowed: an else with no steps simply means “otherwise, go straight on”.

The else-if branch was taken and is green; the if and else branches are dimmed as skipped.

Exactly one branch runs per pass. The tests are checked top to bottom — Checks the branches in order and runs the first one that is true; else runs when none is. — so order them from the most specific to the most general. To run several branches at the same time, use Parallel branches instead: a condition is for choosing.

Build one

  1. Add the node

    Click a + on the line and pick Condition (If / else branching). It arrives with an if true branch and an else branch, both empty.

  2. Write the if test

    Click the node. In its panel, type the if test in the expression editor, for example nodes.start.output.score >= 80. Typing nodes. lists the steps above with their fields.

  3. Add else-if branches

    Add else if appends a branch with its own test, checked after the ones above it. Remove one with its X. The else branch is always there, last, with no test.

  4. Fill the branches

    Each column has its own + under its pill. Put the steps of that path there — any kind of step, including other conditions and loops. Each branch row in the condition’s panel has a name field (placeholder if true, else); a name you type replaces it on the pill.

  5. Continue under the join

    The + under the end cap adds the step that runs after the condition, whichever branch was taken.

Writing a branch test

A test is one JavaScript expression, run in the same isolated engine as binding expressions — no network, no files. It reads nodes.<alias>.output for every step that has already run (Start’s inputs are nodes.start.output when the node keeps its Start label), vars.NAME for variables, and, inside a loop, item, index and loops.<id> — so a condition in a loop body decides once per item.

JavaScriptbranch-tests.js
// if
nodes.fetchOrder.output.total >= 1000
// else if
nodes.fetchOrder.output.items.some((i) => i.fragile)
// else if — a variable is a string
vars.REGION === "eu" && item.country !== "PT"

Reading results after the join

A step in a branch that did not run has no output, so a step under the join that reads it directly fails. When the branches each produce the value you need, read it with optional chaining in an expression and take whichever exists:

JavaScriptafter-join.js
nodes.goldPrice?.output?.price ?? nodes.standardPrice?.output?.price

The condition’s own output records the choice — {"selected": "true"}, {"selected": "elseif-…"} or {"selected": "false"} for else — and is what the run view reads to draw the taken path.

A condition in a run

When the run passes a condition, the taken branch lights up like any executed path and every step of the other branches is marked Skipped and dimmed — at a glance you see which way the flow went. Clicking the condition shows which branch it selected. Inside a loop, the choice belongs to an iteration: pick another iteration on the loop and the canvas repaints that iteration’s path.

SituationWhat runs
The if test is trueThe if branch, then the step under the join
If is false, an else-if is trueThe first true else-if branch only
Every test is falseThe else branch (or nothing, if it is empty)
A test throws or returns a non-booleanNothing — the condition fails and so does the run

Rules

  • One if, any number of else-ifs, one else, in that order; the else has no test.
  • Conditions nest: a branch can hold another condition, a loop or parallel branches.
  • A test sees only steps that already ran. Naming a step below the condition, or one in a skipped branch, throws.