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
| Node | Purpose | Use Case |
|---|---|---|
| AI Agent | Autonomous AI with tool access | Complex tasks requiring reasoning and actions |
| Basic LLM Chain | Simple prompt → response | Classification, summarization, generation |
| Retrieval QA Chain | RAG-based Q&A | Answering questions from documents |
| Vector Store | Embed and search documents | Building knowledge bases for RAG |
| Text Splitter | Chunk documents for embedding | Preparing documents for vector storage |
| Output Parser | Structure LLM responses | Extracting 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:
Trigger: Email Received
Use the IMAP Email Trigger or Gmail Trigger node to watch for new emails.
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.
Route by Category
Use a Switch node to route based on the AI classification. Each branch handles a different category.
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:
// 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
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.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX