TL;DR
- Self-host n8n in 2 minutes with Docker:
docker run -it --rm --name n8n -p 5678:5678 n8nio/n8n - Build your first workflow in 5 minutes: HTTP Request → OpenAI → Slack
- Use AI nodes (OpenAI/Anthropic) to automate tasks like summarizing support tickets
- Schedule workflows with cron triggers (e.g.,
0 9 * * *for daily 9 AM runs) - Secure credentials with environment variables (
.envfile)
## 1. Self-Hosting with Docker
1.1 Install Docker
If you don’t have Docker installed, run:
# Linux/macOS
curl -fsSL https://get.docker.com | sh
# Windows (PowerShell)
winget install Docker.DockerDesktop
1.2 Run n8n
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
Expected output:
n8n ready on 0.0.0.0, port 5678
Version: 1.40.0
Editor is now accessible via: http://localhost:5678
Gotchas:
- Port conflict? Change
-p 5678:5678to-p 5679:5678if port 5678 is in use. - Permission errors? Add
-e N8N_USER=nodeto run as non-root.
1.3 Persist Data
Add a volume to save workflows and credentials:
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
## 2. Your First Workflow
2.1 Access the Editor
Open http://localhost:5678 in your browser. You’ll see the visual workflow editor.
2.2 Create a "Hello World" Workflow
- Click + New Workflow.
- Drag an HTTP Request node from the left panel.
- Configure it:
- Method:
GET - URL:
https://api.github.com/users/n8n-io
- Method:
- Click Execute Node to test. You’ll see GitHub’s API response.
Expected output (truncated):
{
"login": "n8n-io",
"id": 45487711,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ1NDg3NzEx",
...
}
## 3. AI Agent Nodes (OpenAI/Anthropic)
3.1 Add an OpenAI Node
- Drag an OpenAI node into your workflow.
- Click Connect Account and enter your OpenAI API key (get one here).
- Configure the node:
- Resource:
Chat - Operation:
Create Chat Completion - Model:
gpt-4o-mini - Prompt:
Summarize this GitHub user data: {{ $json }}
- Resource:
3.2 Connect Nodes
- Connect the HTTP Request node’s output to the OpenAI node’s input.
- Execute the workflow. The OpenAI node will summarize the GitHub data.
Example output:
The GitHub user "n8n-io" is an organization account with ID 45487711. It was created to host the n8n project, an open-source workflow automation tool.
Gotchas:
- API limits? Use
gpt-4o-minifor cost savings. - Rate limits? Add a Wait node (e.g., 1 second delay) between requests.
## 4. HTTP Request and Webhook Nodes
4.1 HTTP Request Node
Use this to call any API. Example: Fetch weather data from OpenWeatherMap.
- Add an HTTP Request node.
- Configure:
- Method:
GET - URL:
https://api.openweathermap.org/data/2.5/weather?q=London&appid=YOUR_API_KEY - Query Parameters:
{ "q": "London", "appid": "YOUR_API_KEY" }
- Method:
4.2 Webhook Node
Trigger workflows via HTTP. Example: Slack slash command.
- Add a Webhook node.
- Configure:
- Path:
slack-command - HTTP Method:
POST
- Path:
- Click Webhook URLs to copy the URL (e.g.,
http://localhost:5678/webhook/slack-command). - Add a Slack node to send a response.
Test the webhook:
curl -X POST http://localhost:5678/webhook/slack-command \
-H "Content-Type: application/json" \
-d '{"text": "Hello from Slack!"}'
## 5. Scheduling and Cron Triggers
5.1 Add a Cron Trigger
- Drag a Cron node into your workflow.
- Configure:
- Trigger On:
Every Minute(or use cron syntax, e.g.,0 9 * * *for daily 9 AM).
- Trigger On:
- Connect it to an HTTP Request node to fetch data daily.
Example cron expressions:
| Expression | Meaning |
|---|---|
0 * * * * | Hourly |
0 9 * * * | Daily at 9 AM |
0 0 * * 0 | Weekly (Sunday midnight) |
5.2 Manual Triggers
Use the Manual Trigger node to run workflows on demand.
## 6. Environment Variables and Credentials
6.1 Use .env File
Create a .env file:
echo "N8N_BASIC_AUTH_USER=admin" >> .env
echo "N8N_BASIC_AUTH_PASSWORD=securepassword" >> .env
echo "OPENAI_API_KEY=sk-your-key" >> .env
Restart n8n with the .env file:
docker run -it --rm \
--name n8n \
-p 5678:5678 \
--env-file .env \
n8nio/n8n
6.2 Secure Credentials
- In the n8n editor, go to Credentials → Add Credential.
- Select OpenAI and enter your API key.
- Use the credential in any OpenAI node (no need to hardcode keys).
Gotchas:
- Never commit
.envto Git! Add it to.gitignore. - Rotate keys regularly (e.g., every 90 days).
## 7. Production Tips and Backups
7.1 Use PostgreSQL (Not SQLite)
For production, replace SQLite with PostgreSQL:
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-e DB_TYPE=postgresdb \
-e DB_POSTGRESDB_DATABASE=n8n \
-e DB_POSTGRESDB_HOST=postgres \
-e DB_POSTGRESDB_PORT=5432 \
-e DB_POSTGRESDB_USER=n8n \
-e DB_POSTGRESDB_PASSWORD=securepassword \
n8nio/n8n
7.2 Enable HTTPS
Use a reverse proxy like Nginx or Caddy:
# Caddy example
echo "localhost:5678 {
reverse_proxy n8n:5678
}" > Caddyfile
docker run -d --name caddy -p 80:80 -p 443:443 -v $(pwd)/Caddyfile:/etc/caddy/Caddyfile caddy
7.3 Backup Workflows
Export workflows via the API:
curl http://localhost:5678/rest/workflows \
-H "Authorization: Bearer YOUR_API_KEY" \
-o workflows_backup.json
Restore workflows:
curl -X POST http://localhost:5678/rest/workflows \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d @workflows_backup.json
7.4 Monitor Workflows
- Use the Execution List in the n8n UI to debug failed workflows.
- Enable Error Workflows to send Slack alerts on failures.
## Alternatives to n8n
| Tool | Best For | Limitations |
|---|---|---|
| Zapier | Non-technical users | No self-hosting, expensive |
| Pipedream | Developers (code-based workflows) | Fewer pre-built integrations |
## What's Next?
- Build a real workflow: Automate a task like summarizing Slack messages with OpenAI.
- Deploy to production: Use Kubernetes or n8n.cloud for scalability.
- Explore AI features: Try n8n’s AI workflow generator (beta).
Need help scaling AI workflows? Hyperion Consulting specializes in AI tools and automation for enterprises. Visit hyperion-consulting.io to learn more.
