
RAG vs Agentic AI
RAG answers questions from your data. Agentic AI takes multi-step action using it. Here's how to tell which one your business needs, when you need both, and why getting this wrong is the most common way AI budgets get wasted.

TL;DR: A business chatbot works by turning a visitor's message into intent, retrieving grounded facts from your knowledge base and internal systems, then either answering directly or handing off to a human. You can ship a narrow, well-scoped version of this in a few weeks — the pattern below is the same one behind most production support bots today.
Who is this for? Founders and engineering teams weighing whether to add a chatbot to a business website, and developers who want a concrete architecture rather than a vendor pitch.
A website chatbot earns its place when it removes friction at a specific, repeated moment — not as a generic decoration. The common wins:
Strip away the marketing language and every production chatbot follows the same pipeline: capture the message, understand what's being asked, pull in facts it's actually allowed to state, then respond or escalate.
A small embedded script on the website opens a chat panel and posts each message to a backend endpoint, along with a conversation ID so the backend can keep context across turns.
Older chatbots ran on rule-based intent classifiers: a fixed set of buttons or a decision tree matched against keywords. Most current implementations use an LLM instead, which understands free-form text without pre-defining every phrasing — at the cost of being less predictable. The reliable pattern is a hybrid: route obvious cases ("track my order", "talk to a person") through cheap, deterministic logic, and fall back to the LLM only for open-ended questions.
An LLM with no context will confidently invent a return policy that doesn't exist. Retrieval-Augmented Generation (RAG) fixes this: your docs, FAQs, and policies are split into chunks, embedded into a vector store, and at query time the chunks most relevant to the visitor's question are retrieved and given to the model as context, with an instruction to answer only from what it was given.
Answering questions is half the job — a useful bot can also act. "Function calling" (or "tool use") lets the model decide it needs to call getOrderStatus(orderId) or checkAvailability(date) against your real CRM, order system, or booking API, then use the result in its reply instead of guessing.
A chatbot that never escalates will eventually confidently mislead someone. Trigger a handoff on: low model confidence, an explicit request for a person, and anything touching refunds, complaints, or legal/medical/financial claims.
A trimmed version of step 3, as a Next.js API route:
// app/api/chat/route.tsimport { NextRequest, NextResponse } from 'next/server'import { embedQuery, searchKnowledgeBase } from '@/lib/chatbot/retrieval'import { getOrderStatus } from '@/lib/integrations/orders'import { chatCompletion } from '@/lib/chatbot/llm' export async function POST(req: NextRequest) { const { message, conversationId } = await req.json() // 1. Retrieve the knowledge relevant to this question const queryEmbedding = await embedQuery(message) const context = await searchKnowledgeBase(queryEmbedding, { topK: 4 }) // 2. Let the model answer from context, or call a tool for live data const reply = await chatCompletion({ system: 'You are the support assistant for Acme Co. Only answer from the ' + 'provided context. If you are not confident, say so and offer a human.', context, message, conversationId, tools: [ { name: 'getOrderStatus', description: "Look up a customer's order status by order ID", run: async ({ orderId }: { orderId: string }) => getOrderStatus(orderId), }, ], }) // 3. Escalate low-confidence or explicit human requests if (reply.confidence < 0.55 || reply.wantsHuman) { return NextResponse.json({ ...reply, escalate: true }) } return NextResponse.json(reply)}Warning
Never let the model improvise pricing, refund policy, or legal claims. Those answers must come from a retrieved document or a tool call against a real system — not free generation.
None of this requires a large team — a narrowly scoped bot with a real knowledge base and one system integration is a realistic first build. The architecture above is the same one we use when we build these for clients.
Get new posts in your inbox
No spam — just new articles as we publish them.

Md Nasir Wahid
AI-native Engineer & Founder / CEO
Founder of GeekFolks and a full-stack developer with 5+ years of experience across PHP (Laravel, Yii2), Node.js, and Next.js — building scalable, cloud-native systems with a growing focus on AI-driven products.
View full profile →
RAG answers questions from your data. Agentic AI takes multi-step action using it. Here's how to tell which one your business needs, when you need both, and why getting this wrong is the most common way AI budgets get wasted.

A chatbot answers questions. An agent gets things done. Here's the real loop behind agentic AI — goal, reason, act, observe — traced through a live refund request, plus what it takes to build one safely for a real business.

What RAG actually does, stage by stage, traced through ChatBotAi — a real Laravel chatbot that crawls a website, indexes it, and answers questions from the retrieved paragraphs alone.