Skip to main content

Core Concepts

Understand the fundamental building blocks of n8n workflows. This guide explains how nodes, workflows, triggers, credentials, and expressions work together to create powerful automations.

Workflows

A workflow is a collection of connected nodes that execute in a specific order to accomplish a task. Workflows are represented as JSON objects in n8n.

Workflow Structure

Based on the source code (packages/workflow/src/interfaces.ts), a workflow consists of:

Workflow Execution Modes

n8n supports several execution modes:

Manual

Triggered manually via the UI or API

Trigger

Activated by triggers (webhooks, schedules, polling)

Error

Executed when an error workflow is triggered

Webhook

Responds to incoming webhook requests

Example Workflow JSON

Nodes

A node is a single step in a workflow that performs a specific action. Nodes are the building blocks of automations.

Node Structure

From the source code, each node has:

Node Types

n8n has several categories of nodes:

1. Trigger Nodes

Trigger nodes start workflow execution:
Listens for incoming HTTP requests
Accessible at: https://your-domain.com/webhook/my-webhook

2. Action Nodes

Perform operations with services:

3. Core Nodes

Built-in utility nodes:

Code

Execute JavaScript or Python

HTTP Request

Make API calls to any service

Set

Transform and manipulate data

IF

Conditional routing

Switch

Multi-way branching

Merge

Combine data from multiple branches

Node Implementation

Nodes implement the INodeType interface (from packages/nodes-base/):

Connections

Connections define how data flows between nodes.

Connection Structure

Connection Types

  • main: Regular data flow (default)
  • ai_agent: AI agent connections
  • ai_tool: AI tool connections
  • ai_memory: AI memory connections
  • ai_document: AI document connections

Example Connections

The connections object is indexed by source node. To find parent nodes, use the mapConnectionsByDestination() utility from n8n-workflow.

Data Flow

Node Execution Data

Data passed between nodes follows this structure:

Processing Multiple Items

Nodes process items in batches:

Expressions

Expressions allow dynamic data access using the ={{ }} syntax.

Accessing Data

Expression Functions

Expressions use JavaScript syntax and have access to built-in functions from Luxon (dates), lodash (utilities), and standard JavaScript.

Credentials

Credentials store authentication information securely.

Credential Structure

Using Credentials in Nodes

Nodes declare credential requirements:

Accessing Credentials in Code

Common Credential Types

OAuth2

OAuth 2.0 authentication with automatic token refresh

API Key

Simple API key authentication

Basic Auth

Username and password authentication

Header Auth

Custom header authentication

Error Handling

Continue on Fail

Control error behavior at the node level:
When continueOnFail is true, errors are passed to the next node instead of stopping execution.

Error Workflows

Trigger a separate workflow on error:
  1. Create an error workflow with a “Error Trigger” node
  2. In your main workflow settings, select the error workflow
  3. Errors will trigger the error workflow with context:

Retry on Fail

Configure automatic retries:

Static Data

Persist data between workflow executions:
Static data is stored in the database and persists across workflow executions. Don’t store large amounts of data.

Execution Context

Nodes have access to execution context through this:

Best Practices

Error Handling

Always configure error handling for production workflows using continueOnFail or error workflows

Expressions

Use expressions for dynamic data instead of hardcoding values

Credentials

Never hardcode credentials in workflows - always use credential system

Testing

Test workflows manually before activating with real data

Documentation

Use node notes to document complex logic

Modularity

Break complex workflows into smaller, reusable workflows

Advanced Topics

Workflow Versioning

Workflows support versioning:

Pinned Data

Pin test data to nodes for consistent testing:

Sub-workflows

Call other workflows using the “Execute Workflow” node:

Learning Resources

Quick Start

Build your first workflow

Example Workflows

Browse 900+ templates

Node Reference

Documentation for all 400+ nodes

Community Forum

Ask questions and share workflows

This documentation is based on n8n version 2.9.0. Core concepts are stable, but specific node implementations may vary by version.