I created a comprehensive crash course to help you build automations and AI agents using n8n, guiding you from an absolute beginner to a confident creator of full workflows. By the end, you’ll understand key concepts that allow you to build more advanced automations. This article breaks down the process step-by-step, explaining technical ideas in an accessible way while you follow along.
Getting Started with n8n: Cloud vs Self-Hosting
There are two main ways to use n8n. The quickest option is to use n8n Cloud, the cloud-hosted version. It requires no management of the application, making it ideal for beginners or those who want to get up and running fast. However, costs can add up if you have many active workflows running simultaneously.
The alternative is to self-host n8n, which offers virtually unlimited active workflows and executions, making it extremely cost-effective for high-volume usage. I found the easiest way to self-host is through railway.com, which provides a one-click template for n8n installation. Another great service is Elestio, which simplifies deployment with advanced management features—ideal for production environments or client projects.
If you’re just starting, you can either sign up for n8n Cloud or spin up an instance quickly using railway.com. There are minor differences between them. For example, n8n Cloud integrates more easily with Google accounts, while self-hosting grants access to a large community of nodes, expanding what you can do within n8n.
Building Your First Workflow in n8n
Workflows in n8n begin with a trigger, which starts the automation. I showed how to create a workflow by pressing Create workflow and facing a blank canvas. You can zoom in and out with control + mouse wheel or use the buttons provided.
Triggers can be many things: manual initiation, external app events like form submissions or new records in Airtable, scheduled intervals, webhook calls, chat messages, and more. I chose to start with the on form submission trigger, using a customer support form example. This form can collect inquiries, complaints, or requests from prospective customers.
To build the form, I added fields for name (text), email address (email with validation), issue type (dropdown list with options like technical issues, billing, collaborations, general inquiry), and a message (text area). All fields were required to ensure reliable data.
After saving the workflow, I tested the form, which popped up an actual n8n form interface. I submitted sample data and then examined the output panel, where n8n displays the data received from the form in multiple views: table, JSON, and schema. This output panel is very useful for verifying what data is flowing through your nodes.
Connecting to Google Sheets
Next, I connected the form to a Google Sheet to append new rows with the form submissions. I created a simple Google Sheet with columns matching the form fields: full name, email address, issue type, message, and submitted at.
To avoid filling out the form repeatedly when testing, I introduced the pin data feature. Pinning saves the last test data so that you can run tests repeatedly without re-entering information. This saves a lot of time during development.
Then, I added a Google Sheets node with the action to append row. Connecting to Google requires creating credentials, which is straightforward with OAuth2 for Google accounts. For self-hosted instances, additional setup in Google Cloud Console is needed to obtain client ID and secret.
Mapping data fields from the form to the Google Sheet uses JavaScript-like expressions. For example, $json["fullName"]
references the full name from the form submission. The interface shows green for successful mappings and red for errors, which helps prevent mistakes.
After mapping, I tested the step, confirming data was correctly appended to the sheet. Finally, I arranged the nodes neatly on the canvas, completing the basic form-to-Google Sheets automation.
Data Transformation in n8n
Data often needs formatting before use. For instance, the submitted at timestamp from the form was in a raw date format that isn’t user-friendly. I inserted a new node between the form trigger and Google Sheets to format this date.
Using the Date & Time node’s format date action, I dragged in the original date and specified the desired output format. This created a new field called formatted date.
Because the workflow now has an extra node, I updated the Google Sheets node’s field mapping to use the formatted date instead of the raw one. This required referencing the new node explicitly, not just the previous node, showing how data flows between nodes can be adjusted.
Testing the updated workflow confirmed the date appeared in the desired format in Google Sheets. This simple step demonstrated adding nodes mid-workflow and managing data references.
Routing Workflow Based on Form Input
Next, I showed how to direct workflow execution differently depending on form input using routing. For example, technical issues might go to the technical support team, while other inquiries go elsewhere.
Using a Switch node, I routed based on the issue type field. The switch checked if the issue type was “technical issues” or something else, creating two branches.
Sending Emails with Gmail
For the technical issues branch, I added a Gmail node to send an email to the support team. Setting up Gmail also uses OAuth2 credentials for secure access.
I crafted an email subject with static text plus the submitter’s email address. The message body included full details: full name, email, issue type, and the customer’s message.
To avoid the default “sent from n8n” attribution, I disabled the append editing attribution option in the email node.
Testing the email node showed a well-formatted email sent to the support address.
Handling Other Issue Types
For non-technical issues, I duplicated the email node and adjusted the subject line accordingly. Testing required unpinning the data and submitting a new form with a different issue type to activate this branch.
This simple routing illustrates how workflows can handle multiple paths based on input, making automations more dynamic and useful.
Integrating AI into Workflows for Spam Detection
Adding AI to workflows can provide powerful data processing capabilities. I demonstrated how to check if form messages are spam using OpenAI’s API.
First, I created a new sheet called spam to store suspected spam submissions separately. This way, spam messages don’t trigger emails but can still be reviewed to avoid false positives.
Connecting to OpenAI API
I added an OpenAI node to send the form message to the AI model and receive a spam rating. Setting up OpenAI credentials requires creating an OpenAI account (separate from ChatGPT), generating an API key, and entering it in n8n.
The prompt instructs the AI to determine if a message is spam and respond with a simple JSON object containing a spam rating of true or false.
Testing this node with a sample message showed the AI correctly classified the message as non-spam.
Routing Based on AI Spam Rating
Using an If node, I routed messages based on the spam rating. Non-spam messages continue to be appended to the main sheet and trigger emails, while spam messages are routed to the spam sheet without sending notifications.
Because the spam check node was moved earlier in the workflow, I updated the field mappings in the Google Sheets nodes to reference the correct nodes, avoiding mapping errors.
Testing with a spam-like message confirmed it was routed correctly to the spam sheet and no email was sent.
Adding Keyword-Based Spam Filtering
To reduce AI usage and catch obvious spam quickly, I added a keyword filter using a Regex match node before the AI check. This node checks for common spam words like “lottery” and routes matching messages directly to the spam sheet.
This convergent flow technique allows merging multiple routes into a single downstream path, avoiding duplicated nodes and simplifying workflow maintenance.
Testing with a message containing “lottery” showed it bypassed the AI check and was routed directly to the spam sheet.
Advanced AI with LLM Chains
I introduced LLM Chain nodes, which provide more flexibility than the specialized OpenAI node. You can connect various AI models such as Anthropic’s Claude, Google Gemini, or OpenRouter.
Setting up an LLM Chain requires creating credentials for the chosen AI service and defining prompts manually. I reused the spam detection prompt and added a structured output parser to ensure the AI returns JSON in the expected format.
Testing showed the LLM Chain correctly returned the spam rating. Swapping AI models becomes easy with this modular setup, allowing you to choose models based on cost or performance.
Debugging Workflows in n8n
Errors are inevitable when building workflows. I demonstrated some of n8n’s helpful debugging tools. When a node fails, you can view error details directly in the node output or ask the built-in assistant for solutions.
After fixing issues, you can retry executions either from the failing node or with the updated workflow. This avoids re-triggering earlier steps and prevents duplicate actions.
Another powerful feature is debug in editor, which imports execution data into the workflow editor and pins it automatically. This lets you test fixes with real data without re-running triggers.
Connecting External APIs with the HTTP Request Node
Many times, you need to integrate services that don’t have native n8n modules. The HTTP Request node lets you call any API directly.
I gave an example using file.ai, an AI image generation service. After creating an account and getting an API key, I configured the HTTP Request node to send POST requests with JSON payloads to generate images.
Authentication typically involves adding an Authorization
header with your API key, often prefixed by “Bearer” or “Key”. Each service has its own requirements.
Understanding HTTP verbs like GET, POST, DELETE, and PATCH helps determine how to interact with APIs—whether retrieving data, creating records, updating, or deleting.
Once you receive responses, you can pass URLs or other data into subsequent nodes like Google Sheets, Slack, or WordPress, extending your automation’s reach.
Creating AI Agents in n8n
A standout feature of n8n is its AI Agent node, which acts like an intelligent assistant that can maintain conversations, recall history, and call external tools.
I created a minimal agent by combining a chat trigger with the AI Agent node, connecting it to an OpenAI GPT-4o chat model. Enabling window buffer memory allowed the agent to remember the last 10 interactions, making conversations feel natural.
Testing showed the agent responding to greetings and recalling numbers I shared earlier, confirming that memory works as intended.
Adding External Tool Access to AI Agents
To expand the agent’s capabilities, I gave it access to the image generation tool using the HTTP Request node configured earlier. This involved adding the HTTP tool within the agent’s tool list and defining input placeholders and descriptions.
Now, when I ask the agent to generate an image, it calls the external API and returns the image URL right in the chat. This setup took just minutes and creates a powerful AI assistant capable of tool integration.
Customizing Agent Behavior with System Prompts
For more sophisticated agents, you can add system messages that define operating procedures, constraints, or instructions. This guides the agent on how to behave, what to do, and what to avoid.
Agents can be embedded on public websites with authentication controls, making them accessible while secure.
Using Multiple Workflow Triggers
n8n supports workflows with multiple triggers, a feature not common in many automation platforms. For example, the same workflow can be triggered by a chat message or a WhatsApp message.
I showed how to add multiple triggers and then merge their data flows using conditional statements that check which trigger was executed. This allows one workflow to handle diverse inputs cleanly.
This approach extends beyond AI agents. For instance, an article generation workflow can be triggered by Telegram commands, Airtable button clicks (via webhooks), or scheduled intervals. Managing multiple triggers improves workflow flexibility.
Looping and Data Flow in n8n
Handling multiple items is common in workflows, such as processing rows from a Google Sheet or data returned by an API.
n8n processes items behind the scenes, automatically looping through arrays without explicit loops in many cases. For example, reading three rows from a sheet results in three individual data items processed separately.
However, when dealing with arrays as a single item, you may need to use the Split Out Items node to separate them into individual items for processing. This is especially important when mapping data to Google Sheets, avoiding dumping entire arrays into single rows.
Incorporating AI Processing in Loops
To demonstrate looping with AI, I added a basic LLM Chain node that categorizes tasks based on their title. The split-out items node feeds individual tasks to the AI, which returns a category like video, blog post, or email.
The results are mapped back into Google Sheets, updating each row with the AI-generated category. This process runs for all items before proceeding, showing n8n’s ability to handle batch processing efficiently.
Using Loop Over Items Node for Rate Limiting and Control
While n8n handles many loops automatically, the Loop Over Items node offers control when you want to process items in batches or add delays between calls, useful for rate limiting APIs.
Setting the batch size to one processes items individually. Adding a Wait node inside the loop can pause execution between iterations, preventing API overload.
The loop node also provides error handling options, allowing workflows to continue or branch on errors during item processing. Additionally, enabling the Always Output Data option prevents premature workflow termination when no data is present.
Understanding Run Modes in Nodes
Some nodes can run once for all items or once per each item. For example, a code node can be set to run once per item, processing each data item separately, or run once for all items combined.
This affects how data is handled and whether you need to use a loop node beforehand. Understanding these modes helps build efficient workflows and avoid unexpected results.
Final Notes
Mastering n8n opens up many possibilities for automation and AI integration. Starting from simple form submissions to complex AI agents and multi-trigger workflows, this platform offers flexibility and power for creators at all levels.
Experimenting with these concepts by building and testing your own workflows is the best way to gain confidence. The features like pinning data, debugging tools, and modular AI chains make the learning curve manageable and enjoyable.
With these foundations, you can create automations that save time, reduce errors, and add intelligence to your processes.