Skip to content

Write Workflow Expressions

How do you pass the right value to the next step? Use an expression to read a flow input, a wired node output, or stored workflow data. Then apply operations for its type. For Daily invoice digest, filter the invoice queue and turn the matching IDs into one message. The assistant syntax supports const declarations followed by a final expression. This restricted JavaScript-like syntax does not support arbitrary JavaScript.

In the app: open Workflows → Daily invoice digest in development. Connect the source node to the destination, select the destination text field, and click Insert dynamic data. Choose the source and its operations in the expression panel.

With an assistant: every workflow-scoped tool call carries an explicit workflowId, a positive-integer string. List the workflows with workflow_list to find the digest’s ID.

{ "limit": 100 }

Note the digest’s data.items[].id as <workflowId>. If it is absent and data.hasMore is true, find its ID in the app.

List its flows with flow_list.

{ "workflowId": "<workflowId>" }

Note the selected data.items[].id as <flowId>. Inspect that flow with flow_get to find its source and destination nodes.

{ "workflowId": "<workflowId>", "flowId": "<flowId>" }

From data.nodes[].id, note the source as <sourceNodeId> and destination as <nodeId>. List the destination’s properties with node_prop_list to find the text property’s name.

{ "workflowId": "<workflowId>", "nodeId": "<nodeId>" }

Use the text property’s data.props[].name as <name>.

If the connection is absent, connect the nodes with node_connect:

{ "workflowId": "<workflowId>", "flow": "<flowId>", "from": "<sourceNodeId>", "to": "<nodeId>" }

Inspect the context for bindings with expr_context, and the operations available for lists with expr_operation_list:

{ "workflowId": "<workflowId>", "nodeId": "<nodeId>", "prop": "<name>" }
{ "workflowId": "<workflowId>", "type": "list" }

Copy each binding’s js spelling and check inputId and sourceNodeId. If you guess names, the expression can select the wrong source and still compile. unwiredUpstreamOutputs lists connection candidates, not usable bindings. Renaming an input can change its current jsBinding. The legacyBinding value provides diagnostic information. After renaming, wiring, or schema changes, reread context.

Source Use it for Scope
flow.<name> Caller input Current flow.
inputs.<name> Upstream result Wired bindings in context; use the returned accessor.
process.data, process.error This node’s result or error Only when context exposes the process result.
workflowData("custom.invoice") Stored invoices Active collection for the run’s workflow version.
item Current list item Only where context exposes it; a child flow uses its own flow input.
now, isLiveVersion Date/time or environment Aliases: currentDate, live.

If context exposes flow.title, use a backtick template to produce text.

`${flow.title ?? "Daily invoice digest"}`

For numeric or boolean destinations, use direct expressions such as flow.count ?? 0 or flow.enabled ?? false. ?? requires a text, number, or boolean value and a literal fallback of the same type. It preserves real 0 and false. Text fallback replaces whitespace-only text. Text .isEmpty() treats whitespace as present. On an output.T value, take .data before applying inner operations or fallbacks.

You cannot construct output objects or call JSON.stringify(). The object-literal exception is the .filter() options object, such as { ignoreEmptyConstraints: true }. To produce JSON text, assemble complete tokens: .jsonEncode() supplies text quotes and escapes, and .stringify() serializes shapes or lists.

`{"title":${flow.title.jsonEncode()},"invoices":${inputs.invoiceQueue.stringify()}}`

Substitute the bindings from context. Do not add quotes around the interpolations.

Use three test rows: INV-104 / 120 / review false, INV-105 / 1500 / review true, and INV-106 / 80 / review false. These are example values, not existing records. If context exposes inputs.invoiceQueue and these fields, use this expression, referred to below as <digestJs>, to filter and format the digest.

const pending = inputs.invoiceQueue.filter(row => row.reviewNeeded === true);
`Review queue (${pending.length}): ${pending.map(row => row.invoiceId).join(", ")}`

Expect Review queue (1): INV-105. .map() selects one field per call. It cannot construct objects or transform primitive items. Chain selections for nested fields. This single message needs no loop.

For stored invoices, start with workflowData("custom.invoice").filter(...) so supported constraints narrow the storage search. The default record ceiling is 10,000. If you exceed it, you receive a warning and the full result by default. On deployments that enforce the ceiling, the search fails. Narrow the source before relying on a large result.

On a typed null list, both .isEmpty() and .isNotEmpty() return false. Filtering by fields can also fail. Require the input or make its source return []. Test null separately from an empty list.

For statuses "approved", "review", and "":

Predicate Matches Missing-value consequence
row.status === "" Only "" Null is different from empty text.
row.status !== "" "approved", "review" A missing value also passes.
row.status.includes("") All three Every text string contains empty text.

If blank means “omit this constraint,” open Filtered → Ignore empty constraints in the app, or write .filter(row => row.status === flow.status, { ignoreEmptyConstraints: true }). This skips null, undefined, empty text, and empty-list comparison values. It keeps 0, false, whitespace, and dates.

When the schema is known, an unknown field fails compilation. If a saved or schema-less constraint reaches runtime after its field disappears, .filter() drops it. With no remaining constraints, every row passes. .every() fails closed.

The assistant syntax rejects predicates on primitive lists, such as x => x > 1000. If you invent x.value, the constraint may be dropped. In the app, use Filtered → Add advanced condition and compare the current item. With an assistant, use a per-item flow.

Before assigning an expression to an array property, inspect its metadata. Expressions for whole lists need allowsExpressionMode and the expressionValue channel. Without it, a SHORT_TEXT_ARRAY scalar expression replaces the entire array with one dynamic item. Other array properties without this support accept static lists only.

Validate the expression with expr_validate, save it with node_prop_set, then read back the saved expression with expr_decompile. Pass the expression source in js for validation and setting:

{ "workflowId": "<workflowId>", "nodeId": "<nodeId>", "prop": "<name>", "js": "<digestJs>" }

expr_decompile takes the same arguments without js.

If you receive UNREPRESENTABLE_STORED_EXPRESSION, the expression was not overwritten. The stored expression contains constructs this syntax cannot express. To preserve them, copy the selected data.props[] entry’s value or expressionValue as <rawExpression>. Match the guarded valueJs or expressionValueJs channel and edit that tree. Then write it with node_prop_set, passing the parsed tree in rawExpressionJson:

{ "workflowId": "<workflowId>", "nodeId": "<nodeId>", "prop": "<name>", "rawExpressionJson": "<rawExpression>" }

When you write a disabled optional property, the setter enables it before compiling. If the write fails, the property stays enabled. If it should remain unused, disable it in the app or with node_optional_prop_set.

{ "workflowId": "<workflowId>", "nodeId": "<nodeId>", "prop": "<name>", "enabled": false }

In the app: click Test (tooltip: Test current flow) and inspect the node execution’s Configurations. A development test still sends real Slack messages. Choose the intended docs-digest-test channel first.

With an assistant: inspect accepted inputs with run_inputs and build the test values under their returned IDs. Only when the flow needs no inputs should you use {}. Run the flow in development with run_flow to inspect its resolved configurations.

{ "workflowId": "<workflowId>", "nodeIdOrFlowId": "<flowId>", "flow": true }
{ "workflowId": "<workflowId>", "flowId": "<flowId>", "target": "dev", "inputs": { "<inputId>": "<value>" } }

Runs wait waitSeconds (default 60, maximum 120). After finished: false, poll execution_get with workflowId and the returned workflowExecutionId as strings.

Repeat with no qualifying rows. To test missing inputs in development, supply their exact keys with null. If you leave a key out, the run reuses its saved test value. Manual Test turns null text into "". Outside manual Test, omitted optional inputs become null. Check comparisons on the intended trigger/live path too.

Inspect data.nodeExecutions[].resolvedConfigs in the flow result. A node-only result has data.resolvedConfigs. Compilation cannot prove the source ran. A test of one node does not run upstream nodes. Note the destination’s data.nodeExecutions[].id as <nodeExecutionId>. Retrieve that execution with execution_node_get to inspect its full details.

{ "workflowId": "<workflowId>", "nodeExecutionId": "<nodeExecutionId>", "full": true }