AI Tools #n8n#automation#AI workflow

n8n AI Workflow Automation Guide: Connect AI to Anything

Use n8n to build AI-powered automation workflows connecting ChatGPT, Claude, and local LLMs to apps, databases, and APIs.

7 min read

n8n is an open-source workflow automation platform that connects AI models to virtually any app, API, or database through a visual node-based editor. Think Zapier, but self-hostable, AI-native, and with the ability to build complex conditional logic without writing full applications. In 2026, n8n has become the hub for AI power users who want to automate tasks using LLMs without building custom API integrations from scratch.

Why n8n for AI Automation?

  • AI nodes built-in: Dedicated nodes for OpenAI, Anthropic (Claude), Hugging Face, and Ollama
  • Self-hostable: Run on your own VPS — no data leaving your infrastructure
  • Visual workflow builder: Connect nodes graphically; minimal coding required
  • 200+ integrations: Slack, Gmail, Notion, Google Sheets, databases, webhooks
  • Code nodes: When you need custom logic, drop into JavaScript or Python
  • Free self-hosted: Only pay for cloud hosting if using n8n Cloud

Installation

docker run -it --rm   --name n8n   -p 5678:5678   -v ~/.n8n:/home/node/.n8n   n8nio/n8n

Access at http://localhost:5678.

Docker Compose (Persistent)

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=your_secure_password
      - N8N_HOST=your-domain.com
      - WEBHOOK_URL=https://your-domain.com/
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
docker compose up -d

Core Concepts

Nodes: Individual steps in a workflow. Trigger nodes start the workflow; action nodes perform operations.

Workflow: A connected sequence of nodes that processes data from trigger to final output.

Expressions: Reference data from previous nodes using {{ $json.fieldName }} or {{ $node["NodeName"].json.fieldName }}.

Credentials: Stored API keys and auth configs — set once, reuse across workflows.

Building an AI Workflow: Email Summarizer

This workflow monitors a Gmail inbox, summarizes new emails with Claude, and sends summaries to Slack.

Step 1: Email Trigger

  1. Add Gmail Trigger node
  2. Configure OAuth2 credentials (follow n8n’s guide)
  3. Set: Trigger on “Email Received” → Filter by label if desired

Step 2: Claude AI Node

  1. Add Anthropic node after Gmail Trigger
  2. Set API credentials (your Anthropic API key)
  3. Model: claude-haiku-4-5 (fast, cheap for summarization)
  4. Prompt:
Summarize this email in 2-3 sentences, focusing on any action items required:

From: {{ $json.from.value[0].address }}
Subject: {{ $json.subject }}
Body: {{ $json.text }}

Respond with just the summary, no preamble.

Step 3: Slack Node

  1. Add Slack node
  2. Configure bot credentials
  3. Message:
📧 Email Summary
From: {{ $node["Gmail Trigger"].json.from.value[0].address }}
Subject: {{ $node["Gmail Trigger"].json.subject }}

{{ $node["Anthropic"].json.text }}

Step 4: Activate Workflow

Toggle the workflow to Active — it now runs automatically when new emails arrive.

AI Agent Nodes

n8n’s AI Agent node creates conversational agents that can call tools:

  1. Add AI Agent node
  2. Configure system prompt and model
  3. Add Tool nodes: Calculator, HTTP Request, Code, etc.
  4. The agent decides which tools to use based on input

Example: Research agent that searches the web, reads content, and synthesizes a report — triggered by a webhook and posting results to Notion.

Practical Workflow Ideas

Customer Support Triage

Trigger: New Zendesk ticket → Claude classifies as bug/feature request/billing/other → Route to appropriate Slack channel + auto-reply template.

Content Repurposing

Trigger: New blog post (via RSS) → Claude extracts key points → Generate 3 tweet variations + LinkedIn post → Post to Buffer schedule.

Database Q&A

Trigger: Slack message mentioning @databot → Claude converts natural language question to SQL → Execute query → Claude formats results → Reply in Slack thread.

SEO Content Monitoring

Trigger: Google Search Console webhook → Pages with declining impressions → Claude analyzes page content → Generate suggested improvements → Create Notion task.

Code Review Assistant

Trigger: GitHub pull request webhook → Fetch diff → Claude reviews for bugs, security issues, and style → Post review as PR comment.

Working with Local LLMs (Ollama)

Connect n8n to local Ollama models for private, cost-free AI processing:

  1. Ensure Ollama is running: ollama serve
  2. In n8n: Add Ollama node or use HTTP Request node
  3. URL: http://host.docker.internal:11434/api/generate (from Docker)
  4. Method: POST
  5. Body:
{
  "model": "llama3.1",
  "prompt": "{{ $json.text }}",
  "stream": false
}

Local LLMs work well for: classification, summarization, extraction from private documents, and any task where data sensitivity prevents sending to external APIs.

n8n Cloud vs. Self-Hosted

n8n Cloud:

  • Managed hosting, no server needed
  • $20-50/month depending on execution volume
  • Best for: Non-technical users, small teams

Self-hosted:

  • Free beyond server costs (~$5-10/month on a mini VPS)
  • Full data control
  • Best for: Privacy-conscious users, high-volume automations, developers

Advanced: JavaScript/Python Code Nodes

When you need logic n8n’s visual nodes can’t express:

// Code node: Extract entities from Claude's response
const response = $input.first().json.text;
const emails = response.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g) || [];
const phones = response.match(/\d{3}[-.]?\d{3}[-.]?\d{4}/g) || [];

return [{ json: { emails, phones, raw: response } }];

n8n is the most flexible AI automation platform for technical users — it handles simple two-step automations and complex multi-branch AI agent workflows equally well, all from the same self-hosted instance.

#no-code #Claude API #ChatGPT #AI workflow #automation #n8n