Ports and envelope
Every node returns an envelope with ok, data, port and meta. The data becomes the next node's input, and the port decides which edges the engine follows. This page covers ports, edges, fan-out and how the final port settles a run.
A workflow does not branch by magic. Each node says what happened by naming a port, and the graph says where each port leads. Read this page and you can predict any run from its graph.
The envelope
When a node finishes, it returns an envelope:
{
"ok": true,
"data": { "label": "billing", "confidence": 0.92 },
"port": "out",
"meta": {}
}| Field | Meaning |
|---|---|
ok | Whether the node did its work. |
data | The node’s output. It becomes $json for the next node and stays available to every later node through $('Node label'). |
port | The outcome. The engine follows the edges that leave this port. When a node returns no port, the engine uses out. |
meta | Extra information about the execution (for example, which cases matched in flow.switch). |
In a run, each node leaves a node execution with its output, port, status and duration, so you can see later which port every node chose.
Ports
Each node declares its ports in the catalog. One of them is the default. Some common sets:
| Node | Ports |
|---|---|
Most nodes (io.http, data.transform, code.js…) | out, error |
flow.if | true, false, error |
flow.switch | one port per case you define, default, error |
data.validate | valid, invalid, error |
data.lookup | found, miss, error |
ai.classify.triage | success, error |
integrations.mongodb.operation | out, empty, error |
human.task.create | created, error |
flow.split | out (once per item), done, error |
flow.try | do |
A port with no edge is a valid end: when a node leaves through a port that has no edge, that branch stops there.
Edges
An edge connects a port of one node to another node:
{
"from": { "node_id": "validate", "port": "valid" },
"to": { "node_id": "route", "port": "in" }
}The studio writes to.port as in; the engine only looks at from.node_id and from.port. An edge whose
from.port is * is followed whatever port the node returns.
Fan-out
Several edges can leave the same port. The engine runs every target, one after the other, and each branch receives the
same data. Branches run in the order their edges appear in the graph, and the engine runs one step of each branch
before going deeper into any of them.
A node that two branches reach runs once per branch. To gather the items produced by flow.split,
use flow.join, which waits for the done signal and collects the results.
Passing data along
Ports that only route, such as those of flow.if and flow.switch, pass the input through unchanged: the next node
sees the same $json the router received. Nodes that do work replace $json with their own output, so read older
data with $('Node label').item.json. See Expressions.
How the final port settles the run
When no edge is left to follow, the run ends. Its status depends on how it ended:
failedif a node raised an error the engine could not route, if the run went over 100 steps, or if the last node that ran left througherror.completedotherwise, including runs where a node failed, left througherrorand an edge on that port recovered the case.