Results-Driven n8n: The First Hub for Workflow Mastery
Welcome! This hub is your launchpad for mastering n8n. Understand workflow JSON, explore node configurations, discover best practices, and see advanced use cases to build faster and better automationsβall without needing to install anything.
Unlock the secrets of n8n JSON and build powerful workflows. PS: Your AI assistant is ready to help make them even smarter!
π Ready to Build Your Own n8n Nodes?
With our interactive builder, you get the .json
to simply copy and paste into n8n and have your node up and running instantly!
Our comprehensive Interactive Node Guide offers detailed explanations, JSON examples, parameter breakdowns, and even an interactive JSON builder for LangChain and Base nodes.
What is n8n?
n8n is an open-source workflow automation platform. Created in 2019 by Jan Oberhauser in Berlin, it enables the modelling of business processes and the integration and interaction of applications. It's designed to connect various services and APIs to automate repetitive tasks, saving time, money, and reducing human error.
How does n8n work?
Simple Execution, Complex Scenarios
n8n uses a visual, node-based interface. Each node represents an action or a service (e.g., read a file, send an email, query a database). You connect these nodes to create workflows that model complex processes.
For example, an n8n workflow could:
- Collect data from a data warehouse.
- Format this data into a report using a tool like Power BI (or directly within n8n).
- Email the report to stakeholders.
- Send a Slack notification to inform recipients.
With over 600 pre-defined community nodes and workflow templates available, getting started with common automation tasks is often straightforward.
Community Power & Extensibility
Workflows can be exported and imported using JSON format, allowing easy sharing and reuse of templates within the n8n community. This open-source nature fosters collaboration and accelerates learning.
Beyond its extensive catalog of 350+ direct integrations, n8n's βHTTP Requestβ node allows you to connect to virtually any application or service that offers an API, providing almost limitless integration possibilities.
In essence, n8n provides a powerful yet accessible platform for building sophisticated automations. While its visual interface is intuitive, a basic understanding of JavaScript can unlock even more advanced customizations and logic within your workflows.
What are the alternatives to n8n?
Popular alternatives include Zapier and IFTTT. Zapier, for instance, offers a vast number of app integrations and is often praised for its user interface, though it operates on a different pricing model.
How much does n8n cost? (The Best Part!)
n8n's core offering is a completely free and comprehensive self-hosted open-source version. This means you can install it on your own server (or even your local machine for development) and use its full feature set without any mandatory subscription fees. It's incredibly easy to get started with, and the power of the community continuously enhances it.
For those who prefer a managed solution or require enterprise-grade features, n8n also provides optional paid cloud-hosted plans. These typically start from around $20 per month and offer convenience, scalability, and additional support. However, it's crucial to understand that these are entirely optional; the self-hosted version provides the full core functionality for free.
Core Principles of n8n JSON
Zero Comments Tolerated!
0
A foundational rule: n8n workflow files demand strictly valid JSON. Any comments (like //
or /* ... */
) within the actual .json
file will cause the import to fail. Purity is paramount!
Commenting Your Workflow: Using Sticky Notes
While the raw JSON file of an n8n workflow cannot contain comments, n8n provides a user-friendly way to annotate your workflows directly within its visual interface: Sticky Notes.
Sticky Notes are like digital post-it notes that you can place anywhere on your workflow canvas. They are invaluable for:
- Explaining complex logic within a section of your workflow.
- Leaving reminders for yourself or collaborators.
- Documenting the purpose of specific nodes or groups of nodes.
- Providing context or instructions for using the workflow.
These notes are part of the n8n workflow's UI data but are not included in the core `nodes` or `connections` JSON that defines the execution logic, thus keeping your executable JSON clean.
Typically, you add a Sticky Note via a right-click menu or a toolbar option in the n8n UI.
Overall Workflow Structure
An n8n workflow JSON file has a few key top-level properties. Click on each key to learn more about its role. This structure is the blueprint of your entire automation.
Key Components of a Workflow File:
- name: Human-readable workflow title.
- nodes: (As above) Array of node definitions.
- connections: (As above) Object linking nodes.
- active: Boolean (true/false) for workflow status (usually `false` for new imports).
- settings: Workflow-specific configurations (e.g., error workflow, timezone).
- id: A unique identifier for the workflow itself.
- meta (Optional): Contains metadata like the workflow creator ID.
- tags (Optional): An array of tag strings associated with the workflow.
The Anatomy of a Node
Each node in the `nodes` array has several common fields that define its identity, appearance, and behavior. Hover over or tap the field names for a quick explanation.
Parameter Count in Example Nodes
The complexity of a node's `parameters` object can vary. This chart shows the number of top-level parameter keys for each node in the example workflow from the source document.
Deep Dive: Example Node Types & Parameters
Let's explore the specific nodes mentioned in the example workflow. Each tab provides details on the node's purpose, key parameters, and a representative JSON snippet based on the source document.
When chat message received (Chat Trigger)
Type: @n8n/n8n-nodes-langchain.chatTrigger
This node initiates the workflow when a chat message is received via a specific webhook URL.
Key Fields & Parameters:
- webhookId: Unique ID for the webhook endpoint. (e.g., "b7b3d6fd-...")
- parameters.public: (boolean) If true, the endpoint is publicly accessible. Example: `true`.
- parameters.options: Additional settings (empty `{}` in example).
Example JSON Snippet:
"type": "@n8n/n8n-nodes-langchain.chatTrigger", "webhookId": "b7b3d6fd-f8f8-4832-b2c5-82d6b58acfde", "parameters": { "public": true, "options": {} }
Prep Input Fields (Set Node)
Type: n8n-nodes-base.set
This node is used to create, modify, or organize data. In the example, it extracts specific fields from the incoming chat message body.
Key Parameters:
- parameters.assignments.assignments: An array of objects, each defining a new field and its value (often using expressions).
- Example assignment: `name: "query"`, `value: "={{ $json.body.query }}"`, `type: "string"`
- parameters.options: Additional settings for the Set node (empty `{}` in example).
Example JSON Snippet (Illustrative for one assignment):
"type": "n8n-nodes-base.set", "parameters": { "assignments": { "assignments": [ { "name": "query", "value": "={{ $json.body.query }}", "type": "string" } // ... other assignments ] }, "options": {} }
AI Agent (Example from JSON Guide)
Type: @n8n/n8n-nodes-langchain.agent
This node represents core AI logic, using a language model to process input and generate a response based on instructions. This specific example is from the general JSON structure guide.
Key Parameters:
- parameters.promptType: How the prompt is provided (e.g., `"define"` for direct input).
- parameters.text: The main prompt or system message for the agent. (A long string in the example, providing guidance on JSON structure).
- parameters.options: Additional agent configurations (empty `{}` in example).
Example JSON Snippet:
"type": "@n8n/n8n-nodes-langchain.agent", "parameters": { "promptType": "define", "text": "=Okay, I understand. You want the previous guide...", // Truncated for brevity "options": {} }
LM Studio Chat Model
Type: @n8n/n8n-nodes-langchain.lmChatOpenAi
This node configures and provides the connection to a specific language model, in this case, one hosted via LM Studio (OpenAI-compatible API).
Key Fields & Parameters:
- credentials.openAiApi: Links to the n8n credential for LM Studio (contains Base URL).
- Example: `id: "KVs7jziNjpp9jJus"`, `name: "LM Studio Local"`
- parameters.model.value: Identifier of the specific model from LM Studio. (e.g., `"lmstudio-community/gemma-3-12B-it-qat-GGUF"`)
- parameters.options: LLM generation parameters like temperature (empty `{}` in example, meaning defaults).
Example JSON Snippet:
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "credentials": { "openAiApi": { "id": "KVs7jziNjpp9jJus", "name": "LM Studio Local" } }, "parameters": { "model": { "value": "lmstudio-community/gemma-3-12B-it-qat-GGUF" }, "options": {} }
Prep Output Fields (Set Node)
Type: n8n-nodes-base.set
Another instance of the Set node, this one is used after the AI Agent to add a `success` field to the output data.
Key Parameters:
- parameters.assignments.assignments: Array defining fields to set.
- Example assignment: `name: "success"`, `value: "=true"`, `type: "boolean"`
Example JSON Snippet:
"type": "n8n-nodes-base.set", "parameters": { "assignments": { "assignments": [ { "name": "success", "value": "=true", "type": "boolean" } ] }, "options": {} }
Respond to Webhook
Type: n8n-nodes-base.respondToWebhook
This node sends the final data back as an HTTP response to the system that initially triggered the workflow.
Key Parameters:
- parameters.respondWith: Defines what data to send back (e.g., `"allIncomingItems"`).
- parameters.options.responseHeaders: Allows setting custom HTTP headers for the response.
- Example entry: `{ "name": "X-n8n-Signature" }`
Example JSON Snippet:
"type": "n8n-nodes-base.respondToWebhook", "parameters": { "respondWith": "allIncomingItems", "options": { "responseHeaders": { "entries": [ { "name": "X-n8n-Signature" } ] } } }
Understanding n8n AI Agents
For more sophisticated AI tasks, n8n offers various "Agents" (often via Langchain integration). Agents use an LLM to choose a sequence of actions using "Tools." These are distinct from the single "AI Agent" node shown in the JSON example section, which is a specific instance.
Tools/Functions Agent
LLM dynamically calls predefined tools/functions based on input.
SQL Agent
Converts natural language to SQL queries, executes, and interprets results.
ReAct Agent
Iterative: Thought β Action (tool) β Observation β Repeat for complex problem-solving.
Plan & Execute Agent
LLM first creates a multi-step plan, then executes each step for complex tasks.
Conversational Agent
Manages multi-turn dialogues, maintaining conversation history (memory) for context.
Advanced Use Case: RAG AI System with n8n
This section outlines a sophisticated Retrieval Augmented Generation (RAG) system built with n8n. It allows users to chat with an AI agent that can answer questions based on documents ingested from Google Drive or local files, supporting various formats and leveraging vector databases for intelligent retrieval.
Key Features of the RAG System
- Automated Document Ingestion from Google Drive & Local Files.
- Multi-File Type Support (PDF, DOCX, TXT, Excel, CSV).
- Data Cleaning (removes outdated versions upon update).
- Vectorization using local OpenAI-compatible embeddings (Nomic via LM Studio).
- Vector Storage in Supabase/Postgres with pgvector for semantic search.
- Tabular Data Handling: Stores structured data from Excel/CSVs in Postgres, queryable via AI-generated SQL.
- Metadata Storage for documents (ID, title, URL, schema for tabular data).
- RAG Agent (local Gemma model via LM Studio) equipped with tools:
- Semantic search over ingested documents.
- List available documents and their schemas.
- Retrieve full content of specific documents.
- Query tabular data using AI-generated SQL.
- Chat Interface via public webhook with session-based chat memory in Postgres.
Workflow Architecture (High-Level)
1. Database Setup
One-time manual setup of Postgres tables (documents
for vectors, document_metadata
, document_rows
for tabular data) and the pgvector
extension for similarity search.
2. Document Ingestion & Processing
Triggered by Google Drive changes or manual file uploads. Involves metadata setting, cleaning old data, file download, type-based routing (PDF, Excel, CSV, Text), text extraction/splitting, vectorization (Nomic via LM Studio), and storage in Supabase/Postgres.
3. Chat Interface & RAG Agent
Accepts messages via Chat Trigger/Webhook. Uses a local Gemma model (LM Studio), Postgres chat memory, and a suite of tools (Supabase Vector Store, List Docs, Get File Contents, Query Document Rows) to formulate and deliver responses.
Core Technologies Stack
Simplified RAG Data Flow
Docs (Drive/Local)
n8n Ingestion
(Extract, Vectorize)
Vector & Metadata DB
(Supabase/Postgres)
RAG AI Agent (n8n)
(Retrieve, Reason, Respond)
User Chat Interface
Advanced Considerations & Potential Improvements
- Error Handling & Resilience: Implement robust error handling (e.g., Error Trigger node, conditional logic for retries) for all critical steps like file processing, database operations, and AI model calls.
- Configuration Management: Abstract hardcoded values (like Google Drive Folder IDs, model names) using n8n environment variables or a "Workflow Static Data" node for easier updates and deployment.
- Chat Flow Optimization: The 1-minute Wait node in the chat response path should be critically reviewed or removed, as it dramatically slows down the user experience and may lead to timeouts. Asynchronous handling might be needed for long AI processing.
- Scalability: For local LM Studio setups, ensure the host machine has adequate CPU, RAM, and VRAM (if using GPU) to handle concurrent requests for embeddings and chat completions. Monitor database performance under load.
- Security: Adhere to the principle of least privilege for database users accessed by n8n. Be mindful of the capabilities given to AI-generated SQL tools.
This RAG system is a powerful example of n8n's capabilities. The original report contains more granular details on specific node configurations and potential optimizations.
Decoding Connections
The `connections` object maps out how data flows between nodes. It's a critical part of the workflow definition.
The structure for one connection from a source node's output port to a target node's input port is:
// "SourceNodeNameOrID": { "OutputPortName": [ // e.g., "main" or "ai_languageModel" [ // Inner array - CRUCIAL! This allows one output to connect to multiple inputs. { "node": "TargetNodeNameOrID", "type": "InputPortNameOnTarget", // e.g., "main" or "ai_languageModel" "index": 0 // Index of the input port on the target, usually 0. } // , { ... another target connection object for the same output port ... } ] ] // }
The key is the source node's name or IDUsing the node ID is generally more robust than using the name, especially if names are not unique or contain special characters.. Its value is an object where keys are the output port namesMost nodes have a default output port named 'main'. Specialized nodes, like AI or conditional nodes, might have other named output ports (e.g., 'ai_languageModel', 'true', 'false'). from that source node. Each output port maps to an array. This array MUST contain an inner arrayThis inner array is essential and a common point of error if missed. It's designed this way to allow a single output port to potentially connect to multiple different input ports on various target nodes.. This inner array holds one or more connection objects. Each object specifies the `node` (the name or ID of the target node), `type` (the name of the input port on that target node), and `index` (the specific slot of that input port, which is almost always `0` for standard inputs).
Mastering Expressions
n8n expressions allow you to dynamically use data from previous nodes in your parameters.
To access data from the directly preceding node's output itemThis is the most common way to get data from the node immediately connected.:
{{ $json.fieldName }}
To access data from any specific node's output itemUse the node's unique name (if unique and simple) or its ID for reliability. in the workflow (assuming it has executed):
{{ $('NodeNameOrID').item.json.fieldName }}
Key parts:
{{ ... }}
: Denotes an n8n expression.$json
: Refers to the main JSON data of the current item being processed by the current node.$('NodeNameOrID')
: References the output data of a specific node (identified by its name or, more reliably, its ID)..item
: Accesses the current item being processed (n8n often processes items one by one; this ensures you're getting data from the correct iteration if there are multiple items)..json
(after.item
): Accesses the main JSON data object of that specific node's item..fieldName
: The actual key of the data you want from within that JSON object.
Tip: Always run the preceding node and inspect its output in the n8n UI (JSON or Table view) to find the exact path and `fieldName` you need. This is the most reliable way to build correct expressions and avoid guesswork.
Example Workflow Logic (General JSON Structure)
The source document describes an example workflow for an AI-powered chat system (distinct from the RAG system above). Here's a simplified visual representation of its data flow. Click on a node name to jump to its detailed explanation in the "Node Deep Dive" section.
Summary of Logic:
- Workflow starts when a chat message is received via a webhook.
- Input fields (query, user_id, etc.) are extracted and prepared from the incoming message.
- The AI Agent (example from JSON guide) processes this input. It utilizes the configured LM Studio Chat Model and its own system prompt/instructions to generate a response.
- A `success: true` field is added to the output data, likely for status tracking.
- The final result, including the AI's response, is sent back as an HTTP response to the system that originally sent the chat message.
Key Takeaways & Best Practices
Remember these crucial points when working with n8n JSON, especially for AI-driven workflows:
Be Specific with AI
When prompting an AI for workflow JSON, detail node types, parameters, and `typeVersion`s. Precision yields better results.
Iterate & Test
Start simple, then add complexity. Test AI-generated JSON by importing it into n8n at each step.
Validate Relentlessly
Always copy generated JSON (removing illustrative comments) and import into n8n. Use n8n's error messages and JSON validators.
Credentials Matter
Ensure n8n credentials (e.g., for LM Studio) are correct with the right Base URL and API keys.
- Model Identifiers: Double-check that `model.value` in LLM nodes matches the exact model identifier in your LLM service.
- Expressions are Key: Use n8n expressions accurately. Verify data paths by inspecting previous node outputs.
- Node-Specific Parameters: For complex nodes, consult n8n documentation for all parameters. The UI panel is your first exploration point.
- Strictly Valid JSON: Remember, n8n workflow files must be pure JSON. No comments in the actual `.json` file!
π What's Next? Exciting Features Coming Soon!
We're constantly working to enhance your n8n experience on resultsfirst.ca. Here's a sneak peek at what we're brewing:
Workflow Wizards & Templates
Get started even faster with pre-built workflow templates and interactive wizards to guide you through common automation scenarios.
Smarter Connections Helper
Tools to help you debug connection issues more easily and perhaps even suggest common connection patterns based on your nodes.
Enhanced Sticky Notes
More formatting options, the ability to link notes to specific nodes, and perhaps even collaborative commenting features for your Sticky Notes.
Advanced Expression Assistant
An interactive helper to build and debug complex n8n expressions with real-time validation and output previews.
JSON Validator & Optimizer
An integrated tool to validate your n8n JSON and offer suggestions for optimizing its structure or performance.
Community Showcase
A place to share your innovative n8n workflows and discover solutions built by the ResultsFirst community.
Stay tuned for these and more updates designed to help you achieve your automation goals with n8n!