Data preparation steps
A data preparation step runs one or more formulas on values from workflow inputs, step inputs, or earlier steps — then writes the results as named outputs you can chain into agents, tools, or conditions.
Use it when you need to change data between action steps without calling an agent or external tool — for example summing scores, joining labels, or building a true/false flag before a condition.
When to use data preparation
| Approach | Best for |
|---|---|
| Data preparation | Sum, split, join, filter, compare, or format values in the workflow |
| Condition | Branch to a different next step when a rule is true or false |
| Agent / tool | Search, write content, call APIs, or create documents |
Good reasons to use data preparation:
- Aggregate a list — total, count, or filtered subset before the next step.
- Shape text — join array items into one string, or split CSV-like text into a list.
- Prepare a flag — produce
true/falsefrom inputs, then branch with a condition step.
Step 1 — Add a data preparation step
- Open your workflow in the editor.
- Click Add Step, or choose From Template and open the Data Preparation category.
- Set Step kind to Data Preparation.
- Under Output mappings, add one row per result you need:
- Output name — how later steps reference this value (for example
total). - Type — string, number, boolean, array, or object.
- Formula — a single
{{ … }}expression that produces the value.
- Output name — how later steps reference this value (for example
Templates such as Data Preparation - Sum array pre-fill a common mapping; adjust names and formulas to match your workflow.
Step 2 — Pass data into formulas (optional)
Formulas can read:
| Source | Example |
|---|---|
| Workflow inputs | {{ workflow_inputs.mode }} |
| Earlier step outputs | {{ steps.search.outputs.results }} |
| Step inputs on this step | {{ values }} (after you add an input named values) |
To reuse a long expression or coerce a type first, add step inputs on the data preparation step (same pattern as agent chaining):
- Under Inputs, add an input (for example
values, type array, value source From expression). - Set the expression to
{{ steps.collect.outputs.scores }}. - In the mapping formula, use the short name:
{{ sum(values) }}.
Formula reference
Formulas use the same {{ … }} syntax described in Workflow authoring. Common helpers:
| Goal | Formula example |
|---|---|
| Sum numbers in an array | {{ sum(values) }} |
| Count items | {{ len(items) }} |
| Join strings | {{ join(labels, ", ") }} |
| Split text | {{ split(text, ",") }} |
| Compare values | {{ workflow_inputs.mode == "deep" }} |
| Filter a list | {{ filter(items, #.active == true) }} |
| Today’s date (YYYY-MM-DD) | {{ now().Format("2006-01-02") }} |
| Parse date to YYYY-MM-DD | {{ date(date_string, "2006-01-02").Format("2006-01-02") }} |
| Days between two dates | {{ floor((date(end_date, "2006-01-02") - date(start_date, "2006-01-02")).Hours() / 24) }} |
| Days remaining until due date | {{ floor((date(due_date, "2006-01-02") - date(now().UTC().Format("2006-01-02"))).Hours() / 24) }} |
| Is due date overdue | {{ date(due_date, "2006-01-02") < date(now().UTC().Format("2006-01-02")) }} |
Later steps reference results with:
{{ steps.<step_name>.outputs.<output_name> }} Example workflow (sum then branch)
workflow_inputs:
- name: scores
type: array
required: true
steps:
- name: sum_scores
kind: data_preparation
config:
mappings:
- name: total
expression: "{{ sum(scores) }}"
inputs:
- name: scores
type: array
format: json
value_source: from_expression
expression: "{{ workflow_inputs.scores }}"
outputs:
- name: total
type: number
format: json
on_error: fail
- name: check_total
kind: condition
config:
choices:
- condition: "{{ steps.sum_scores.outputs.total > 100 }}"
next_step: high_path
on_error: fail
- name: high_path
kind: tool
# ...
on_error: fail Running and checking results
After a run, open the execution detail page and expand the data preparation step. Resolved inputs and computed outputs appear on the step record. Use those output names in formulas on steps below.
Limits and tips
- Each mapping row must be one formula wrapped in
{{ }}. - Output names in mappings must match the step outputs list (the editor keeps them in sync).
- All mappings in one step evaluate against the same inputs — you cannot use one mapping’s result inside another mapping in the same step yet. Add a second data preparation step if you need a chain.
- For branching, use a condition step after data preparation — conditions need a boolean formula, while data preparation can produce any type.
Related guides
- Workflow authoring — formulas, chaining, and step kinds
- Loop steps —
context.loop_itemand related expressions inside loops - Sub-workflows