DEV Community

Daichi Koga
Daichi Koga

Posted on

Building an AI-Powered CRM Chat Assistant with n8n and OpenRouter

Build a No-Code AI CRM Assistant in One Day (n8n + Claude + OpenRouter)

What if your team could query a CRM just by asking a question?

Instead of navigating dashboards or exporting CSV files, imagine typing:

“Show me deals closing this month.”

…and getting the answer instantly.

In this article, I'll show you how I built a no-code AI CRM assistant in a single day that allows employees to query a CRM using natural language.

The entire system runs without writing a single line of application code.


Tech Stack

  • n8n — self-hosted workflow automation
  • OpenRouter — AI model API gateway
  • CRM — CRM with REST API
  • Docker — container runtime
  • Claude Sonnet 4.6 (via OpenRouter) — LLM powering the agent

Architecture

[Employee] → n8n Chat UI → [AI Agent (Claude via OpenRouter)]
                                ├── Tool: Search API
                                └── Tool: Search API
                                      ↓
                                [CRM API]
                                      ↓
                        [AI generates response in Japanese]
                                      ↓
                          [Employee receives answer]
Enter fullscreen mode Exit fullscreen mode

The key idea is to let the AI agent decide which CRM API to call based on the user's natural language query.


Step 1 — Run n8n with Docker

Spinning up n8n locally takes only one command:

docker run -d \
  --name n8n \
  --restart always \
  -p 5678:5678 \
  -e WEBHOOK_URL=http://YOUR_IP:5678/ \
  -e N8N_EDITOR_BASE_URL=http://YOUR_IP:5678/ \
  -v n8n_data:/home/node/.n8n \
  n8nio/n8n
Enter fullscreen mode Exit fullscreen mode

Key Learnings

Authentication has changed

Older guides mention N8N_BASIC_AUTH_*, but these variables are now deprecated.

n8n now uses email-based account setup through the web UI on first launch.

LAN access requires correct environment variables

Without setting:

WEBHOOK_URL
N8N_EDITOR_BASE_URL
Enter fullscreen mode Exit fullscreen mode

the chat UI may attempt to call localhost, causing CORS errors for other users on the network.


Step 2 — Building the AI Agent

Instead of a simple pipeline like:

Chat → HTTP Request → AI
Enter fullscreen mode Exit fullscreen mode

I built a tool-enabled AI Agent.

This allows the LLM to choose the correct CRM endpoint autonomously.

Workflow structure:

Chat Trigger → AI Agent
                ├── Tool: search
                └── Tool: search
Enter fullscreen mode Exit fullscreen mode

Each tool calls a specific CRM endpoint

Dynamic query example:

{{ $json.query }}
Enter fullscreen mode Exit fullscreen mode

Step 3 — The System Prompt (The Most Important Part)

The system prompt determines whether the agent works reliably.

Step 4 — Sharing on LAN

Find your IP:

ipconfig getifaddr en0
Enter fullscreen mode Exit fullscreen mode

Share the chat URL:

http://YOUR_IP:5678/webhook/xxxxx/chat
Enter fullscreen mode Exit fullscreen mode

Enable Basic Auth for security.


Challenges & Lessons Learned

Token Limit Explosion

Querying the CRM without filters returned the entire dataset.

Result: 8M+ tokens

Solution:

  • enforce search conditions
  • block empty queries

Cost

Component Cost
n8n (self-hosted) $0
OpenRouter (Claude Sonnet) ~$26/month
Infrastructure $0

Supports roughly 10 users × 5 queries/day.


Conclusion

Using n8n + OpenRouter, I built a working AI CRM assistant in less than a day.

The biggest takeaway:

System prompt design is critical.

With the right guardrails, you can turn any API-driven system into a natural-language interface.

Top comments (0)