
n8n is a workflow automation tool that connects your apps, APIs, databases and AI models into processes that run on their own. You can use it as a hosted service (n8n Cloud) or run it on your own server, and it handles far more complex logic than Zapier-style tools: branching, loops, custom code and AI agents. To use it well you need three things: a sensible hosting setup, workflows built from small, testable parts, and a human approval step wherever AI output reaches a customer or a record.
This masterclass walks through each of those in order, with links to our deeper guides on every topic. It’s the same approach we use on client projects in our AI automation service.
What can you automate with n8n?
Start with work that is frequent, rule-based and currently done by hand. In B2B marketing and sales teams that usually means:
- Data entry and sync between the CRM, forms, billing and spreadsheets.
- Lead routing and qualification: enrich a new lead, score it, assign it, notify the right rep.
- Reporting: pull numbers from ad platforms, GA4 and the CRM into one weekly report.
- Support triage: classify incoming tickets and draft first replies.
- Content operations: turn one source (a webinar, a transcript) into drafts for several channels.
- Back-office work: invoice checks, onboarding checklists, access provisioning.
Traditional automation follows fixed if-this-then-that rules, which is perfect for predictable tasks. AI steps extend that to messy inputs such as emails, documents and free-text form answers. The best workflows combine both: deterministic steps for everything that can be rule-based, and an AI step only where judgment is needed.
Should you use n8n Cloud or self-host it?

| n8n Cloud | Self-hosted n8n | |
|---|---|---|
| Setup | Minutes; n8n runs the servers | You provision a server, database, proxy and backups |
| Maintenance | Updates and uptime handled for you | Your team patches, monitors and restores |
| Data location | On n8n’s infrastructure | On infrastructure you choose, including inside your own network |
| Scaling | Within your plan’s limits | As far as your servers go, using queue mode with workers |
| Best for | Teams without DevOps capacity, pilots, moderate volumes | Sensitive data, internal systems behind a firewall, high volumes |
Self-hosting gives you control over where data lives and lets n8n reach internal systems without exposing them to the internet. It doesn’t make you compliant with GDPR or HIPAA on its own; that still depends on how you run, secure and document it. Our n8n hosting guide compares AWS, DigitalOcean and n8n Cloud in detail.
What does a production self-hosted setup look like?
- A Linux server sized for your workload, with monitoring on CPU and memory.
- Docker Compose running two services: n8n and PostgreSQL. SQLite, the default database, is fine for testing but not for production volumes.
- Environment variables in a
.envfile, not in the compose file:N8N_HOST,WEBHOOK_URL,DB_TYPE=postgresdband the database connection settings. - A reverse proxy (Nginx, Caddy or Traefik) in front of n8n, handling HTTPS certificates.
- Persistent volumes for the n8n data directory and the database.
- Backups: scheduled
pg_dumpof the database plus the n8n data volume, copied off the server. Back up theN8N_ENCRYPTION_KEYtoo: without it, stored credentials can’t be decrypted after a restore. - Queue mode once volumes grow: Redis plus separate worker processes, so one heavy workflow doesn’t block the rest.
Then lock it down. Our security guide for self-hosted n8n covers authentication, network access and webhook protection.
What are the building blocks of an n8n workflow?
Triggers
Every workflow starts with a trigger: a schedule, an incoming webhook, an app event (a new CRM deal, a new form entry) or a manual run. Webhooks are the most flexible, because almost any system can call one.
Logic and data handling
If and Switch nodes route items down different branches. Merge, Loop Over Items and the Code node (JavaScript or Python) reshape data when it doesn’t arrive in the form the next system expects. Understanding that n8n passes lists of items from node to node, and runs most nodes once per item, is the single most useful thing to learn early.
The HTTP Request node
When there’s no pre-built integration, the HTTP Request node talks to any API with documentation. Most work comes down to three details:
- Authentication: usually a bearer token in the
Authorizationheader, or Basic auth (for example, WordPress application passwords). Store these as n8n credentials, never in the node itself. - The body: JSON for most APIs, multipart form data for file uploads.
- Binary data: when moving files (an image generated by an AI model into your CMS, say), download the file as binary first, then send it with the right
Content-TypeandContent-Dispositionheaders. Wrong headers are the usual cause of corrupted uploads and 400 errors.
Sub-workflows
Don’t build one giant workflow. Split processes into small sub-workflows that each do one job, and call them with the Execute Workflow node. They’re easier to test, reuse and debug, and a failure in one doesn’t hide inside a hundred-node canvas.
How do you keep n8n workflows from breaking silently?
Automations rarely fail loudly. An API changes, a token expires, and nothing happens for a week until someone notices the CRM is out of date. Build for that from day one:
- Retry on fail for nodes that call external APIs, with a sensible wait between attempts.
- An error workflow: set one per workflow, starting with the Error Trigger node, that posts the failed execution and its error to Slack or email.
- Validation before writing: check that required fields exist before updating a CRM record.
- Version control for production workflows. Our guide to managing n8n at scale with Git and CI/CD explains how.
For patterns that recover automatically, see building self-healing AI workflows in n8n.
How do you build AI agents in n8n?
n8n’s AI Agent node connects a language model (OpenAI, Anthropic, Google, or a local model through Ollama) to three things:
- Memory. Short-term memory keeps the last few turns of a conversation; long-term memory stores your documents in a vector store (Pinecone, Qdrant, Supabase or Postgres with pgvector) and retrieves the relevant passages for each question. That retrieval pattern (RAG) keeps answers grounded in your own data. Our guide to AI memory in n8n goes deeper.
- Tools. Nodes or sub-workflows the agent may call, such as a CRM lookup, a database query or an HTTP request. The model decides when to call which tool and with what inputs.
- A system prompt that defines the job, the limits and the output format.
Agent or router?
Fully autonomous agents that plan and call tools in loops are powerful, but slow, costly and hard to debug. For most business processes, a router pattern works better: one fast model call classifies the input (a sales enquiry, a support question, spam), and ordinary n8n branches handle each case with fixed logic. The AI makes one judgment; everything else stays predictable. Use full agents, or multi-agent setups, only where the task genuinely needs open-ended reasoning.
Why should a person approve AI output?
Because models still make confident mistakes. In everything we build, the agent writes to a review queue, and nothing reaches a customer or a CRM record until a person approves it. n8n supports this directly with “send and wait for approval” steps in Slack, email and other channels. You can relax the rule for low-risk steps later, deliberately. We explain the approach in human-in-the-loop AI automation.
What do marketing and CRM workflows look like in n8n?
Three patterns we build often:
- Lead qualification: a form submission triggers enrichment, an AI step scores fit and intent against your criteria, and the lead lands in the CRM with an owner and a summary, after review.
- CRM sync: n8n sits between the CRM, the email platform and billing, so a status change in one updates the others. This is where most data silos disappear.
- Weekly reporting: numbers from Google Ads, Meta, GA4 and the CRM are pulled into one report and posted to Slack every Monday.
For outbound email, n8n can handle lead validation, personalization drafts and reply classification, but deliverability depends on fundamentals: verified addresses, properly authenticated sending domains, modest volumes per inbox and honoring opt-outs. Our cold email infrastructure guide covers the setup.
How much does n8n automation cost?
Four cost lines, whichever route you take:
- Software: n8n Cloud is a subscription; the self-hosted community edition is free, with paid licenses for enterprise features.
- Infrastructure: for self-hosting, a server, a database and backups.
- AI usage: model API calls are billed per token by the provider, so a router pattern and short prompts matter.
- People: building, maintaining and fixing workflows. This is usually the largest line.
To judge the return, measure the process before you automate it (hours per week, error rate, response time) and again after. We quote builds on scope after a free audit. For a comparison with other tools, see n8n vs Activepieces vs Node-RED and n8n vs Zapier.
Where should you start?
- Pick one bottleneck: a frequent, rule-based task that someone does by hand every week.
- Define success: hours saved, errors avoided, or response time.
- Build a small pilot as modular sub-workflows, with error handling and a review step.
- Run it alongside the manual process for a couple of weeks and compare.
- Add AI only where judgment is needed, once the deterministic parts are stable.
- Document it so your team knows what runs, when, and how to stop it.
Whether you build in-house or with help depends on your team. Our posts on hiring a freelance n8n developer and choosing an n8n agency cover the trade-offs.
FAQ
Is n8n free?
The self-hosted community edition is free to use for your own business under n8n’s fair-code license. n8n Cloud and the enterprise features are paid. Either way, hosting, AI usage and maintenance cost money.
Is n8n better than LangChain for AI agents?
They solve different problems. n8n is a visual workflow tool with AI nodes built on LangChain concepts; LangChain is a code library for developers. For business workflows that connect AI to your CRM and other apps, n8n is usually faster to build and easier to maintain. We compare them in LangChain vs n8n.
Can n8n run AI models locally?
Yes. n8n can call a model running on your own hardware through Ollama, so data never leaves your network. See our guide to local LLMs with n8n.
Do I need a developer to use n8n?
Not for simple workflows. For self-hosting, custom API integrations and AI agents in production, someone comfortable with APIs, JSON and basic JavaScript makes a big difference.
If you have a process you’d like to take off your team’s plate, tell us about it.


