Self-hosted vs n8n.cloud
n8n.cloud is managed hosting — no upgrades to babysit, but paid and your data flows through someone else's infra. Self-hosted (Docker) is free, full control over data (matters for PII in emails and CRM), but you handle upgrades and backups.
Minimal self-hosted launch:
docker volume create n8n_data
docker run -d --name n8n -p 5678:5678 \
-v n8n_data:/home/node/.n8n \
-e GENERIC_TIMEZONE="Europe/Kyiv" \
-e N8N_HOST="n8n.example.com" \
docker.n8n.io/n8nio/n8n
The UI opens at http://localhost:5678. Workflows and credentials live in the n8n_data volume — back it up.
Connecting AI providers
Credentials → New. n8n stores keys encrypted (encryption key in N8N_ENCRYPTION_KEY); they are not exposed in workflow exports.
- OpenAi credential —
API Key from platform.openai.com.
- Anthropic credential —
API Key from console.anthropic.com.
- Google Gemini (PaLM) API credential — key from Google AI Studio.
Set the key once in the credential and reuse it across all nodes. Never put the key in a URL or request body directly — only through a credential.
First workflow: HTTP Request → OpenAI → Slack
Node: Manual Trigger
└─> Node: HTTP Request
Method: POST
URL: https://api.openai.com/v1/chat/completions
Authentication: Predefined Credential Type
Credential Type: OpenAi
Body: JSON
JSON Body:
{
"model": "gpt-4o-mini",
"messages": [{ "role": "user", "content": "Give me an octopus fact" }]
}
└─> Node: Slack
Resource: Message
Operation: Send
Channel: #general
Text: ={{ $json.choices[0].message.content }}
The n8n data model: items and JSON
n8n passes an array of items between nodes. Each item is an object { json: {...}, binary: {...} }. A node runs once per item (unless configured otherwise).
{{ $json.field }} — a field of the current item.
{{ $node["HTTP Request"].json.choices[0].message.content }} — reaching into a specific node's output.
{{ $items() }} — all incoming items.
Understanding items is critical: if 10 emails come in, the AI node runs 10 times — this drives cost and rate limits. To collapse into one call, use an Aggregate or Code node before the AI node.
The most common beginner mistake is expecting a node to process "everything at once" when n8n iterates per item. Always check the item count in a node's preview.