> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firstresonance.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a flow step by step

> Add, configure, test, and check one step at a time, reference earlier steps' output, and branch on a condition.

Build a flow one step at a time, and test after each step. Each new step then has real output to reference, and a failure points to the step that caused it. Before you start, you need a flow with a trigger and a saved test payload. See [Create a flow](https://docs.firstresonance.io/automate-with-ion/workflow-builder/create-a-flow.md) and [Capture a test payload with Listening mode](https://docs.firstresonance.io/automate-with-ion/workflow-builder/test-a-flow.md#capture-a-test-payload-with-listening-mode).

## Add, test, and check each step

Repeat these steps for every step you add to the flow:

1. In **Workflow Builder**, click **+** under the last step, search for a component, such as **ion-api** or **Branch**, and select an action.
2. Configure the step's fields. Reference values from earlier steps instead of typing them in, as described in [Reference a value from an earlier step](#reference-a-value-from-an-earlier-step).
3. Run the flow with your saved payload, as described in [Run the flow with a saved payload](https://docs.firstresonance.io/automate-with-ion/workflow-builder/test-a-flow.md#run-the-flow-with-a-saved-payload).
4. In **Run history**, click the new step and check its **Output**. If a value is missing or wrong, fix the step and run the flow again before you add the next step.

Check the trigger's output the same way before you add the first step. The ION record the event is about is under `results.body.data.data` in the trigger's output, such as the received item of a **Receipt Items - Create** event. Confirm it holds the value the next step needs, such as a `part_inventory_id`.

## Reference a value from an earlier step

1. In the step's **Configure** tab, click the arrow icon at the right end of the field to open the **Reference** panel.
2. In **Step**, select the earlier step whose output you want, such as **Trigger**.
3. Expand the output tree and click the value. **Path** fills in with its location, such as `results.body.data.data`.

![Reference panel with Step set to Trigger, Path set to results.body.data.data, and the trigger's test result output tree.](https://mintcdn.com/firstresonance/KEx9PuouRGpnHjVh/images/automate-with-ion/workflow-builder/reference-panel.png?fit=max\&auto=format\&n=KEx9PuouRGpnHjVh\&q=85\&s=7286416a1d299065a20509bf3b9fa7f1)

The Reference panel with the trigger selected and the test run's output tree expanded.

The tree shows the earlier step's output from your latest test run. If the panel shows **No Data**, that step hasn't run in a test yet. Run the flow with your saved payload, then open the panel again.

## Pass variables to Run GraphQL Query

The **GraphQL Variables** field of **Run GraphQL Query** takes one reference to an object. The object's keys must match the variables the query declares. For example, a query that declares `$part_inventory_id` can reference the trigger's `results.body.data.data` object, which has a `part_inventory_id` key.

ION rejects variables that aren't an object. To send a single value, such as an ID, reference the object that contains it.

## Branch on a condition

Use the **Branch** component to send a run down different paths.

1. In **Workflow Builder**, click **+** under the step the branch follows, search for **Branch**, and select an action:
   * **If Condition is Met** chooses the next step based on one or more conditions.
   * **If Value Equals** chooses the next step based on a value.
2. For **If Condition is Met**, enter a name in **Condition**, such as "Needs aBOM". The name labels the condition's path on the canvas. A run that doesn't match takes the **Else** path.
3. Set the condition's first **Field**, its **Operator**, and its second **Field**. Reference a value from an earlier step, or type one in, such as `0`.
4. Optional: To add another check, click **Add a condition**. Select **And** to require every condition, or **Or** to require any one of them.
5. Run the flow with your saved payload, and click the branch step in **Run history**. Its **Output** names the path the run took.

![Flow canvas with an If Condition is Met branch splitting into Needs aBOM and Else paths, beside its condition settings with And, Or, Field, and Operator.](https://mintcdn.com/firstresonance/KEx9PuouRGpnHjVh/images/automate-with-ion/workflow-builder/branch-condition.png?fit=max\&auto=format\&n=KEx9PuouRGpnHjVh\&q=85\&s=f4897e68a1d2c93726f037a89c6fc63f)

An If Condition is Met branch with a Needs aBOM path and an Else path, and its first condition.

> [!TIP]
>
> To check that a value exists, such as the ID of a related record, reference that value and select the **exists** operator.

To test a step under one path, use a saved payload that takes that path.


## Related topics

- [Run a step](https://docs.firstresonance.io/build-hardware/runs-and-execution/step-execution.md)
- [RunStepBuildRequirement](https://docs.firstresonance.io/api-reference/types/RunStepBuildRequirement.md)
- [runStepBuildRequirements](https://docs.firstresonance.io/api-reference/queries/runStepBuildRequirements.md)
- [RunStepBuildRequirementSubstitute](https://docs.firstresonance.io/api-reference/types/RunStepBuildRequirementSubstitute.md)
- [UpdateRunStepBuildRequirement](https://docs.firstresonance.io/api-reference/types/UpdateRunStepBuildRequirement.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.