...

/

Dynamic Workflows with Expressions

Dynamic Workflows with Expressions

Learn how to make workflows dynamic using n8n’s powerful expression system.

In our last lesson, we transformed our Triage Agent from a manual script into an autonomous service. It can now run in real time, triggering the moment a new issue is created in GitHub. This is a solid foundation, but if you look at the Slack message it sends, it’s just a generic ping: “New GitHub Issue Detected.”

The GitHub Trigger provides a rich JSON payload full of valuable context about the issue, including its title, the author’s username, and any labels. Our workflow is currently ignoring all of it.

In this lesson, we will make our agent context-aware. You will learn to use expressions to access and embed data from previous nodes. By the end, we will have transformed our static Slack alerts into dynamic, informative messages that tell the team exactly what they need to know.

An introduction to expressions

To make our workflow dynamic, we need a way to reference data that changes with each execution. n8n provides a powerful system for this called expressions.

Expressions in n8n are based on JavaScript code, enclosed in double curly braces {{ }}, that you can use inside any node parameter. They utilize a templating language called “Tournament,” enhanced with custom methods, variables, and data transformation functions specifically designed to streamline tasks like accessing data from other nodes and workflow metadata.

For a developer, the concept is immediately familiar. It’s like using template literals or string interpolation in languages like JavaScript (${variable}) or Python (f"{variable}"). It is a clean and effective way to embed live, changing data within a static structure.

Accessing data with $json and dot notation

Now that we are familiar the {{ }} syntax, let’s look at how to navigate the data structure of a previous node to get the exact value we need.

When a node executes, it receives an array of items from the previous node. Each item typically contains a JSON object. To simplify accessing this data within an expression, n8n provides a special variable: $json.

The $json variable is a convenient shorthand for $input.item.json. It represents the ...