Loopfour
Blocks

Condition block

Configure the Condition block: write the expression it evaluates and connect the branches the workflow follows when it is true or false.

The Condition block (type: "condition") tests values from the run and sends it down one of two branches: then when the test is true, else when it is false. For the plain-language guide, see Make a decision.

When to use it

  • Route a bill over an approval limit to an Approval step.
  • Skip a step when an earlier lookup found nothing, for example create a customer only when the search returned no match.
  • Stop on an error path: point else at a step with terminal: true.

Configuration

In the editor you build the test as rows in Conditions and join them with Combine With (AND or OR). The branches are the connections you draw from the block. On save, the editor writes this config:

Field (config key)TypeRequiredMeaning
conditionsexpressionYesThe test. See the expression forms below.
thenstring arrayYesIds of the steps to run when the test is true. At least one.
elsestring arrayNoIds of the steps to run when the test is false.

Expression forms

FormShape
Comparison{ "left": "<value>", "operator": "<operator>", "right": "<value>" }
Group{ "operator": "and", "conditions": [ ... ] } or "or"
Negation{ "not": <expression> }

left and right are strings. Each can be a literal or a template reference such as {{steps.extract_bill.structured.total}}, resolved before the comparison.

Operators

OperatorTrue when
eqValues are equal. Numeric text compares as numbers, so "10.00" equals "10".
neValues are not equal.
gt, gte, lt, lteNumeric comparison. $, €, £, ¥ and commas are removed first; text that is not a number counts as 0.
contains, startsWith, endsWithText comparison. Objects and arrays are compared as JSON text.
existsleft is not null or missing. right is not used.
isEmptyleft is missing, null, blank text, an empty array or an empty object. right is not used.
matchesleft matches the regular expression in right. An invalid pattern is false.

How branches run

Top-level steps run in array order. Steps listed in then or else run from the condition. The branch not taken is marked skipped, together with any steps nested inside it. A step listed in both branches, or reached again from another branch, runs when a taken path reaches it.

Output

FieldTypeMeaning
resultbooleanThe test result.
branchstringthen or else.
nextStepsstring arrayThe step ids the taken branch ran.
branchResultsarrayThe output of each step in the taken branch, in order.

Read the result as {{steps.<step id>.result}}.

Example

This workflow creates a QuickBooks bill and asks the controller to approve bills of $10,000 or more first.

{
  "name": "Approve large bills",
  "trigger": { "type": "api" },
  "steps": [
    {
      "id": "check_amount",
      "type": "condition",
      "name": "Bill is $10,000 or more?",
      "config": {
        "conditions": { "left": "{{input.amount}}", "operator": "gte", "right": "10000" },
        "then": ["controller_approval"]
      }
    },
    {
      "id": "controller_approval",
      "type": "approval",
      "name": "Controller approves bill",
      "config": {
        "approvers": ["controller@example.com"],
        "reason": "Bill {{input.billNumber}} from {{input.vendorName}} for {{input.amount}}",
        "timeout": "3d",
        "notifyChannels": [
          { "type": "email", "instructions": "Write a short note asking the controller to approve this vendor bill." }
        ]
      }
    },
    {
      "id": "create_bill",
      "type": "action",
      "name": "Create bill in QuickBooks",
      "action": "quickbooks.createBill",
      "config": {
        "vendorId": "{{input.vendorId}}",
        "billNumber": "{{input.billNumber}}",
        "lines": "{{input.lines}}"
      }
    }
  ]
}

Bills under $10,000 skip the approval and go straight to create_bill. A rejected approval fails the run, so the bill is not created.

Errors and limits

  • A config without conditions or with an empty then fails the step with Invalid condition step config.
  • A reference that resolves to nothing compares as empty: exists is false, and gt against it treats it as 0. Test with exists first when a field can be missing.
  • In the editor, a condition with no rows saves as a comparison of two empty values, which is true.

On this page