FlowTruxFlowTrux/Docs
Docsworkflows

Template Variables

How to use Handlebars-style template variables to pass data between nodes in FlowTrux workflows.

FlowTrux uses Handlebars-style template syntax to reference data from previous nodes, trigger input, global context, and loop iteration state. Templates can be used in most node configuration fields.

Syntax

Templates are enclosed in double curly braces:

{{steps.nodeId.output.field}}

Available Contexts

ContextSyntaxDescription
Trigger Data{{trigger.data}}The input data provided when the workflow started
Trigger Query{{trigger.data._query}}URL query parameters (webhook triggers only)
Node Output{{steps.nodeId.output}}The full output object of a previously executed node
Node Field{{steps.nodeId.output.field}}A specific field from a node's output
Nested Field{{steps.nodeId.output.data.items[0].name}}Nested property or array index access
Global Context{{global.key}}A value from the workspace-scoped persistent key-value store
Loop Item{{item}}The current element during loop iteration
Loop Index{{index}}The current iteration index (0-based) during loop iteration

Type Preservation

Template resolution behaves differently depending on how the template is used within a value.

Whole-value templates preserve types

When the entire value is a single template expression, the resolved type is preserved. Arrays remain arrays, objects remain objects, numbers remain numbers.

{
  "items": "{{steps.fetch.output.data}}"
}

If steps.fetch.output.data is an array like ["a", "b", "c"], the result is the array itself, not a string.

Inline templates produce strings

When a template appears as part of a larger string, the result is always a string created by interpolation.

{
  "message": "Found {{steps.fetch.output.count}} items"
}

If steps.fetch.output.count is 42, the result is the string "Found 42 items".

Usage in MCP Parameters

Templates inside MCP tool parameter JSON are resolved before the tool is called. This means complex types pass through correctly.

{
  "symbols": "{{steps.action-1.output.tickers}}"
}

If tickers resolved to ["AAPL", "TSLA"], the MCP tool receives the actual array, not a string representation.

Common Patterns

Pass trigger data to an agent prompt

Summarize the following text: {{trigger.data.content}}

Chain node outputs

Use the output of one node as input to the next:

{{steps.agent-1.output.response}}

Access nested API response data

After an HTTP action that fetches JSON:

{{steps.http-1.output.data.results[0].title}}

Use global context for persistent configuration

API endpoint: {{global.apiBaseUrl}}/{{global.version}}/resources

Loop iteration with item and index

Inside a Loop body, reference the current element:

{
  "text": "Item #{{index}}: {{item.name}} - {{item.status}}"
}

Conditional check on previous output

In an If-Else condition field:

{{steps.http-1.output.status}} === 200

Combine multiple node outputs

Research: {{steps.researcher.output.response}}
Analysis: {{steps.analyst.output.response}}

JavaScript Expressions

Certain nodes evaluate JavaScript expressions rather than simple templates:

  • If-Else / Switch conditions -- evaluated as boolean expressions
  • Transform actions -- arbitrary JavaScript for data reshaping
  • Filter / Reduce aggregators -- array processing expressions

All JavaScript expressions run in a sandboxed environment with a 3-second timeout. The sandbox has no access to process, fetch, require, or any external APIs. Only the data context (previous node outputs, trigger data) is available within the expression.

Variable Picker

Every template-capable field has a { } button that opens the Variable Picker:

  1. Click the { } button (or type {{ to trigger autocomplete)
  2. Browse available variables grouped by: Steps (upstream node outputs), Trigger data, Global variables, Loop variables
  3. Select a variable to insert it at the cursor position

Preview Values

If the workflow has been executed before, the picker shows preview values from the last run next to each variable - so you can see the actual data structure before inserting.

Autocomplete

As you type inside {{...}}, the autocomplete narrows suggestions by matching against variable names. Use arrow keys to navigate and Enter/Tab to select.

Validation Warnings

Template fields show visual feedback:

  • Amber warning triangle - appears when a {{variable}} references a node that doesn't exist upstream. Hover to see which variables are invalid.
  • Red border - on JSON fields, indicates invalid JSON syntax.

Visual Condition Builder

For If-Else logic nodes, you can use the Visual Condition Builder instead of writing JavaScript:

  1. Select the logic node and go to the Condition section
  2. Toggle between Builder and Code mode
  3. In Builder mode, add rules: pick a variable, choose an operator (equals, contains, greater than, etc.), enter a value
  4. Rules are connected with AND or OR (click the connector to toggle)
  5. The builder automatically generates the equivalent JavaScript expression

When switching from Code to Builder, the platform attempts to parse your existing expression into visual rules. Complex expressions (mixed AND/OR, nested parentheses) stay in Code mode.