Skip to content

AI & Automation

How to Build a RAG Chatbot: Production Architecture and Checklist

Build a RAG chatbot with a production architecture: ingestion, retrieval, grounded generation, citations, evaluation, security and rollout.

25 September 2026MainakMainak

Overhead view of a laptop showing data visualisations and charts

To build a RAG chatbot, connect a controlled document-ingestion pipeline to a retrieval service, pass only authorised evidence to a model, and measure the answer and the retrieval path separately. The chat window is the smallest part. A production build also needs source ownership, metadata, access control, re-indexing, citations, refusal behaviour, tracing, security tests and a release gate. This guide covers the production architecture and implementation checklist. The core RAG concepts are in RAG chatbot development, and whether a knowledge base assistant is the right shape at all is covered in knowledge base chatbots.

Key Takeaways

• Build two pipelines: an asynchronous document-to-index pipeline and a synchronous question-to-answer request path.

• A production RAG chatbot needs a clear contract for chunks, citations, access filters, tool calls and the “not enough evidence” response.

• Evaluate retrieval and generation separately. A good answer cannot compensate for missing or unauthorised evidence.

• Keep an approved source, an owner, a version and a freshness date for every document. Retrieval without provenance is difficult to operate.

• Use hybrid search, reranking and metadata filters as measured improvements—not unquestioned defaults.

• For India, test Hinglish and regional languages, local workflows, sensitive order data and retention before launch.

Start with the production shape

A useful RAG architecture has six bounded components:

• Source and ingestion service: receives documents, extracts text, preserves metadata and records failures.

• Indexing service: cleans, chunks, embeds and stores searchable units with access metadata.

• Query service: authenticates the user, applies filters, retrieves candidates and optionally reranks them.

• Generation service: builds a constrained prompt, calls the model and returns a cited or explicitly uncertain answer.

• Application service: maintains conversation state, citations, handoff and rate limits.

• Operations layer: traces, evaluates, monitors freshness, cost, latency and policy violations.

Keep the first version as simple as the task allows. A single application can contain these components behind clear interfaces. Split them only when scale, access boundaries or independent release cadence justify the operational cost. Microsoft’s RAG design and evaluation guide similarly describes a request path and a separate data pipeline, with chunking, enrichment, embedding and persistence on the data side.

Define the contract before choosing the stack

Write a short specification for each boundary. It prevents a common failure where the chatbot, index and admin screen each invent a different meaning for “document.”

Source record

For every source, record:

• Canonical URL, file name or system ID

• Business owner and approver

• Effective date and expiry or review date

• Tenant, region, language and access groups

• Version and checksum

• Extraction status and parser version

• Whether the source contains personal or regulated data

The source record should be immutable enough to audit. If a policy changes, create a new version and re-index it; do not silently overwrite the evidence that produced an old answer.

Chunk record

A chunk should have a stable ID, source ID, title, section path, text, token or character range, language, effective date, access metadata and embedding version. A chunk that says “this applies to eligible customers” without the surrounding eligibility rule is not yet a useful retrieval unit. Choose boundaries around headings, policies, tables and FAQs, then test them against real questions.

Build the document ingestion pipeline

Ingestion should be repeatable and observable. A typical job follows this sequence:

• Fetch or receive the document.

• Validate type, size, checksum and source ownership.

• Extract text, headings, tables, links and page references.

• Remove navigation, boilerplate, duplicated footers and broken fragments.

• Detect language and preserve important formatting.

• Split content into semantically meaningful chunks.

• Create metadata and access tags.

• Embed chunks with a versioned embedding model.

• Write vectors, text and metadata to the index.

• Run a small retrieval smoke test before marking the document ready.

The job must be idempotent: a repeated upload updates or skips the same version instead of creating duplicate chunks. Store failures with a reason, and sample questions against newly indexed content.

Parse before you optimise retrieval

PDFs, invoices, spreadsheets, HTML help centres and WhatsApp exports have different failure modes. A parser that flattens a GST table into an unreadable line can make a perfect embedding irrelevant. Include table reconstruction, page or section references, duplicate detection and language checks in the ingestion acceptance tests. For a document-heavy corpus, estimate parser work before choosing a vector store.

Design retrieval as a measurable service

Start with a simple baseline: a semantic search plus metadata filters. Then test whether lexical search or reranking improves the real query set. OpenAI’s Retrieval documentation describes vector stores, semantic search, attribute filters, ranking and query rewriting. These are building blocks, not proof that a particular configuration is right for your corpus.

A query service should return more than text. For each candidate, return a source ID, title, section, score, access decision, index version and a citation key. That lets the generator cite evidence and lets operators debug why a source was selected or excluded.

Handle exact terms and semantic questions

A support question may contain a SKU, order number, error code or policy term. Vector similarity can miss exact strings, while keyword-only search can miss paraphrases. Test lexical search, semantic search, hybrid fusion and reranking separately. Record the relevant source IDs for each labelled question, then calculate recall at the retrieval depth you will actually use.

Do not add a reranker because a tutorial mentions it. Add one if it improves retrieval for the target questions, stays within your latency budget and does not push unauthorised content above the access boundary. Microsoft’s guide recommends evaluating each RAG phase independently while also measuring the end-to-end experience.

Build the grounded generation path

The generation service should receive a small, labelled context package:

• Original user question

• Retrieved passages with citation IDs

• Source titles and effective dates

• Access decision or tenant context

• Required response format

• Refusal and handoff instructions

• Conversation summary, if one is genuinely needed

The model should be told to use the supplied context for factual claims, identify uncertainty, cite the relevant source and say when the answer is not supported. A citation should point to a source the user is allowed to open.

Separate the retrieval result from the generation result in traces. If the answer is wrong, identify whether evidence was absent, wrong, ignored or mishandled during generation. This is the same separation used in AI agent evaluation and observability.

Define the “not enough evidence” path

A useful RAG chatbot has a deliberate fallback:

• If confidence or evidence is below the policy threshold, say the available sources do not answer the question.

• Offer a link to the relevant help-centre topic or a human support channel.

• Do not invent a policy, URL, price, date or order status.

• If the answer requires a live action, hand off to a tool or a human rather than pretending a document is current.

A refusal is not a failure when the evidence is genuinely absent.

Add tools without turning the bot into an unchecked agent

A chatbot that answers policy questions is different from a system that changes an order. If the product needs live order status, inventory or account data, use a narrowly scoped tool and return its result to the generator or workflow. A search over a stale PDF is not a substitute for the system of record.

Define tool contracts with strict schemas, authentication, tenant scope, timeouts, idempotency and audit IDs. A user must not be able to turn a document question into a privileged write simply by adding text to the prompt. The MCP authorization guidance provides useful principles for least-privilege scopes, token validation and protecting sensitive tools. The same integration work may involve custom application development when the retrieval service must connect to a business system rather than sit in a chat prototype.

If the system starts choosing tools and changing its plan, review the boundary between bounded RAG and agency. The comparison in AI agents vs chatbots explains why grounding does not by itself make a system an agent, and why tool permissions remain a separate control.

Add access control and privacy before launch

Retrieval must enforce authorisation before content reaches the model. Apply filters to the index or retrieval layer, then verify that the returned chunks belong to the user’s tenant, region or role. Do not rely on a prompt that says “do not reveal other customers’ data.”

Log a redacted trace with source IDs, policy decisions, latency and outcome. Avoid storing raw prompts, full invoices, payment details or customer contact information by default. If a source is personal data, document the purpose, access, retention and deletion path. India’s Digital Personal Data Protection Rules, 2025 and the DPDP Act commencement materials are relevant starting materials, but the implementation remains phased. Use qualified advice for your obligations and vendor contracts.

Untrusted documents are also a security boundary. A PDF can contain instructions that try to override the system prompt. Keep retrieved text clearly separated from developer instructions, validate structured fields, and do not allow retrieved content to grant tool permissions. Test prompt injection with documents, support attachments and web pages before exposing a write-capable workflow.

Make evaluation part of the build

Create a labelled set before tuning. Include normal questions, exact identifiers, paraphrases, ambiguous questions, missing-information questions, stale-source questions, cross-tenant attempts and adversarial documents. For each case, record expected source IDs, acceptable answer facts, forbidden claims, required citation behaviour and whether the system should refuse or hand off.

Run four test groups:

• Ingestion: Does the right text and metadata enter the index?

• Retrieval: Does the correct evidence appear at the chosen depth?

• Generation: Given that evidence, is the answer faithful, useful and correctly cited?

• End to end: Does the user get the right outcome within the latency and cost budget?

Track the index and model versions with every result. A “better” prompt that silently uses an older index is not a valid comparison. Add incident cases to the suite and keep a held-out set for release decisions.

India-specific deployment checklist

For an Indian D2C, SaaS or internal assistant, test at least these contexts:

• English, Hindi, regional-language and Hinglish questions

• Product names, SKUs, invoice numbers and error codes

• WhatsApp or support transcripts with formatting noise

• GST and policy questions linked to an authoritative source

• UPI, card and cash workflows that remain outside document retrieval

• Multiple tenants, roles, locations and languages

• Documents that contain customer, employee or supplier data

A bot that answers a clean English return-policy question but fails “Mera order kahan hai?” has not solved the local support problem. Benchmark the actual traffic distribution. If documents are multilingual, choose an embedding and retrieval setup that your own tests support; do not assume an English benchmark transfers.

A seven-step launch plan

1. Scope one bounded task

Write the questions the bot will answer, the sources it may use, the actions it must not take and the handoff path. Exclude a second task until the first has a baseline.

2. Assemble approved content

Remove drafts, duplicate pages and irrelevant navigation. Assign an owner and review date to every source. This is often more valuable than a sophisticated model.

3. Ship a traceable index

Use stable chunk IDs, source metadata, access filters, versioning and a re-index job. A vector database is a component, not the architecture.

4. Build a measured query service

Start with semantic retrieval and filters, then compare hybrid search and reranking against labelled questions. Preserve returned source IDs and scores.

5. Add grounded generation and citations

Constrain the prompt, require an evidence-based refusal, return citation metadata and test unsupported questions explicitly.

6. Instrument and secure the path

Add traces, stage latency, token cost, retrieval metrics, redaction, rate limits, tenant tests, prompt-injection tests and audit IDs. Connect business records through scoped tools only when the task needs them.

7. Release through a shadow rollout

Run the bot beside the existing search or support process. Review a sample of answers, source access, latency, handoffs and costs. Expand only the branches that meet the agreed criteria.

Frequently asked questions

Do I need a vector database to build a RAG chatbot?

A vector store is a common implementation, but it is not the only way to search documents. A production build needs reliable retrieval, metadata, permissions and evaluation. Start with the simplest index that meets your corpus and scale requirements; the database brand is not the quality metric.

How should I choose chunk size?

There is no universal token count. Split around meaningful sections, preserve tables and eligibility rules, and test chunks against labelled questions. If a chunk cannot be understood without its parent section, include a title, section path or neighbouring context.

Can RAG answer real-time order status?

Not reliably from documents. Use a read-only tool or workflow against the system of record, then show the live result. The tool call should be separately permissioned and observed.

How do I know if the answer is grounded?

Check whether the claim is supported by the retrieved source, whether the citation points to the correct section and whether the answer refuses when evidence is missing. Use a faithfulness evaluation and periodic human review; do not rely only on citation presence.

Is it better to use a hosted or self-managed RAG stack?

The right choice depends on data sensitivity, team skills, volume, latency, vendor lock-in and operating budget. Compare complete lifecycle ownership, not only model price. A hosted API can simplify the first prototype, while a controlled stack may suit sensitive or specialised workloads.

Build the evidence path, not just the chat UI

To build a RAG chatbot responsibly, treat ingestion, retrieval, generation, permissions, tools and evaluation as one system. Start with approved sources and a small query set, keep the first task bounded, measure retrieval separately from answer quality and make unsupported answers visible. The result should be an assistant your operators can inspect and improve—not a fluent interface that hides a weak evidence pipeline.

Planning a production RAG assistant for your business? Share your documents, channels and risk requirements with GrowMyStore.

How to Build a RAG Chatbot: Production Architecture and Checklist