We earn commissions when you shop through the links below.
If you’ve been looking for a powerful, self-hostable alternative to tools like Make or Zapier, n8n deserves your full attention. Knowing how to use n8n to automate your workflow gives you a level of flexibility and control that most SaaS automation tools simply can’t match — and it’s free to self-host. In this guide, I’ll walk you through everything from installation to building real automation flows with actual code examples.
What Is n8n?
n8n (pronounced “n-eight-n”) is an open-source, node-based workflow automation tool. Think of it as a visual programming environment where you connect services, APIs, and logic blocks together to automate repetitive tasks. Unlike purely cloud-based tools, n8n can run entirely on your own infrastructure, which means your data stays with you.
It supports over 400 integrations out of the box — Slack, GitHub, PostgreSQL, Google Sheets, HTTP requests, webhooks, and more. And when a native integration doesn’t exist, you can write custom JavaScript directly inside a node.
Setting Up n8n
You have three main options for running n8n:
- n8n Cloud — Managed hosting from the n8n team. Easiest to start, but costs money.
- Self-hosted via Docker — The most popular option for developers. Full control, zero lock-in.
- Railway or similar PaaS — Deploy with one click on platforms like Railway, which makes self-hosting nearly as easy as a managed service.
Here’s the fastest way to get n8n running locally with Docker:
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
Once the container starts, open http://localhost:5678 in your browser. You’ll be prompted to create an owner account, and then you’re inside the n8n editor.
For a persistent production setup with a proper database, use Docker Compose:
version: '3.8'
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=yourpassword
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=dbpassword
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
postgres:
image: postgres:15
restart: always
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=dbpassword
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
n8n_data:
postgres_data:
If you want to host this on a VPS, DigitalOcean Droplets are a solid choice — a $6/month droplet handles n8n comfortably for personal or small team use.
Understanding the n8n Interface
Before building your first workflow, get familiar with these core concepts:
- Workflow — A canvas where you connect nodes together.
- Node — A single unit of work. Could be a trigger (webhook, cron schedule) or an action (send email, query database, call API).
- Trigger Node — Every workflow starts with one. It defines what kicks off the automation.
- Connections — The arrows between nodes that pass data from one step to the next.
- Expressions — n8n’s templating syntax for referencing data from previous nodes, like
{{ $json.email }}.
Building Your First Workflow
Let’s build something practical: a webhook that receives form submissions and posts them to a Slack channel.
Step 1: Add a Webhook Trigger node
Click the “+” button on the canvas, search for “Webhook”, and add it. Set the HTTP method to POST. n8n will generate a unique URL like https://your-n8n-instance.com/webhook/abc123. Copy that URL — it’s where you’ll send data.
Step 2: Add a Slack node
Click the “+” after the webhook node, search for “Slack”, and add a “Send a Message” action. Connect your Slack credentials (OAuth2 or Bot Token), choose your channel, and set the message text using an expression:
New submission from {{ $json.body.name }}!
Email: {{ $json.body.email }}
Message: {{ $json.body.message }}
Step 3: Activate and test
Toggle the workflow to Active, then send a test POST request:
curl -X POST https://your-n8n-instance.com/webhook/abc123 \
-H "Content-Type: application/json" \
-d '{"name": "Jane Doe", "email": "jane@example.com", "message": "Hello!"}'
You should see the message appear in Slack within seconds. That’s the core loop of how to use n8n to automate your workflow — trigger, process, act.
Using the Code Node for Custom Logic
One of n8n’s biggest strengths over no-code-only tools is the Code node. You can drop raw JavaScript (or Python) anywhere in your workflow. Here’s an example that transforms incoming data before passing it downstream:
// Code node: transform items
const results = [];
for (const item of $input.all()) {
const raw = item.json;
results.push({
json: {
fullName: `${raw.firstName} ${raw.lastName}`,
emailLower: raw.email.toLowerCase(),
signupDate: new Date().toISOString(),
isPremium: raw.plan === 'pro' || raw.plan === 'enterprise',
}
});
}
return results;
This is where n8n really separates itself from drag-and-drop-only tools. You’re not stuck waiting for a native integration to support a specific field transformation — just write the logic yourself.
Common Automation Patterns
Here are workflows I’ve built that demonstrate how to use n8n to automate your workflow across different use cases:
1. Scheduled Database Cleanup
Use a Cron trigger → PostgreSQL node to delete records older than 90 days every night at midnight. No cron job to manage on the server, just a workflow.
2. GitHub Issue Notifications
Webhook from GitHub → IF node (filter by label) → Slack or email notification. Only pages your team when a bug-labeled issue is opened, not every PR comment.
3. Lead Enrichment Pipeline
Webhook receives new lead → HTTP Request to a data enrichment API → update a CRM via their API → log to a Google Sheet. All in one workflow, triggered automatically.
4. AI-Powered Content Processing
Pull RSS feeds on a schedule → send article content to OpenAI → save summaries to a Notion database. Great for building internal research digests.
Tips for Working With n8n in Production
Use environment variables for credentials. Don’t hardcode API keys. n8n’s credential store encrypts secrets, but using environment variables in the Docker config adds another layer.
Enable error workflows. In Settings, you can assign a separate “Error Workflow” that triggers whenever any other workflow fails. Use this to send yourself an alert instead of silently dropping data.
Version control your workflows. Export workflows as JSON and commit them to a Git repo. n8n doesn’t have built-in Git integration for community edition, so this is manual — but worth doing.
Watch your memory on complex workflows. If you’re processing thousands of items in a single execution, use the Split In Batches node to avoid memory spikes.
n8n vs. Make: When to Use Which
I get this question a lot. Here’s my honest take:
- Use n8n when you need custom code, self-hosting, or you’re building complex multi-branch logic. It’s also significantly cheaper at scale.
- Use Make when you want a polished, managed experience with a lower setup ceiling and your team isn’t comfortable with infrastructure. Make’s visual builder is slightly more beginner-friendly.
Both tools are excellent. The choice usually comes down to whether you want control or convenience.
Final Thoughts
Understanding how to use n8n to automate your workflow is genuinely one of the highest-ROI skills you can add to your developer toolkit. The combination of visual workflow building, native integrations, and full code access makes it flexible enough to handle almost any automation task — from simple notifications to complex data pipelines.
Start with one repetitive task you do manually every week. Build a workflow for it. Once you see how much time you reclaim, you’ll keep going. The learning curve is shallow, but the ceiling is high.