N8N - Workflow Automation

No-code automation - BTS SIO SISR

Objective

Deploy the N8N platform to create automation workflows (API integration, data processing, notifications) with a visual no-code/low-code interface.

Prerequisites

What is N8N?

N8N (pronounced "n-eight-n") is an open-source workflow automation platform. An alternative to Zapier, Integromat (Make) or Microsoft Power Automate, it allows connecting services via "nodes" without writing code.

Use cases

Installation via Docker

Step 1: Install Docker

sudo apt update
sudo apt install docker.io docker-compose -y

# Enable Docker at boot
sudo systemctl enable docker
sudo systemctl start docker

# Verify
docker --version

Step 2: Launch N8N in simple mode

docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -v ~/.n8n:/home/node/.n8n \
 n8nio/n8n
Info: N8N will be accessible at http://server_ip:5678

Step 3: Installation with Docker Compose (production)

Create a working directory:

mkdir ~/n8n-docker
cd ~/n8n-docker

Create the docker-compose.yml file:

nano docker-compose.yml

Content:

version: '3.8'

services:
 n8n:
 image: n8nio/n8n:latest
 container_name: n8n
 restart: unless-stopped
 ports:
 - "5678:5678"
 environment:
 - N8N_BASIC_AUTH_ACTIVE=true
 - N8N_BASIC_AUTH_USER=admin
 - N8N_BASIC_AUTH_PASSWORD=SecurePassword123
 - N8N_HOST=192.168.1.100
 - N8N_PORT=5678
 - N8N_PROTOCOL=http
 - WEBHOOK_URL=http://192.168.1.100:5678/
 volumes:
 - ./n8n_data:/home/node/.n8n
Important: Replace 192.168.1.100 with your server's actual IP and SecurePassword123 with a strong password.

Step 4: Launch

# Start N8N
docker-compose up -d

# Check logs
docker-compose logs -f n8n

Access the Web Interface

  1. Open a browser
  2. Go to http://192.168.1.100:5678
  3. Log in with:
    • Username: admin
    • Password: SecurePassword123

Simple Workflow Example

Scenario: Discord notification on new GLPI user

Step 1: Create a new workflow

  1. Click "New Workflow"
  2. Give it a name: "GLPI → Discord"

Step 2: Add a Webhook trigger

  1. Click "+"
  2. Search for "Webhook"
  3. Select "Webhook"
  4. HTTP method: POST
  5. Path: /glpi-user
  6. Copy the generated URL (e.g. http://192.168.1.100:5678/webhook/glpi-user)

Step 3: Add a Discord action

  1. Click "+" after Webhook
  2. Search for "Discord"
  3. Select "Discord"
  4. Authentication: create a Discord webhook:
    • Discord → Channel settings → Integrations → Webhooks
    • Create a webhook, copy the URL
  5. Webhook URL: paste the Discord URL
  6. Message: use variables from the GLPI webhook
    New user created: {{ $json["name"] }} - Email: {{ $json["email"] }}

Step 4: Activate the workflow

  1. Click "Save"
  2. Toggle the "Active" switch in the top right

Step 5: Test

From a terminal:

curl -X POST http://192.168.1.100:5678/webhook/glpi-user \
 -H "Content-Type: application/json" \
 -d '{"name":"Jean Dupont","email":"[email protected]"}'

Verify the message is received on Discord.

Securing with HTTPS

With Nginx Reverse Proxy

sudo apt install nginx certbot python3-certbot-nginx -y

Create the file /etc/nginx/sites-available/n8n:

server {
 listen 80;
 server_name n8n.grp3.local;

 location / {
 proxy_pass http://localhost:5678;
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $scheme;
 
 # WebSocket support
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "upgrade";
 }
}
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

# SSL certificate Let's Encrypt
sudo certbot --nginx -d n8n.grp3.local

Modify docker-compose.yml:

 environment:
 - N8N_PROTOCOL=https
 - N8N_HOST=n8n.grp3.local
 - WEBHOOK_URL=https://n8n.grp3.local/
docker-compose down
docker-compose up -d

Useful Commands

Container management

# View real-time logs
docker-compose logs -f n8n

# Restart
docker-compose restart n8n

# Stop
docker-compose down

# Update N8N
docker-compose pull
docker-compose up -d

Workflow backup

# Workflows are stored in SQLite
sudo cp -r ~/n8n-docker/n8n_data ~/backup_n8n_$(date +%Y%m%d)

Popular Nodes

Key Points for the BTS Oral

BTS Limitation:
N8N presented here is configured in HTTP with Basic Auth. In production, enforce HTTPS + OAuth2/SAML authentication + network isolation.