Skip to content

Control Flow Modules

Control Flow Modules

Router

Routes execution to different branches based on a condition. Functions like an if/else or switch statement.

appId: router

{
"appId": "router",
"ref": "routeByType",
"args": {
"routes": [
{
"condition": "{{ eq $prev.classify.type 'invoice' }}",
"label": "invoice"
},
{
"condition": "{{ eq $prev.classify.type 'receipt' }}",
"label": "receipt"
},
{
"condition": "true",
"label": "other"
}
]
}
}

Downstream flowlets check which route was taken:

{
"filters": [
{"leftValue": "{{ $prev.routeByType.route }}", "operator": "eq", "rightValue": "invoice"}
]
}

Iterator

Loops over an array, executing subsequent steps for each item.

appId: iterator

{
"appId": "iterator",
"ref": "loopItems",
"args": {
"items": "{{ $prev.fetchList.results }}",
"batchSize": 10
}
}

In the iteration steps, access the current item:

{{ $prev.loopItems.item }} ← current item
{{ $prev.loopItems.index }} ← current index (0-based)
{{ $prev.loopItems.total }} ← total item count
{{ $prev.loopItems.isLast }} ← true on last iteration

Aggregator

Collects results from an Iterator or parallel branches into a single array.

appId: aggregator

{
"appId": "aggregator",
"ref": "collectResults",
"args": {
"sourceRef": "processItem",
"field": "result"
}
}

Output: { "items": [...all collected values...], "count": 42 }

Subflow

Calls another flow as a step, passing arguments and receiving its output.

appId: subflow

{
"appId": "subflow",
"ref": "runSubprocess",
"args": {
"flowId": "65abc-child-flow-id",
"args": {
"inputData": "{{ $prev.prepare.data }}",
"mode": "fast"
},
"async": false,
"timeout": 60
}
}

Output: { "state": "DONE", "playId": "...", "out": { ...subflow output... } }

With async: true, the subflow is triggered in the background and the play ID is returned immediately.

Enumeration

Generates a sequence of values for use in iteration.

appId: enumeration

{
"appId": "enumeration",
"ref": "makeRange",
"args": {
"from": 1,
"to": 10,
"step": 1
}
}

Output: { "items": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }