Intermediate

n8n AI Workflows

n8n is an open-source workflow automation platform with first-class AI support. Its visual builder, self-hosting option, and powerful AI nodes make it the top choice for teams that want full control over their AI automations.

Why n8n for AI Automation?

  • Open source: Self-host on your infrastructure for data privacy and control. No vendor lock-in
  • AI-native nodes: Built-in nodes for LLMs, AI agents, vector stores, chains, and tools
  • 400+ integrations: Connect AI workflows to virtually any service or API
  • Code when needed: Write JavaScript or Python in code nodes for custom logic
  • Active community: Templates, tutorials, and a growing ecosystem of AI workflow recipes

Core AI Nodes

NodePurposeUse Case
AI AgentAutonomous AI with tool accessComplex tasks requiring reasoning and actions
Basic LLM ChainSimple prompt → responseClassification, summarization, generation
Retrieval QA ChainRAG-based Q&AAnswering questions from documents
Vector StoreEmbed and search documentsBuilding knowledge bases for RAG
Text SplitterChunk documents for embeddingPreparing documents for vector storage
Output ParserStructure LLM responsesExtracting JSON, lists, structured data

Building Your First AI Workflow

Let us build an email classifier that categorizes incoming emails and routes them to the appropriate team:

  1. Trigger: Email Received

    Use the IMAP Email Trigger or Gmail Trigger node to watch for new emails.

  2. AI Classification

    Pass the email subject and body to a Basic LLM Chain node with a prompt that classifies the email into categories: support, sales, billing, partnership, spam.

  3. Route by Category

    Use a Switch node to route based on the AI classification. Each branch handles a different category.

  4. Take Action

    Each branch can create a ticket (Jira/Linear), send to a Slack channel, add to a CRM, or draft a response.

AI Agent Workflows

n8n's AI Agent node creates autonomous agents that can use tools within your workflow:

n8n AI Agent Configuration
// Agent setup in n8n:
Agent Type: Conversational Agent
LLM: Claude Sonnet (via Anthropic credential)
Tools:
  - Calculator (built-in)
  - HTTP Request (call external APIs)
  - Code Tool (run JavaScript)
  - Vector Store Tool (search knowledge base)
Memory: Window Buffer Memory (last 10 messages)
System Prompt: "You are a helpful customer support
  agent. Use the knowledge base tool to find answers.
  Use the HTTP tool to look up order status."

Practical Recipes

  • Content repurposer: RSS trigger → fetch article → LLM summarize → LLM create social posts → post to Twitter/LinkedIn
  • Meeting summarizer: Webhook receives transcript → LLM extracts action items → creates tasks in project management tool
  • Lead enrichment: CRM trigger (new lead) → AI research company → enrich CRM record → score lead → notify sales
  • Document processor: Watch folder → extract text from PDF → LLM extracts key fields → save to database
Self-hosting tip: Run n8n with Docker using docker run -p 5678:5678 n8nio/n8n. For production, use Docker Compose with PostgreSQL for persistence and proper environment variables for API keys.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.