Skip to main content

Variables and Expressions

Variables and expressions help an automation use the right value at the right time.

Think of them as smart placeholders. Instead of typing one fixed value into a workflow, you tell Automation Hub where to get the value from when the job runs.

Why This Matters​

Without variables, you may have to update the same value in many places.

For example, if the operations team email changes, you do not want to open 20 different jobs and edit each email step manually. You want to update the email once and let every job use the new value.

With variables, your automations become easier to reuse, easier to update, and less likely to break because of copied values.

The Basic Idea​

Fixed Value
You type the exact value into one step
Smart Placeholder
You write an expression like {{gv.OpsTeamEmail}} to tell Automation Hub where to find the value
Real Value
When the job runs, the placeholder becomes the real value
Simple: write the automation once, then let the right values fill in automatically.

Example:

Instead of typing this everywhereUse this expression
ops@example.com{{gv.OpsTeamEmail}}
Alice{{$('FindCustomer').result.name}}
12345{{trigger.payload.customerId}}

Where Values Can Come From​

There are three common places Automation Hub can get a value from.

Earlier Step
Use something the job already found, created, or calculated
Trigger Context
Use a value from the event that started the job (webhook body, schedule info, etc.)
Global Variable
Use a shared value stored once in Global Configurator for many jobs

1. Values From Earlier Steps​

Use this when one step finds information and a later step needs that information.

Example: Send a Customer Email​

FindCustomer
The job finds the customer's name and email address
WriteMessage
The message uses {{$('FindCustomer').result.name}} from the previous step
SendEmail
The email goes to {{$('FindCustomer').result.email}}

What the user writes in the message body:

Hello {{$('FindCustomer').result.name}}, your order is ready.

What the customer receives:

Hello Alice, your order is ready.

Use step references for customer names, ticket numbers, file names, totals, approval results, or anything created during the current run.

2. Values From the Trigger​

Use this when the job is started by a webhook, schedule, or external event, and you need data from that event.

Example: Process an Incoming Webhook​

Webhook Fires
An external system sends a payload with customer and order data
Read Trigger Data
Steps use {{trigger.payload.customerId}} to access the incoming data
Act on Data
The job processes the customer using the trigger values

The same job handles every incoming request without changes, because it reads the relevant data from whatever triggered it.

Use trigger values for customer IDs, order numbers, event types, request bodies, or any data sent by the system that started the job.

3. Global Variables (Saved Settings)​

note

Global variables are shared across all jobs in your environment. Updating a global variable immediately affects every job that references it, so review all dependent jobs before changing shared values like base URLs or team emails.

Use this when the same value is shared by many automations. Global variables are stored in Global Configurator and can be referenced by any job.

Example: Shared Team Email​

Save Once
Store the operations team email as OpsTeamEmail in Global Configurator
Use Often
Many jobs reference {{gv.OpsTeamEmail}}
Update Once
If the email changes, update it once in Global Configurator

Use global variables for team emails, standard folder paths, base URLs, environment names, API keys, and shared connection details. Encrypted variables (like passwords or API keys) are automatically decrypted at runtime.

Expression Syntax​

All expressions are wrapped in double curly braces: {{ }}. Here are the expression types you can use.

Step References​

Reference output from a previous step using the $() selector.

SyntaxDescription
{{$('stepId').result.fieldName}}Access a field from a step's output
{{$('stepId').result.nested.field}}Access a nested field
{{$('stepId').result.rows[0].name}}Access an item in an array

Examples:

{{$('FindCustomer').result.email}}
{{$('QueryDB').result.rows[0].name}}
{{$('GetOrder').result.items[2].price}}
{{$('CallAPI').result.response.status}}

Global Variables​

Reference shared settings stored in Global Configurator using the gv. prefix.

SyntaxDescription
{{gv.VariableName}}Access a global variable by name

Examples:

{{gv.OpsTeamEmail}}
{{gv.SlackChannel}}
{{gv.BaseAPIUrl}}
{{gv.DatabasePassword}}

Trigger Context​

Access data from the event that started the job using the trigger. prefix.

SyntaxDescription
{{trigger.payload.fieldName}}Access a field from the trigger payload
{{trigger.payload.nested.field}}Access nested trigger data

Examples:

{{trigger.payload.customerId}}
{{trigger.payload.order.total}}
{{trigger.payload.eventType}}

JavaScript Expressions​

Evaluate JavaScript inline for calculations, formatting, or logic.

SyntaxDescription
{{2 + 3}}Simple arithmetic
{{Math.round(5.7)}}Built-in JavaScript functions
{{$('step').result.total * 1.1}}Combine step data with calculations
{{value > 100 ? 'VIP' : 'STANDARD'}}Conditional (ternary) logic

Examples:

{{$('QueryDB').result.total * 1.1}}
{{$('GetOrder').result.quantity > 100 ? 'BULK' : 'STANDARD'}}
{{Math.round($('CalcStep').result.average * 100) / 100}}

JavaScript expressions run in a sandboxed engine with no access to the file system or network.

Mixed/Inline Expressions​

Embed one or more expressions within plain text. This is useful for building messages, subjects, or URLs dynamically.

Examples:

Hello {{$('FindCustomer').result.name}}, your order #{{$('GetOrder').result.orderId}} is ready.
Report for {{trigger.payload.month}} generated successfully. Sent to {{gv.OpsTeamEmail}}.
https://{{gv.BaseAPIUrl}}/customers/{{$('FindCustomer').result.customerId}}

Using Expressions in Practice​

Here are common scenarios showing how to use expressions with the correct syntax.

Send a personalized email​

FieldExpression
To{{$('FindCustomer').result.email}}
SubjectOrder #{{$('GetOrder').result.orderId}} - Confirmation
BodyHello {{$('FindCustomer').result.name}}, your order of {{$('GetOrder').result.quantity}} items has been confirmed.

Post a Slack notification with calculated values​

FieldExpression
Channel{{gv.SlackChannel}}
MessageDaily total: ${{$('SumSales').result.total}}. Tax estimate: ${{$('SumSales').result.total * 0.08}}.

Build an API call from trigger data​

FieldExpression
URLhttps://{{gv.BaseAPIUrl}}/customers/{{trigger.payload.customerId}}
HeaderBearer {{gv.APIToken}}

Conditionally set a value​

FieldExpression
Priority{{$('CheckOrder').result.amount > 1000 ? 'HIGH' : 'NORMAL'}}
Tier{{$('GetCustomer').result.totalSpend > 10000 ? 'VIP' : 'STANDARD'}}

How Automation Hub Fills the Values​

When a job runs, Automation Hub resolves every expression automatically:

Scan Fields
Looks for {{ }} patterns in all step configuration fields
Identify Type
Determines if the expression is a step reference, global variable, trigger context, or JavaScript
Fetch Data
Retrieves step results from the database, global variable values via API, or trigger context from the run
Evaluate
Runs the expression through a sandboxed JavaScript engine and replaces the placeholder with the actual value
Run Step
The step executes with all values resolved and ready to use
Types are preserved during resolution: numbers stay as numbers, booleans stay as booleans, and objects stay as objects. A step that returns a list will pass the actual list to the next step, not a string.

Where Expressions Can Be Used​

Expressions work in any step configuration field, including:

  • Recipient, subject, and body fields (email, Slack, Teams)
  • Query fields (database, API)
  • URL and header fields (API calls)
  • Condition fields (for conditional steps)
  • Loop configuration fields
  • File paths and folder names

Which One Should You Use?​

If the value is...Use thisSyntax example
Found by an earlier stepStep reference{{$('FindCustomer').result.email}}
Sent by the system that triggered the jobTrigger context{{trigger.payload.customerId}}
Shared by many jobs across your teamGlobal variable{{gv.OpsTeamEmail}}
Different between dev, test, and productionGlobal variable{{gv.EnvironmentName}}
A calculation based on other valuesJavaScript expression{{$('Step1').result.price * 1.1}}
A conditional choiceTernary expression{{$('Step1').result.qty > 100 ? 'BULK' : 'STANDARD'}}

Tips for Better Automations​

Use clear step names

  • Name steps like FindCustomer, CreateReport, or SendEmail
  • Clear names make expressions easier to read: {{$('FindCustomer').result.name}} is self-explanatory

Start with simple expressions

  • Begin with one or two dynamic values in a job
  • Add more only when the flow is easy to follow

Think about where the value lives

  • If a value comes from earlier in the run, use a step reference
  • If a value comes from the event that started the job, use a trigger context
  • If a value belongs to the whole team, use a global variable

Use global variables for secrets

  • Store API keys, passwords, and tokens as encrypted global variables
  • They are automatically decrypted at runtime and kept secure

Test with friendly sample data

tip

Use Test Mode to preview how expressions resolve before running the automation in production. This lets you catch typos, missing fields, and incorrect paths before they affect real data.

  • Use examples like Alice, April, or Finance
  • Confirm the final message, report, or notification looks right

Ask one question when unsure

  • "Where should this value come from?"

If the answer is "a previous step," use {{$('StepName').result.field}}. If the answer is "the trigger event," use {{trigger.payload.field}}. If the answer is "a shared team setting," use {{gv.VariableName}}.