Skip to content

Logic Nodes

Logic nodes control execution flow — branching, looping, waiting, error handling, batching, and sub-workflow delegation. Use them to build conditional automation, fan-out pipelines, and resilient recovery paths.

NodeTypeOutput
Codecodejson
Switchswitchtext
If / Conditionif_conditionboolean
Loop / Maploop_maparray
Wait / Delaywait_delayjson
Error Catcherror_catchjson
Try / Catchtry_catchjson
Mergemergejson
Split In Batchessplit_in_batchesarray
Sub-Workflowsub_workflowworkflow_result
Stop / Returnstop_returnworkflow_result

Code

Type: code · Category: Logic

Execute sandboxed JavaScript or TypeScript against upstream data. Returns a JSON-compatible value.

When to Use

Use Code when no built-in node handles your exact transformation, calculation, or routing logic. Ideal for: custom aggregations, multi-field transforms, regex extraction, business rule logic.

Inputs

NameTypeRequired
inputanyNo

Outputs

NameTypeDescription
resultjsonReturn value of the code function.

Required Config

FieldTypeDescription
codetemplateCode body. Must return a JSON-compatible value. The upstream payload is available as input.

Optional Config

FieldTypeDefault
timeoutMsnumber5000

Example

json
{
  "code": "return { digestText: input.summary, itemCount: input.items.length };",
  "timeoutMs": 5000
}

Downstream:email_send with { "body": "$.result.digestText" }

Troubleshooting

  • "Execution timeout" — reduce timeoutMs or simplify the code.
  • "Return value is not JSON" — avoid returning undefined, Date, or class instances.

JSON Transform · Switch · Data Mapper


Switch

Type: switch · Category: Logic

Route execution by matching configured cases. Evaluates a path on the input and emits the matching branch label.

Inputs

NameType
inputany

Outputs

NameTypeDescription
resulttextMatched branch label.

Required Config

FieldTypeDescription
casesjsonOrdered branch cases: [{ label, operator, value }]. Operators: equals, contains, gt, lt, regex.

Optional Config

FieldTypeDefault
inputPathstring
defaultBranchstring

Example

json
{
  "inputPath": "$.status",
  "cases": [{ "label": "failed", "operator": "equals", "value": "failed" }],
  "defaultBranch": "ok"
}

Downstream:slack_notify with { "text": "$.branch" }

If / Condition · Code · Error Catch


If / Condition

Type: if_condition · Category: Logic

Continue downstream when a boolean condition evaluates true. Drops the item when false.

Required Config

FieldTypeDescription
conditiontemplateBoolean expression or path mapping (e.g. $.score >= 0.8).

Example

json
{ "condition": "$.score >= 0.8" }

Downstream:leaderboard_update

Switch · Score Aggregator


Loop / Map

Type: loop_map · Category: Logic

Map over an array and emit transformed items. Each item in the array is processed by the downstream subgraph.

Inputs

NameTypeRequired
itemsarrayYes

Outputs

NameType
itemsarray

Optional Config

FieldTypeDefault
arrayPathstring$.items
maxItemsnumber100

Example

json
{
  "arrayPath": "$.documents",
  "itemVariable": "document",
  "maxItems": 25
}

Downstream:summarizer with { "documents": "$.items" }

Troubleshooting

  • "Array is empty" — check upstream filter or aggregate nodes.
  • "maxItems exceeded" — increase maxItems or use split_in_batches before the loop.

Split In Batches · Filter Items · Aggregate


Wait / Delay

Type: wait_delay · Category: Logic

Pause execution for a duration or until a timestamp. Useful for rate-limiting, scheduled resumption, or debouncing.

Optional Config

FieldTypeDefault
delayMsnumber5000
delayUntilstring

Example

json
{ "delayMs": 300000 }

(5-minute delay before checking a GitHub PR status.)

Downstream:github_read

Schedule Trigger · Retry


Error Catch

Type: error_catch · Category: Logic

Handle an upstream error and route fallback data. Connect this node to the error output of a node that may fail.

Inputs

NameTypeRequired
errorerrorYes — error envelope from a failed node

Outputs

NameType
recoveryjson

Optional Config

FieldTypeDefault
fallbackValuejson
continueOnErrorbooleantrue

Example

json
{
  "fallbackValue": { "alert": "Workflow failed while summarizing RSS." },
  "continueOnError": true
}

Downstream:slack_notify with { "text": "$.recovery.alert" }

Try / Catch · Retry · Logger


Try / Catch

Type: try_catch · Category: Logic

Run a protected branch and emit either the result or an error envelope. Unlike error_catch, Try / Catch wraps the protected subgraph inline.

Optional Config

FieldTypeDefault
catchBranchstringcatch

Example

json
{ "catchBranch": "notify_failure" }

Expected output (on error): { "ok": false, "error": { "message": "Provider timeout" } }

Downstream:slack_notify with { "text": "$.error.message" }

Error Catch · Stop / Return


Merge

Type: merge · Category: Logic

Merge multiple upstream values into one payload. Use after parallel branches to consolidate results.

Optional Config

FieldTypeDefaultOptions
strategyselectjson_objectlast_write_wins · concat · array · json_object

Example

json
{ "strategy": "json_object" }

Expected output: { "merged": { "digest": "...", "scores": [0.8, 0.9] } }

Downstream:email_send with { "body": "$.merged.digest" }

Split In Batches · Aggregate


Split In Batches

Type: split_in_batches · Category: Logic

Split a large array into batches for downstream processing.

Inputs

NameTypeRequired
itemsarrayYes

Optional Config

FieldTypeDefault
batchSizenumber25

Example

json
{ "batchSize": 10 }

Downstream:rss_feed with { "urls": "$.batch" }

Loop / Map · Deduplicate


Sub-Workflow

Type: sub_workflow · Category: Logic

Execute another workflow with mapped inputs. Use for orchestrating modular workflows, reusable sub-pipelines, and hierarchical automation.

Required Config

FieldTypeDescription
workflowIdstringWorkflow id to invoke.

Optional Config

FieldTypeDefault
inputMappingjson
maxDepthnumber2

Example

json
{
  "workflowId": "wf_weekly_digest",
  "inputMapping": { "topic": "$.topic", "window": "$.window" },
  "maxDepth": 2
}

Expected output: { "workflowResult": { "status": "completed", "output": "Digest ready" } }

Downstream:email_send with { "body": "$.workflowResult.output" }

Stop / Return · Code


Stop / Return

Type: stop_return · Category: Logic

Stop execution and return a final payload. Use to end a conditional branch early or mark a definitive workflow result.

Optional Config

FieldTypeDefaultOptions
returnPathstring$
statusselectcompletedcompleted · failed

Example

json
{ "returnPath": "$.answer", "status": "completed" }

Downstream:logger (last node before termination)

Sub-Workflow · Error Catch


See also: Node Catalog Index · Workflow Concepts · Workflow Studio