Loops & Conditionals

Control flow primitives for complex workflows. Loop over arrays, branch on conditions, and build dynamic execution paths based on step outputs.


ForEach Loops

Add a loopConfig to any step to iterate over an array from a previous step. The step runs once per item; the current item is available as {{currentItem.field}}.

loopConfig: {
  source: "executionContent",    // pull from a previous step's output
  config: {
    stepId: "load_investors",    // which step's output to iterate
    field: "listEntries",        // dot-path to the array
    filter: {                    // optional — only loop qualifying items
      field: "score",
      operator: ">=",
      value: 70
    }
  }
}

onFailure: continue keeps looping past failed items; stop halts the entire loop on the first failure.


Entry Conditions (Conditional Gates)

Add entryConditions to any step to make it run only when criteria are met. If they fail, the step can be skipped, stop the workflow, or wait.

entryConditions: {
  onCriteriaFail: "skip",    // "skip" | "stop" | "wait"
  conditionText: "Only draft if score is high enough",
  criteria: [
    {
      variable: "{{steps.score_step.score}}",
      operator: ">=",
      value: 75
    },
    {
      variable: "{{input.documentFile}}",
      operator: "isNotNull"
    }
  ]
}
onCriteriaFailBehavior
skipSkip this step silently and continue to the next. Good for optional enrichment.
stopMark the execution as failed. Use for hard requirements.
waitPause execution until the condition is satisfied or manually overridden.

Condition Operators

OperatorUse for
==  !=Exact match / not equal (strings, booleans, enums)
>  <  >=  <=Numeric comparison (scores, counts, dates)
isNull  isNotNullPresence check (optional inputs, optional enrichment results)
containsSubstring or array membership check

Waiting for a Loop to Finish

If a downstream step needs to wait for all loop iterations to complete before running, add a loop_completion condition:

entryConditions: {
  criteria: [
    {
      type: "loop_completion",
      stepId: "enrich_each_company"
    }
  ]
}

Example: Enrich → Filter → Draft

Step 1Read prospects list (status: new). Returns listEntries[].

Step 2Loop over listEntries, onFailure: continue. Enrich {{currentItem.domain}} via Hunter.

Step 3Score each enriched lead. Entry condition: email isNotNull (skip if nothing was found).

Step 4Draft outreach. Entry condition: score >= 75, onCriteriaFail: skip — low scorers skipped silently.


Loops vs. Batching

Loops iterate sequentially within a single execution — one item at a time, in order. Batching splits a list into parallel child executions running concurrently. Use loops for small lists or when order matters; use batching for large datasets where speed matters more.


Next Steps

  • Batching — Parallel fan-out for large datasets
  • Validation — Catch bad data before loops run
  • AI Steps — Using AI steps inside loops