Introduction
Welcome to another week of self-hosting various services in my homelab. This week, we’ll be exploring automation - specifically, how to connect and automate various services in our homelab.
That’s where n8n comes in - a powerful workflow automation tool that I’ve been using to create custom integrations between my services. What makes it special isn’t just its extensive list of integrations, but how it allows you to create complex workflows with a visual interface while still maintaining the flexibility of custom code when needed.
What is n8n?
n8n ↗️ is an open-source workflow automation tool that helps you connect different services and automate tasks between them. Think of it as a self-hosted alternative to Zapier or Make (formerly Integromat), but with more flexibility and control.
What really drew me to n8n was its comprehensive feature set:
- Visual workflow builder.
- 400+ built-in integrations.
- Custom JavaScript code nodes.
- Webhook support.
- REST API nodes.
- Error handling workflows.
- Conditional execution.
- Scheduling capabilities.
- Queue mode for reliability.
- Credential management.
- Version control for workflows.
- Self-hosted and fully controllable.
The project is open sourced with couple of paid features for Enterprise users. You can check out their GitHub repository ↗️ for more details.
Setup n8n
Once again, I am going to be using Docker to run n8n in my homelab, so let’s go through the setup process. First, create a new directory:
mkdir n8n && cd n8n
Here’s my docker-compose configuration:
services: n8n: image: docker.n8n.io/n8nio/n8n::latest container_name: n8n restart: unless-stopped ports: - '5678:5678' environment: - VUE_APP_URL_BASE_API=https://n8n.mydomain.com - N8N_EDITOR_BASE_URL=https://n8n.mydomain.com - WEBHOOK_URL=https://n8n.mydomain.com - GENERIC_TIMEZONE=Asia/Kolkata - N8N_ENCRYPTION_KEY=supersecret - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true volumes: - ./data:/home/node/.n8n - ./files:/files healthcheck: test: [ 'CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:5678/healthz', ] interval: 30s timeout: 5s retries: 3
Pro Tip
Generate a secure encryption key:
openssl rand -base64 32
This key is used to encrypt sensitive data like credentials in the database.
Create the necessary directories:
mkdir -p {data,files}
Now you can start n8n:
docker compose up -d
Enjoying the content? Support my work! 💝
Your support helps me create more high-quality technical content. Check out my support page to find various ways to contribute, including affiliate links for services I personally use and recommend.
How I am using n8n in my homelab
When I integrated paperless-ngx in my homelab, I wanted to explore automation for ingesting documents into the system.
N8N felt like the perfect tool for the job, so I started exploring and creating workflows for automating this process. Here are some actual workflows I’ve implemented in my homelab:
-
Inject Documents from Google Drive:
I have couple of documents in my Google Drive that I want to ingest and start processing in Paperless-ngx, so I created a workflow to do that.
Here’s how it looks like:
n8n workflow for Google Drive to Paperless-ngx -
Ingest Documents from GMail:
Apart from documents in Google Drive, there are couple of documents that I receive in my Email like monthly credit card bills, broker statements, etc.
So another workflow that I created is to ingest these documents when they are received in my Gmail into Paperless-ngx.
Here’s how it looks like:
n8n workflow for Gmail to Paperless-ngx
Workflows in detail
Let me know if you want to know more about how I created these workflows, I can write a separate post on that (let me know in the comments).
Features I Love
After using n8n for several weeks, here are some features that I find particularly useful:
-
Visual Workflow Builder: The ability to see and design workflows visually makes it easy to understand complex automations.
-
Custom Code Nodes: When built-in nodes aren’t enough, I can write custom JavaScript code to handle specific needs.
-
Integrations: The sheer number of integrations available is impressive, and the ability to create custom integrations is a huge plus.
Overall, n8n is still a new piece of software that I have recently added to my arsenal of self hosted tools, but if you are looking for a powerful automation tool for your homelab, I would recommend giving it a try.
Conclusion
n8n is yet another tool that I have added to my homelab. It automates repetitive tasks, ensures services work together smoothly, and alerts me when things go wrong.
Do you use n8n in your homelab? What are your workflows? Share your experiences in the comments below, or reach out to me on Twitter ↗️ / Reddit ↗️.
Happy automating!