n8n-claw Self-Hosted AI Agent Setup in 30 Minutes
n8n-claw is a self-hosted AI agent built entirely inside n8n that uses Claude API for reasoning, PostgreSQL for persistent memory with vector search, Telegram as the chat interface, and SearXNG for private web search. It can install expert sub-agents (Research, Content, Data), build its own MCP servers, and manage tasks via cron. Setup from scratch takes 30 minutes.
Primary Intelligence Summary: This analysis explores the architectural evolution of n8n-claw self-hosted ai agent setup in 30 minutes, focusing on the implementation of agentic AI frameworks and autonomous orchestration. By understanding these 2026 intelligence patterns, agencies and startups can build more resilient, self-correcting systems that scale beyond traditional automation limits.
Written By
SaaSNext CEO
n8n-claw Self-Hosted AI Agent Setup in 30 Minutes
Direct Answer Block
n8n-claw is a self-hosted AI agent built entirely inside n8n that uses Claude API for reasoning, PostgreSQL for persistent memory with vector search, Telegram as the chat interface, and SearXNG for private web search. It can install expert sub-agents, build its own MCP servers, manage tasks via cron, and learn from conversations. Setup from scratch takes 30 minutes with a single Docker Compose file.
The Real Problem
42% of developers now self-host at least one AI tool, up from 18% in 2024. The reason is straightforward: cloud AI subscriptions store your conversation history on third-party servers, cost $20-200/month with limited customization, and disappear if you stop paying.
[ STAT ] 42% of developers self-host at least one AI tool in 2026, driven by data privacy and customization needs. — Stack Overflow Developer Survey, 2026
The alternatives to cloud AI — OpenClaw, AutoGPT, AgentGPT — all require dedicated infrastructure, complex configuration files, and a separate database setup that most developers do not have time for. They also require maintaining a separate process with its own logs, updates, and failure modes. If you already run n8n for workflow automation — and over 200,000 developers do — adding a separate agent stack feels like going backwards.
What This Workflow Actually Does
n8n-claw builds the entire agent inside your existing n8n instance. No separate runtime. No separate database. No separate configuration files.
[TOOL: n8n] The entire agent runtime. All logic, routing, state management, and scheduling happen inside n8n workflows. 15+ interconnected workflows handle message intake, memory, skill routing, sub-agent delegation, and cron scheduling.
[TOOL: Claude API] The reasoning engine. Handles intent classification, skill selection, content generation, and research synthesis.
[TOOL: PostgreSQL] The persistent memory store. Stores conversation history with vector embeddings for semantic recall. Stores the skills registry where the agent tracks what capabilities it has.
[TOOL: Telegram Bot API] The chat interface. Send a message from your phone, the agent responds. Supports DM and group chat.
[TOOL: SearXNG] The self-hosted web search provider. Zero API costs, zero tracking. Aggregates results from 245 search engines through your own server.
The agentic reasoning step: Claude classifies every incoming message into research, task creation, content generation, skill management, or general chat. It then routes to the correct skill or expert sub-agent. If no skill exists, it generates one on the fly.
Who This Is Built For
Developers already running n8n for workflow automation who want a Telegram-controlled AI assistant without deploying a separate OpenClaw instance. You already have Postgres running. You already have n8n running. One setup script adds the AI agent.
Solo SaaS founders who need a 24/7 AI assistant for task management, research, and content creation accessible from their phone. No cloud subscription. No vendor lock-in. Your data stays on your server.
Privacy-conscious users who want an AI assistant with zero telemetry, local-only data storage, and self-hosted search. SearXNG means you never send a query to Google, and Postgres means every conversation stays on your hardware.
How It Runs: Step By Step
-
Telegram Message Intake: User sends a message. n8n's Telegram trigger receives user ID, chat ID, and text. Output: parsed message object.
-
Session Retrieval: n8n queries PostgreSQL for recent conversation history using vector similarity search. Input: user ID. Output: last 20 messages with relevance scores.
-
Intent Classification: Claude receives the new message plus history and classifies the intent. Research request? Task creation? General chat? Output: classified intent with confidence score.
-
Skill Router: n8n checks the skills registry in PostgreSQL for matching skills. If found, loads the skill's MCP template and tool config. Output: selected or generated skill.
-
Expert Sub-Agent: For complex tasks, n8n routes to a sub-agent workflow. The Research Expert queries SearXNG, summarizes via Claude, returns structured response. Output: sub-agent result with sources.
-
Memory Consolidation: The conversation turn is stored in PostgreSQL with vector embedding for future recall. Output: updated memory store.
-
Proactive Tasks: If the user set a reminder, n8n's cron trigger executes it at the scheduled time. Output: Telegram notification with result.
-
Self-Expansion: If a capability does not exist as a skill, the Claude Code integration builds a new MCP server on the fly. Output: new skill registered and invoked.
Setup and Tools
Setup time: 30 minutes. This is the fastest path to a self-hosted AI agent with memory, skills, and search.
n8n → Agent runtime (self-hosted Docker, requires community AI agent package) Claude API → Reasoning engine (console.anthropic.com) PostgreSQL + pgvector → Memory store (any Postgres 14+) Telegram → Chat interface (BotFather at t.me/BotFather) SearXNG → Private search (searxng/searxng Docker image)
Gotcha: The n8n AI Agent node is NOT included in the default Docker image. You must either build a custom image with the AI agent package or install the community node from Settings Community Nodes. This step is not mentioned in the n8n-claw setup guide because the author assumes you already have it.
The Numbers
▸ Task management overhead 3-5 hrs/week → automated via Telegram commands ▸ Research time per topic 45-90 min → 10-15 min with Research Expert sub-agent ▸ Cloud AI subscription $20-200/month → $0-20/month (pay-per-token) ▸ Skill compounding zero reuse → library grows automatically, saving 30-60 min per repeat ▸ Setup time vs OpenClaw 4-8 hours → 30 minutes with n8n-claw script
Measurable in week 1: set one reminder via Telegram. Tell the agent: Remind me to check server logs at 9 AM tomorrow. Watch it fire automatically.
What It Cannot Do
- It cannot work without a public HTTPS endpoint. Telegram's webhook requires n8n to be reachable. Developers behind NAT must use ngrok, Cloudflare Tunnel, or deploy to a VPS.
- It does not implement RAG on uploaded documents. It only searches conversational memory. For document Q&A, connect a separate n8n pipeline with a vector database node.
- It requires manual recovery if the Postgres connection drops. n8n-claw spans 15+ interconnected workflows. A database outage makes the entire agent unresponsive until the connection is restored.
Start in 10 Minutes
-
(2 min) Run SearXNG: docker run -d -p 8888:8080 searxng/searxng. Verify JSON API is enabled by visiting http://localhost:8888/search?q=test&format=json.
-
(5 min) Create a Telegram bot via BotFather at t.me/BotFather. Copy the bot token. Configure n8n's Telegram trigger and send nodes with the token.
-
(10 min) Import the n8n-claw workflow JSON from github.com/freddy-schuetz/n8n-claw. Add your Claude API key and Postgres connection string to the credentials.
-
(10 min) Test: send a message to your Telegram bot. The agent should respond with a greeting and list available commands. You now have a self-hosted AI agent.
FAQ
Q: Can n8n-claw replace OpenClaw entirely? A: For most tasks, yes. n8n-claw covers the core OpenClaw features: Telegram interface, memory, skills, cron, and search. It does not include OpenClaw's file system access or IDE integration — those require the separate OpenClaw skill for n8n-claw.
Q: Does n8n-claw require pgvector for memory? A: Yes. Semantic search over conversation history requires the pgvector extension. Run CREATE EXTENSION vector; on your Postgres instance before importing the workflows.
Q: Can I add custom expert sub-agents? A: Yes. Expert agents are just n8n sub-workflows. Create a new workflow with your custom logic, then register it in the skills registry table with a trigger phrase. The agent will route matching requests to it.
Q: How much does it cost to run n8n-claw? A: $0-20/month depending on usage. SearXNG and n8n are free self-hosted. Claude API costs vary: $5-15/month for moderate use (100-200 conversations). Postgres on a $5/month VPS handles it.
Q: Can multiple users talk to the same agent? A: Yes. The agent uses user ID from Telegram to maintain separate memory per user. Each user has independent conversation history and skill access based on allowlist configuration.
(Source: Stack Overflow Developer Survey, 2026) (Source: n8n-claw.com, 2026) (Source: GitHub freddy-schuetz/n8n-claw, 2026) (Source: SearXNG Docs, 2026)
The sub-agent architecture deserves special attention. Each expert sub-agent is itself an n8n workflow that inherits the agent's memory and tool context. The Research Expert sub-agent, for instance, receives the conversation state from the parent agent, runs SearXNG queries with parameters derived from the user's question, summarizes results via Claude, and returns a structured response that the parent agent incorporates into its reply. This modular design means you can add a new expert sub-agent by creating one n8n workflow and registering it in the skills registry table with a trigger phrase. No code changes to the parent agent. No redeployment. The sub-agent shows up in the agent's capability list automatically.
The sub-agent architecture deserves special attention. Each expert sub-agent is itself an n8n workflow that inherits the agent memory and tool context. The Research Expert sub-agent receives the conversation state from the parent agent, runs SearXNG queries with parameters derived from the user question, summarizes results via Claude, and returns a structured response the parent agent incorporates into its reply. This modular design means you add a new expert sub-agent by creating one n8n workflow and registering it in the skills registry table with a trigger phrase. No code changes to the parent agent and no redeployment required.