Home > Blog > How to Build an AI Chatbot for Your Website

How to Build an AI Chatbot for Your Website (With n8n + Claude)

A practical, no-fluff guide to building and deploying a real AI chatbot on your website using n8n as the orchestration layer and Anthropic’s Claude as the brain — based on our live implementation at SmartFlow.

Why Add an AI Chatbot to Your Website?

Visitors land on your site, scan for 10 seconds, and leave. That is the reality for most business websites. A well-built AI chatbot changes the dynamic entirely — it turns a passive page into an interactive conversation.

The numbers speak for themselves: 67% of consumers worldwide have interacted with a chatbot in the past year, and businesses using AI-powered chat report saving up to 30% on customer support costs. But the real advantage goes beyond cost savings.

Unlike traditional FAQ bots that match keywords to pre-written answers, an AI chatbot powered by a large language model actually understands context and natural language. A visitor can ask “do you work with Shopify stores in France?” and get a meaningful, relevant answer — not a generic “please contact us.”

We built exactly this for the SmartFlow website — and this article walks you through the entire process, from architecture to deployment.

Choosing Your AI Backend

The AI model you choose determines the quality of every conversation your chatbot has. Here is a practical comparison of the main options available in 2026:

OpenAI GPT-4

The most well-known option. GPT-4 is powerful and widely supported, with extensive documentation and community resources. However, costs add up quickly at scale — especially if conversations run long. The API can also experience latency spikes during peak hours.

Anthropic Claude

Claude stands out for its excellent reasoning capabilities and large context window. It follows instructions precisely, which is critical when you need the bot to stay on-topic and represent your business accurately. Claude also offers native tool use, competitive pricing (especially the Haiku model for chat), and strong multilingual support.

Open-Source Models (Llama, Mistral)

Free to use, but you need to host them on your own GPU infrastructure. Running a 70B parameter model requires at least an A100 GPU ($1-2/hour), and you are responsible for uptime, scaling, and model updates. Great for privacy-critical applications, but overkill for a website chatbot.

Why We Chose Claude

For the SmartFlow chatbot, we needed a model that could:

Claude checked every box. The instruction-following accuracy alone was worth the choice — when you tell Claude “keep answers under 3 sentences for simple questions,” it actually does.

The Architecture: n8n as the Brain

The secret to building a maintainable AI chatbot is not writing a custom backend. Instead, we use n8n — an open-source workflow automation platform — as the orchestration layer between the frontend widget and the Claude API.

Here is the complete data flow:

Architecture Flow

Chat Widgetn8n WebhookMemory Manager (Code Node)Claude API (HTTP Request)Response FormatterWidget

Each step is a visible, editable node in n8n. No black boxes, no hidden logic.

How Each Node Works

Why n8n Over a Custom Backend

You could build this with Express.js, FastAPI, or any backend framework. But n8n offers distinct advantages for a chatbot specifically:

Building the Chat Widget

The frontend widget is what visitors actually see and interact with. We built ours from scratch with a few non-negotiable requirements:

Pure Vanilla JavaScript

No React. No Vue. No framework at all. The chatbot widget is a single JavaScript file that creates its own DOM elements, styles itself with injected CSS, and communicates with the n8n webhook via fetch(). Zero dependencies means:

Automatic Language Detection

The widget reads the page’s lang attribute to determine whether to display the interface in English or French. Placeholder text, default greeting, and even the send button label adapt automatically. The detected language is also sent to n8n so Claude responds in the correct language.

Design Details That Matter

Crafting the System Prompt

The system prompt is arguably the most important piece of the entire chatbot. A bad system prompt produces a generic, unhelpful bot. A great one produces a knowledgeable assistant that genuinely represents your business.

Key Principles We Follow

The system prompt is not a one-time thing. Plan to iterate on it weekly for the first month. Watch real conversations, identify where the bot falls short, and refine. The difference between version 1 and version 5 of your system prompt is enormous.

Conversation Memory Without a Database

Most chatbot tutorials tell you to set up Redis or PostgreSQL for conversation memory. We skipped all of that. Here is why — and how.

n8n Static Data as Memory Store

n8n workflows have a built-in feature called static data — a persistent key-value store scoped to each workflow. We use it to store conversation histories, keyed by session ID:

Session Management

Why This Works

For a website chatbot, this approach is ideal. Conversations are short-lived (most are under 5 messages), traffic is moderate (not thousands of concurrent sessions), and there is zero infrastructure to manage. No database server, no connection pooling, no schema migrations. n8n handles persistence natively.

Deploying to Every Page

Once the widget and workflow are ready, deployment is the easy part.

One Script, Every Page

The chatbot is loaded via a single line at the bottom of every HTML page:

<script src="/js/chatbot.js?v=3" defer></script>

For a static site like ours (no framework, just HTML files served by Nginx), this is the simplest possible deployment strategy. For WordPress or other CMS platforms, you would add the script tag to the theme footer template for the same effect.

Real Costs: A Transparent Breakdown

One of the biggest concerns with AI chatbots is cost. Here is exactly what our SmartFlow chatbot costs to run:

Monthly Cost Comparison

Compare to SaaS chatbot platforms:

That is a 10-30x cost difference. And with the self-hosted approach, you own every piece of the stack — no vendor lock-in, no per-seat pricing, no feature gates.

The cost scales linearly with usage. Even at 1,000 conversations per month (which would be excellent traffic for a services website), the Claude API cost would be around $10-15/month. Still a fraction of any SaaS alternative.

Results and Next Steps

Here is what we achieved with this setup:

Real-World Example

The SmartFlow chatbot handles visitor questions about automation services, pricing, and technical capabilities across 33 pages in English and French — built and deployed in a single afternoon using n8n + Claude.

What’s Next

The current implementation is a solid foundation. Here is what we plan to add:

The beauty of this architecture is that every improvement is just another n8n node. No refactoring, no redeployment of the widget, no breaking changes. The workflow grows organically as your needs evolve.

Should You Build Your Own?

If you have a static website or a simple CMS, basic comfort with APIs, and access to a VPS (or n8n Cloud), you can absolutely build this yourself. The total implementation time is 4-8 hours for someone comfortable with webhooks and JavaScript.

If you need advanced features (multi-agent routing, complex lead scoring, integration with enterprise tools), or you simply want it done right the first time without the learning curve, that is exactly the kind of project we handle at SmartFlow.

Either way, the days of paying $100+/month for a basic chatbot are over. With n8n and Claude, you get a smarter bot for a fraction of the cost — and you own every piece of it.

Need Help Implementing This?

SmartFlow specializes in automation and AI integration. Let’s discuss how we can streamline your business.

Contact Us →