SevvenLabs
Home/Blog/AI Engineering
AI Engineering

How to Build a RAG Chatbot for Live Business Data

Published on •By , Founder & CEO, SevvenLabs
How to Build a RAG Chatbot for Live Business Data

Short answer: A RAG chatbot answers questions from your own documents instead of from a model's memory. To make one that also works with live business data, use a hybrid design: retrieval (RAG) for static content such as policies and manuals, and tool calls to your database or API for anything that changes, such as prices, stock and bookings. Add citations, a confidence check and a human handoff, and test it with a fixed set of real questions. This guide covers each step, based on a project we built for a car rental marketplace.

Most RAG chatbot tutorials stop at "upload a PDF and ask questions." That works for a demo. A RAG chatbot for business needs more. It must stay current, admit when it does not know, and pass hard cases to a person.

What RAG is, in three sentences

RAG stands for retrieval-augmented generation. When a user asks a question, the system searches your documents for the most relevant passages. It then gives those passages to a language model, which writes an answer based on them.

Why plain RAG fails with live data

A vector index is a snapshot. It is only as fresh as the last time you rebuilt it. Policy documents change a few times a year, so a snapshot is fine. Prices, availability and booking status can change every hour.

If you put that data in the index, the bot will quote old prices with full confidence. If you re-index constantly, you pay for it in cost and complexity, and you are still always a little behind.

The fix is to split the data by how fast it changes:

  • Static or slow data (policies, FAQs, manuals, contracts): retrieve it from a vector index.
  • Live data (inventory, prices, orders, bookings, customer accounts): fetch it with a tool call to your own database or API at question time.

The model decides which one it needs. Often it needs both in one conversation.

How to build a RAG chatbot, step by step

1. Collect and clean your sources

List every document the bot should know: PDFs, Word files, help articles, internal wikis. Remove duplicates and outdated versions. Fix broken text from scanned files. This step decides most of your answer quality. Bad input gives bad answers, however good the model is.

2. Chunk the documents

Split each document into pieces small enough to retrieve precisely. A common starting point is a few hundred tokens per chunk with some overlap, so a sentence cut at a boundary still appears whole in one chunk. Keep headings with their text. Test different sizes on your own questions, because the best size depends on your content.

3. Create embeddings

An embedding model turns each chunk into a list of numbers that captures its meaning. Pick one model and use it for both documents and questions. If you change the model later, you must re-embed everything.

4. Store vectors in a vector database

If you already use PostgreSQL, the pgvector extension is a practical choice. It keeps vectors next to your other data and supports fast approximate search with an HNSW index. You can also run normal full-text search in the same database, which helps in the next step.

5. Retrieve and rerank

Vector search finds passages with similar meaning. It can miss exact terms such as product codes, plan names or legal phrases. Keyword search finds those. Combining both (hybrid search) gives better results than either alone. A reranker can then reorder the top results so the best passages come first. Send only a handful of passages to the model, not everything you found.

6. Write the prompt and require citations

Tell the model to answer only from the supplied passages. Tell it to say "I don't know" when the passages do not cover the question. Show the source (document name and section) next to each answer, so users and staff can check it. Citations also make errors easy to find.

7. Add tool calling for live data

Define tools the model can call, such as search_products, get_booking or check_stock. Each tool runs a read query against your real system and returns structured results. The model then writes the reply from that result. Keep tools narrow and read-only at first. For account data, require the user to be signed in and check permissions in your code, not in the prompt.

8. Build a human handoff

Some chats need a person: angry customers, edge cases, account problems, or low-confidence answers. Give agents the full chat history so customers never repeat themselves. Let agents hand the chat back to the bot when they are done. Plan this from the start, because it is hard to add later.

9. Add an admin console

Your team should be able to update prompts, upload and re-index documents, and test retrieval without a developer. Without this, every small content change becomes a code release.

10. Log, evaluate and test

Log every question, the retrieved passages, tool calls and the final answer. Build an evaluation set of 50 to 200 real questions with known good answers. Run it before every change to prompts, chunking or models. This is the only reliable way to know whether a change helped.

11. Set guardrails

Block answers that are not supported by your sources. Use a confidence threshold: if retrieval is weak, ask a clarifying question or hand off. Limit what each tool can read. Never let the model run free-form database queries.

12. Deploy and control cost

Run the chatbot as its own service so you can update it without touching your main site. Use a small, fast model for most questions. Cache answers to repeated questions and repeated tool results where freshness allows. Stream responses so users see text quickly. Send only the top passages and the recent chat turns to the model, not whole documents.

Components and common tool choices

ComponentWhat it doesCommon choices
Document parsingExtracts clean text from PDF and DOCXUnstructured, PyMuPDF, python-docx
ChunkingSplits text into retrievable piecesLangChain text splitters, LlamaIndex
EmbeddingsTurns text into vectorsHosted embedding APIs, open models such as BGE
Vector storeStores and searches vectorsPostgreSQL + pgvector, Qdrant, Pinecone
Keyword searchFinds exact termsPostgreSQL full-text search, OpenSearch
RerankerReorders top resultsCross-encoder models, hosted rerank APIs
OrchestrationRuns the agent and tool callsLangChain, LlamaIndex, plain Python
API layerServes chat and streamingFastAPI, WebSockets
Handoff and live chatRoutes chats to peopleWebSockets with Redis Pub/Sub
EvaluationScores answers on a test setCustom scripts, Ragas, spreadsheets

From the Zunu project

We built a RAG chatbot called Zunu for RealDealRide, a car rental marketplace in the USA. Customers ask about insurance, deposits and cancellations, and they search for cars by city, dates, vehicle type and daily budget. A static FAQ and a generic chatbot could not do both without guessing. You can read the full Zunu case study. Here is how it maps to the steps above.

  • Static documents through RAG. Policy PDF and DOCX files are split into chunks of about 350 tokens with 75 tokens of overlap. They are embedded as 768-dimension vectors with gemini-embedding-001 and stored in PostgreSQL 16 with pgvector.
  • Hybrid search. Retrieval combines pgvector HNSW cosine similarity with PostgreSQL full-text search. Documents re-index atomically, so the bot never reads a half-updated index.
  • Live data through tools. The agent runs on Python FastAPI and LangChain with Google Gemini (gemini-3.1-flash-lite). Its tools search live vehicle inventory by city, type, price and dates, and also look up reservations, discounts and reviews, and create tickets. Results appear as car cards inside the chat. Signed-in members can check or manage their bookings.
  • Grounding. Answers come only from retrieved policy chunks, with a confidence threshold before Zunu replies.
  • Human takeover. Separate WebSocket channels for customers and operators, coordinated through Redis Pub/Sub, support Accept Takeover, internal whisper notes and Release-to-AI. Agents see the full session history and confidence scores.
  • Admin console. A 13-view Laravel console lets staff update prompts, test retrieval in a live sandbox and re-index policy documents in seconds, with no code deployment.
  • Deployment and security. Zunu runs as a separate Docker microservice that plugs into the existing Laravel site. It uses HMAC-SHA256 JWT authentication, role-based admin access and guest email verification. The target is under 5 seconds end to end, with streamed responses.

The main lesson: the car inventory never went into the vector index. Policies went in the index. Cars and bookings were fetched live. That split is what keeps answers both accurate and current.

Common mistakes

  • Indexing live data. Prices and stock in the index go stale. Use tool calls instead.
  • Letting the index go stale. Even static documents change. Re-index when files change, and show the document date in citations.
  • No citations. Without sources, nobody can verify an answer or find the cause of an error.
  • No human handoff. A bot with no exit frustrates customers and hides problems from your team.
  • No evaluation set. Without one, every prompt tweak is a guess.
  • Sending all data to the prompt. It raises cost, slows replies and often lowers accuracy. Retrieve a few good passages.
  • Skipping permissions on account data. Check who is asking in code before any tool returns private data.
  • Answering outside the sources. If the answer is not in your documents or tools, the bot should say so.

Frequently asked questions

What is a RAG chatbot?

A RAG chatbot looks up relevant passages from your own documents and gives them to a language model, which writes the answer from those passages. This keeps answers tied to your sources instead of the model's memory.

Can a RAG chatbot use live business data?

Yes, but not through the vector index alone. Static documents go into the index, and live data such as prices, stock and bookings is read through tool calls to your database or API at the moment of the question.

Which database should I use for a RAG chatbot?

If you already run PostgreSQL, the pgvector extension is a practical start. It keeps vectors next to your other data and supports both vector search and full-text search. Dedicated vector databases make sense at larger scale.

How do I stop a RAG chatbot from making things up?

Answer only from retrieved passages, set a confidence threshold, show citations, and hand the chat to a human when retrieval is weak. Then test with a fixed set of real questions before every release.

Want a RAG chatbot built on your own documents and live data? See our enterprise RAG systems service, explore Spark, our chatbot product, or learn how AI agent automation can run tasks behind the chat. When you are ready, contact us and tell us what your bot should answer.