How to Build an AI Chatbot for Your Business in 2026
TL;DR: Building an AI chatbot for business means connecting a large language model to your company knowledge base, support docs, and backend systems so it can answer customer questions, route tickets, and handle common requests 24/7. This guide covers architecture, knowledge ingestion, conversation design, and deployment.
Why AI Chatbots Are Different Now
AI chatbots in 2024 were glorified FAQ search engines. Type a question, get a canned response. The chatbots you can build today with large language models understand context, follow multi turn conversations, and take actions in your backend systems.
The difference is the underlying technology. Old chatbots matched keywords to pre written responses. Modern chatbots use LLMs to understand intent, retrieve relevant information from your knowledge base, and generate natural responses. They handle follow up questions, understand context from earlier in the conversation, and know when to escalate to a human.
Step 1: Define the Chatbot's Scope
A chatbot that tries to handle everything handles nothing well. Define clear boundaries.
Scope template
This chatbot will:
- Answer questions about [products/services] using our documentation
- Look up [order status / account details / booking information]
- Handle [common request type: password resets, refund requests, plan changes]
This chatbot will NOT:
- Negotiate pricing or contracts
- Handle complaints about service failures
- Make promises about timelines or features
- Access sensitive personal data beyond [defined fields]
Write the "will not" list first. It is more important than the "will" list because it defines your guardrails.
For a broader view of AI agent capabilities, see how to build an AI agent and our AI agent development service.
Step 2: Prepare Your Knowledge Base
The chatbot is only as good as the information it has access to. Garbage in, garbage out.
Knowledge sources to collect
- FAQ pages and help center articles — Export as markdown or plain text
- Product documentation — Feature descriptions, pricing, technical specs
- Support ticket history — Past questions and their correct answers
- Policy documents — Return policy, SLA, terms of service
- Internal runbooks — How your team handles common scenarios
Cleaning your content
- Remove outdated information (old pricing, discontinued features)
- Standardize formatting (consistent headers, lists, and terminology)
- Split long documents into focused chunks (300 to 500 words each)
- Add metadata to each chunk: source document, topic, last updated date
Building the vector index
import { OpenAI } from "openai";
const openai = new OpenAI();
// Embed each chunk
async function embedChunk(text: string) {
const response = await openai.embeddings.create({
model: "text-embedding-3-small",
input: text,
});
return response.data[0].embedding;
}
// Store in PostgreSQL with pgvector
async function indexChunk(chunk: {
text: string;
source: string;
topic: string;
}) {
const embedding = await embedChunk(chunk.text);
await db.insert(knowledgeChunks).values({
text: chunk.text,
source: chunk.source,
topic: chunk.topic,
embedding,
});
}
A typical business knowledge base with 200 to 500 articles produces 1,000 to 3,000 chunks. Embedding and indexing this takes under an hour.
For a deep dive into RAG architecture, see our guide on how to build a RAG application.
Step 3: Build the Chat Interface
The chat interface sits on your website or inside your app. Keep it simple.
UI requirements
- Chat bubble that opens a conversation panel
- Message input with send button
- Message history (user and bot messages with timestamps)
- Typing indicator while the bot is thinking
- Quick reply buttons for common actions
- "Talk to a human" button always visible
React chat component (simplified)
function ChatWidget() {
const [messages, setMessages] = useState<Message[]>([]);
const [input, setInput] = useState("");
const [isLoading, setIsLoading] = useState(false);
async function sendMessage() {
if (!input.trim()) return;
const userMessage = { role: "user", content: input };
setMessages((prev) => [...prev, userMessage]);
setInput("");
setIsLoading(true);
const response = await fetch("/api/chat", {
method: "POST",
body: JSON.stringify({
messages: [...messages, userMessage],
}),
});
const data = await response.json();
setMessages((prev) => [
...prev,
{ role: "assistant", content: data.response },
]);
setIsLoading(false);
}
return (
<div className="chat-panel">
<div className="messages">
{messages.map((m, i) => (
<div key={i} className={`message ${m.role}`}>
{m.content}
</div>
))}
{isLoading && <TypingIndicator />}
</div>
<input
value={input}
onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && sendMessage()}
placeholder="Ask a question..."
/>
</div>
);
}
Step 4: Build the RAG Pipeline
RAG (Retrieval Augmented Generation) is the pattern that makes your chatbot answer from your knowledge base instead of making things up.
How it works
- User sends a message
- The message is embedded into a vector
- The vector is compared against your knowledge base chunks
- The top 3 to 5 most relevant chunks are retrieved
- The chunks plus the user's message are sent to the LLM
- The LLM generates a response grounded in those chunks
Implementation
async function chat(userMessage: string, history: Message[]) {
// 1. Retrieve relevant knowledge
const queryEmbedding = await embedChunk(userMessage);
const relevantChunks = await db.execute(sql`
SELECT text, source
FROM knowledge_chunks
ORDER BY embedding <=> ${queryEmbedding}
LIMIT 5
`);
const context = relevantChunks
.map((c) => `[Source: ${c.source}]\n${c.text}`)
.join("\n\n");
// 2. Generate response with context
const response = await anthropic.messages.create({
model: "claude-sonnet-4-6-20250514",
max_tokens: 1024,
system: `You are a helpful customer support chatbot for [Company Name].
Answer questions using ONLY the provided context. If the context does not
contain the answer, say "I don't have that information. Let me connect you
with our support team."
Never make up information. Never guess. Cite the source document when relevant.
Context:
${context}`,
messages: history.concat([{ role: "user", content: userMessage }]),
});
return response.content[0].type === "text"
? response.content[0].text
: "";
}
Step 5: Add Backend Integrations
A chatbot that only answers questions from docs is useful. A chatbot that can also look up orders, check account status, and create tickets is transformative.
Common integrations
| Integration | What It Enables |
|---|---|
| CRM (HubSpot, Salesforce) | Look up customer profile, past interactions |
| Order system | Check order status, tracking information |
| Ticketing (Zendesk, Linear) | Create support tickets, check existing ticket status |
| Billing (Stripe) | Look up subscription, invoice history |
| Calendar (Google Calendar) | Book meetings, check availability |
Use the tool use pattern from the AI agent guide. Define each integration as a tool with a clear schema. The LLM decides when to call each tool based on the conversation.
const tools = [
{
name: "lookup_order",
description: "Look up order status by order ID or customer email",
input_schema: {
type: "object" as const,
properties: {
order_id: { type: "string", description: "Order ID" },
email: { type: "string", description: "Customer email" },
},
},
},
{
name: "create_ticket",
description: "Create a support ticket for issues that need human follow-up",
input_schema: {
type: "object" as const,
properties: {
subject: { type: "string" },
description: { type: "string" },
priority: { type: "string", enum: ["low", "medium", "high"] },
},
required: ["subject", "description"],
},
},
];
Step 6: Configure Escalation
The chatbot should know when to hand off to a human. Define explicit triggers:
- Topic based: Customer mentions legal issues, data deletion, or contract disputes
- Sentiment based: Customer expresses frustration or anger (detect via tone analysis)
- Confidence based: The RAG retrieval returns low relevance scores (no good matches in knowledge base)
- Explicit request: Customer says "talk to a human" or clicks the escalation button
- Action threshold: Refund requests above $100, account changes, security concerns
When escalating, pass the full conversation history to the human agent. Nothing frustrates a customer more than repeating themselves. Understanding the distinction between chatbots and AI agents helps you set the right scope and escalation thresholds from the start.
Step 7: Test Before Deploying
Testing checklist
- Answers common questions correctly (test your top 50 support questions)
- Says "I don't know" when the answer is not in the knowledge base
- Does not hallucinate product features, pricing, or policies
- Escalates correctly on all defined trigger conditions
- Handles multi turn conversations (follow up questions, context switching)
- Works on mobile screens
- Responds within 3 seconds
- Logs every conversation for review
Shadow testing
Run the chatbot alongside your human support team for one week before going live. Every conversation the chatbot handles gets reviewed by a human. Track accuracy, escalation rate, and customer satisfaction. Fix issues before exposing real customers.
Step 8: Deploy and Monitor
Deploy the chatbot incrementally. Use the AI Agent ROI Calculator to model your expected cost savings before committing to a full rollout:
- Week 1: Show the chatbot to 10% of website visitors
- Week 2: If accuracy is above 85%, increase to 50%
- Week 3: Roll out to 100%
Metrics to track
| Metric | Target | Action If Below |
|---|---|---|
| Resolution rate | Above 70% | Expand knowledge base |
| Accuracy | Above 90% | Review wrong answers, improve prompts |
| Escalation rate | Below 25% | Add more knowledge, expand chatbot scope |
| Response time | Under 3 seconds | Optimize retrieval, cache common queries |
| CSAT score | Above 4.0/5.0 | Review low rated conversations |
DIY vs Hire an Agency
Build it yourself when:
- You have a developer comfortable with LLM APIs and vector databases
- Your knowledge base is small (under 100 articles)
- The chatbot only needs to answer questions (no backend integrations)
- You have time to iterate on prompts and retrieval quality
Hire an agency when:
- You need CRM, order system, or ticketing integrations
- Accuracy requirements are high (customer facing, brand reputation at stake)
- You want the chatbot live in under 2 weeks
- You need guardrails, escalation logic, and monitoring from day one
At HouseofMVPs, we build AI chatbots that integrate with your knowledge base, CRM, and support tools. Starting at $3,000 with 14 day delivery. Each build includes RAG pipeline, backend integrations, escalation logic, and a monitoring dashboard.
Common Chatbot Mistakes
Launching without a knowledge base. An LLM without context will hallucinate your product features. Always use RAG.
Not defining escalation triggers. Without clear escalation rules, the chatbot will try to handle situations it should not.
Ignoring conversation analytics. Review chatbot conversations weekly. The wrong answers show you what is missing from your knowledge base.
Making it sound too human. Users should know they are talking to a bot. Pretending to be human erodes trust when discovered.
Skipping the shadow test. Going live without human review is how you end up with a chatbot telling customers to "please hold" and then disconnecting. See our AI workflow automation guide for how to build the operational processes that support a live chatbot deployment.
For the complete AI agent architecture, start with how to build an AI agent. For industry specific AI integration, see our AI integration services.
Build With an AI-Native Agency
Free: 14-Day AI MVP Checklist
The exact checklist we use to ship production-ready MVPs in 2 weeks. Enter your email to download.
AI Chatbot Requirements Template
A template for defining your chatbot's scope, knowledge sources, escalation rules, and success metrics.
Frequently Asked Questions
Frequently Asked Questions
Free Estimate in 2 Minutes
Already know your scope? Book a Fixed-Price Scope Review
