Set Variable Node

The Set Variable node captures a value, gives it a name, and remembers it for the rest of the workflow — all while passing the original input straight through. It's a transparent "remember this" step you can drop anywhere in a flow.

Overview

As workflows grow, you often need a value from early on — an id, a threshold, a token from a response — many steps later. Rather than threading it through every node in between, capture it once with a Set Variable node and reference it by name wherever you need it.

  • Capture an id at the start and reuse it at the end without re-wiring
  • Store a threshold once and compare against it in several places
  • Hold a token from an upstream response for later calls
  • Pin a computed value so downstream nodes share the same number

How It Works

The node takes two settings:

  • Variable name — the name you'll reference the value by
  • Value expression (optional) — JavaScript over input that computes the value to store. Leave it blank to store the whole incoming input.

When the node runs, it evaluates the expression, remembers the result under your chosen name, and then passes the original input through to the next node unchanged. It adds a remembered value — it does not replace the data flowing through.

{ "user": { "id": 42 }, "amount": 1500 }
        │
   Set Variable
   name:  threshold
   value: input.amount
        │
{ "user": { "id": 42 }, "amount": 1500 }   ← input still flows on
   (and "threshold" = 1500 is now remembered)

Writing the Value Expression

The value expression is JavaScript evaluated against the incoming data, in the same safe sandbox used elsewhere in the flow.

// Store a single field
input.amount

// Compute something
input.price * input.quantity

// Pull a nested value
input.response.data.token

// Store the whole input (or just leave the expression blank)
input

It supports the same references available elsewhere:

// Environment variables
'{{env.DEFAULT_REGION}}'

// Another node's output, by name
{{node['Lookup'].customerId}}

// An earlier workflow variable
vars['baseThreshold'] * 2

Using the Value Later

After the node runs, the captured value is available two ways:

1. By the node's name — like any other node's output:

{{node['Threshold'].value}}

2. As a workflow variable — available everywhere:

// In any text field
{{vars['threshold']}}

// Inside Code and Condition / Switch expressions
vars['threshold']

This means a value you set early can be used in a prompt, a Condition, a Switch case, or a Code node much later in the flow — without connecting a long chain of nodes to carry it.

Common Patterns

Capture Early, Use Late

Start → Set Variable (orderId = input.id) → … many steps … → Action
                                                              uses {{vars['orderId']}}

Store a Threshold to Branch On

Set Variable (threshold = input.limit)
        │
     Switch
       ─ [over]  input.amount > vars['threshold']
       ─ [under] true

Hold a Token from a Response

Login request → Set Variable (token = input.response.accessToken)
                        │
                Later API call → header: Bearer {{vars['token']}}

Best Practices

  1. Name for meaning — use names like threshold or customerId so references read clearly later.
  2. Capture once — set a value at the point it's first known, then reference it everywhere downstream.
  3. Leave the expression blank to store everything — useful for snapshotting the whole input before later steps reshape it.
  4. Remember input passes through — the node adds a value, it doesn't change the data flowing on, so it's safe to insert mid-flow.
  5. Reference, don't re-wire — reach a stored value with {{vars['name']}} instead of connecting a node back across the canvas.

Related Topics