Chapter 2: Foundations of n8n: Nodes, Architecture, and Data Types¶
Video: Watch this chapter on YouTube (4:50)
Overview¶
This chapter covers the essential building blocks of n8n, explaining how nodes work, the architecture of AI agents, workflow execution logic, input/output handling, expressions, and data types. Understanding these fundamentals is crucial for building effective automations.
Detailed Summary¶
What is n8n?¶
n8n stands for "Notemation" and is a free, open-source workflow automation tool. It functions as a universal connector that links different apps, services, and AI agents together without requiring extensive custom code. The core functionality happens through nodes, which are visual building blocks that can be chained together to create automated workflows.
Understanding Nodes¶
Nodes are the fundamental building blocks in n8n. There are two main types:
1. Trigger Nodes¶
- Start the workflow based on a defined trigger event
- Examples: new email arriving, webhook call, scheduled time
- Identified by a lightning icon in the interface
- Only have output data (no input data since they initiate the workflow)
2. Action Nodes¶
- Perform the actual work in the workflow
- Examples: send an email, interact with an LLM, call an API
- Have both input and output data
AI Agents in n8n¶
An AI agent within a workflow is triggered by an event or trigger node and has three essential elements:
1. LLM (Large Language Model)¶
- The "brain" that powers the agent
- Can be OpenAI, Claude, Llama, or any supported LLM
- Connected via API access tokens
2. Context Window Memory¶
- Gives the agent context of workflow interactions
- Maintains conversation continuity
- Differentiates between stateless and stateful responses
3. Tools¶
- External capabilities the agent can use to complete tasks
- Examples: Gmail, web scrapers, calculators
- Optional—agent decides when to use them based on instructions
Workflow Execution Logic¶
Sequential Execution (Default)¶
- Nodes run in order: trigger → node → node → finish
- If connected in a line, everything runs in order without skipping
- If one node fails, the workflow errors out
Branching Execution¶
- One input can trigger multiple paths
- Example: one branch posts to Slack, another goes to Gmail
- Each branch runs independently (sequentially, top to bottom)
Memory Types for AI Agents¶
1. Context Memory (Simple Memory)¶
- Short-term memory inside the AI's prompt
- Great for chat history and maintaining context
- Configurable context window length (e.g., remembers last 5 interactions)
Example without memory: - User: "Hello, my name is Mark" - AI: "Hello Mark, how can I assist you today?" - User: "What is my name?" - AI: "I don't have access to personal information..." (fails to remember)
Example with memory: - Same conversation, but AI correctly responds: "Your name is Mark"
2. Vector Database / RAG Memory¶
- Long-term searchable memory
- Documents stored as embeddings
- Agent retrieves only relevant information when answering
- Knowledge source outside of LLM's training data
- Used for scale and accuracy
Input and Output Data¶
Every node in n8n has:
Input Panel¶
- Shows payload data received from the previous node
- Example: chat message from a chat trigger node
Output Panel¶
- Shows the response or result of the node's processing
- Becomes the input for the next connected node
Data Representation Formats¶
Data in n8n can be viewed in three formats:
- Schema: Defined data structure, easy for drag-and-drop
- Table: Rows and columns format, handy for spreadsheets
- JSON: The underlying structured format, most flexible
Additional type: Binary for files and images
Fixed vs Expression Values¶
When configuring node fields, you can choose:
Fixed Values¶
- Static, hardcoded content
- Same value every workflow run
- Example:
please send an email(never changes)
Expressions¶
- Dynamic values pulled from earlier nodes
- Workflow adapts to real-time inputs
- Uses JavaScript expressions
- Can drag and drop variables from previous nodes
- Example:
{{ $json.chatInput }}(changes based on user input)
Data Types in n8n¶
n8n uses five main data types:
- Strings: Text values (e.g., "hello world")
- Numbers: Numeric values (e.g., 42, 3.14, -100)
- Booleans: True or false values
- Arrays: Lists of items (e.g., [1, 2, 3] or ["Alice", "Bob"])
- Objects: Structured data with key-value pairs, can be nested
- Accessed with dot paths in expressions (e.g.,
user.email)
Community Nodes¶
n8n supports community-built nodes that extend functionality beyond official integrations. If a built-in integration doesn't exist for your tool, the community likely has created one.
Workflow Execution Controls¶
Node Controls¶
- Execute Step: Run only this node without running the entire workflow
- Deactivate: Disable a node (workflow skips it during execution)
- Delete: Remove the node from the workflow
Pin Data Feature¶
- Pins output data to a node
- Prevents re-running API calls during development
- Saves API tokens and costs
- Useful for testing and iteration
Production vs Development¶
- Development Mode: Execute workflow manually, test executions marked with beaker icon
- Production Mode: Toggle "Activate Workflow" to run automatically
- Execution logs show all runs with timestamps and types
- "Copy to editor" feature allows importing production data for troubleshooting
Making Workflows Public¶
The chat trigger node includes a "Make chat publicly available" option that: - Generates a public URL - Allows external users to interact with the AI agent - Can include authentication options - Supports custom initial messages
Key Takeaways¶
-
Nodes are building blocks: Understanding trigger nodes (start workflows) and action nodes (do work) is fundamental to n8n.
-
AI agents need three elements: LLM for intelligence, memory for context, and tools for external actions.
-
Sequential execution is default: Workflows run top-to-bottom, and one failure stops everything unless you design around it.
-
Memory matters: Simple memory provides short-term context; vector databases provide long-term, searchable knowledge.
-
Data flows between nodes: Each node's output becomes the next node's input—this chaining is the essence of workflows.
-
Fixed vs Expressions: Use fixed values for constants, expressions for dynamic content from previous nodes.
-
Five data types: Strings, numbers, booleans, arrays, and objects cover all data handling needs.
-
Pin data saves resources: During development, pin API responses to avoid repeated calls and costs.
-
Production requires activation: Workflows only run automatically when toggled to active/production mode.
Conclusion¶
The foundations chapter provides essential knowledge for working with n8n effectively. Understanding nodes, data flow, memory types, and execution logic creates the groundwork for building sophisticated automations. The distinction between fixed and expression values is particularly important for creating dynamic, responsive workflows. With these fundamentals mastered, learners are prepared to build their first AI agent workflow, knowing how data moves through the system and how to configure each component for optimal performance.