How to Use Variables Across Workflow Steps
What Are Workflow Variables
A workflow variable is a named value that exists for the duration of a single workflow run. When the workflow starts, variables are empty or populated with incoming trigger data. As each step executes, it can read existing variables and write new ones. By the time the workflow finishes, the variables hold the accumulated results of every step that ran.
Think of variables as a shared clipboard that all nodes in the workflow can read from and write to. A database lookup node might write a customer record to a variable, then an email node reads that variable to personalize the message, and a logging node reads it again to record the activity.
How Variables Flow Through a Workflow
Input Variables
When a workflow is triggered by a webhook, form submission, or scheduled event, the incoming data becomes the initial set of variables. A webhook trigger might provide fields like "email," "name," and "action." These are immediately available to the first node in the workflow and every node after it.
Output Variables
Each node can produce output that gets added to the variable pool. An AI command that analyzes a message might output "category" and "priority." A database query might output the full customer record. These outputs become new variables available to all downstream nodes.
Overwriting Variables
If two nodes write to the same variable name, the later one overwrites the earlier value. This is useful when you want to transform data, like running a raw address through a formatting step that outputs a cleaned version to the same variable name. Be careful with naming to avoid accidental overwrites.
Step-by-Step: Setting Up Variables
Before building, map out which nodes need which data. If your email node needs a customer name and order total, trace where those values come from. The customer name might come from the trigger, while the order total comes from a database lookup.
Use clear, descriptive names like "customerEmail," "orderTotal," or "aiCategory." Consistent naming makes the workflow easier to read and debug. Avoid generic names like "data1" or "value" that become confusing when you have dozens of variables.
In each node's settings, reference variables from earlier steps. An email node's "To" field would reference the "customerEmail" variable. The subject line might include the "orderID" variable. Most workflow builders let you insert variables using a placeholder syntax or dropdown selector.
When a node returns data, map its output fields to named variables. A database query node might return a full record, so you map "record.name" to "customerName" and "record.balance" to "accountBalance" for use in later steps.
Run the workflow with test data and inspect the variable values at each step. Most workflow builders show you the variable state at each node during a test run, making it easy to spot where a variable is missing or has the wrong value.
Common Variable Patterns
Passing Trigger Data Through the Entire Chain
The most basic pattern is a trigger that provides all the data the workflow needs. A form submission includes name, email, phone, and message. Every node in the chain can reference any of these fields without any additional configuration.
Enriching Data Step by Step
A more advanced pattern builds up data as the workflow runs. The trigger provides an email address. Step 2 looks up the customer record by email and writes the full profile to variables. Step 3 sends the profile to an AI for analysis and writes the AI output to new variables. Step 4 uses both the profile and AI analysis to decide which team to notify.
Using Variables in Conditions
Variables are what make conditional logic possible. A condition node checks the value of a variable, like "if aiPriority equals urgent," and branches accordingly. Without variables carrying data between steps, conditions would have nothing to evaluate.
Variables in AI-Powered Steps
When you include an AI command in your workflow, variables become especially powerful. You can construct the AI prompt using variables from earlier steps, giving the AI full context about the current situation. The AI's response then becomes a new variable that downstream steps can act on. For example, you might pass a customer message and their purchase history to an AI step, which outputs a recommended action that a condition node uses to route the workflow. See How to Add AI Decision-Making to Your Workflows for detailed examples.
Build workflows where every step has the data it needs. No coding, no manual data passing.
Get Started Free