Guides

RAG Chatbot: How to Build One for Customer Support

Luke Tan

Last update

To build a RAG chatbot for customer support, split your help content into short chunks, turn each chunk into an embedding, and store the embeddings in a vector database tagged with who is allowed to see them. When a customer asks something, retrieve the closest chunks, filtered by those tags, and have a language model answer only from what came back, citing the page and saying so when nothing matches. Engineers can build that with Postgres and pgvector or with open models from Hugging Face. A platform such as Wonderchat runs the same pipeline on your help center and files, and most teams are live the same day. The pipeline is the easy part. The content decides whether it works.

Why most RAG chatbots disappoint after the demo

The demo always works. Someone loads twenty help articles into a notebook, asks five questions those articles answer, and gets five cited answers. Then it goes live, and customers ask the questions nobody wrote down.

Retrieval cannot find a page that does not exist. In practice, the model matters less than what the agent has to read.

So a RAG chatbot is a documentation project with a retrieval step attached. You can choose the stack in an afternoon. The pages it answers from take the real effort, and no framework writes them.

The second failure is harder to see. Wonderchat’s support team sees one failure most often, and it is not invention. It is retrieval pulling an archived policy and answering from it correctly: the citation is real, the answer is wrong, and nobody notices for weeks. RAG reduces made-up answers. It does not stop answers from the wrong page; only pruning the content does.

How a RAG chatbot works

RAG, retrieval-augmented generation, joins two components. The retrieval component turns the question into an embedding (numbers that capture meaning) and searches your indexed content for the closest passages. The generation component, a language model, writes the reply using only those passages.

A strong model fed the wrong passage writes a fluent, wrong answer, which is why most of the build below is about the index, not the model. The split is also why RAG suits support: you never retrain anything. You update a help article, re-index it, and the next answer uses it. AWS’s explainer on retrieval-augmented generation covers the architecture from the infrastructure side.

Plan two things before you write any code

1. A knowledge base worth retrieving from

Before anything is ingested:

  • Keep one answer per page, so retrieval never chooses between two versions of the refund policy.

  • Unpublish archived policies. If a page is out of date, it is out of the index.

  • Give every page a clear title and a public URL, because that URL becomes the citation.

  • Check last quarter’s most frequent ticket subjects against the help center. Any subject without a page is your first writing assignment.

2. Who is allowed to see what

A public support bot is simple: only public content goes in. An assistant that also answers staff questions is not. One developer described the requirement plainly on Reddit: “We don’t want employees from one department seeing sensitive data from another.”

The usual question is one chatbot per department or one shared one. A single, centralized index with role-based access control (RBAC) is easier to maintain: every document is embedded once, with one model setup. It needs three things:

  • Document tagging: metadata on every chunk at ingestion, such as department HR and access level confidential.

  • User authentication: the user’s role comes from your login system, never from anything typed into the chat.

  • Filtered retrieval: the search itself only considers chunks the user may see. Filtering after the model has written the answer is too late.

Path 1: build it yourself

Building from scratch gives you control of every step, from the model to the permissions, and makes you its owner for as long as the bot is live.

Step 1: Choose the stack

You need three parts: an embedding model, a vector store and a generation model. A common hosted stack uses OpenAI for embeddings and answers, with Supabase running Postgres with the pgvector extension as the store. Keeping vectors in Postgres means the department tag sits in an ordinary column beside each embedding, so one SQL function can filter by department and rank by similarity in the same query.

To run open models on your own hardware, Hugging Face hosts pre-trained models, including RAG models that load a tokenizer (text into model input), a retriever and a generator together. A general model copes with broad questions; one trained on your field handles its jargon better.

Step 2: Set up the environment

Create a Python virtual environment so library versions do not collide, then install with pip: the provider’s SDK and the vector store client for a hosted stack, or PyTorch and Hugging Face’s library to self-host. Self-hosted generation needs an NVIDIA GPU with CUDA. A hosted API needs only keys, kept in environment variables, never in code.

Step 3: Ingest, chunk and embed

Write a script that loads each document, splits it into chunks, embeds them and stores each with its source URL, page title, department and access level. Split on headings rather than every thousand characters, so a chunk holds one complete answer instead of half of two. Re-run ingestion when a page changes, and delete the chunks of any page you retire, or the archived-policy problem becomes yours.

Step 4: Retrieve, filtered by permission

Embed each question with the same model, search for the closest chunks, and apply the user’s department as a filter inside that search. Set a similarity threshold and return a handful of matches; three is a common start. If nothing clears the threshold, say the question is not covered rather than guess. Add keyword search if customers ask about product codes or error numbers, which embeddings match poorly.

Step 5: Generate with a strict prompt

Build the prompt from the retrieved chunks plus the question, and give the model three rules: answer only from the context, name the source page, and if the answer is not in the context, reply “I don’t have enough information to answer this question.” That last rule is the line between a support tool and a confident guesser. Send the source URLs back with the reply so the customer can check.

Step 6: Build the interface, the handover and the feedback loop

Streamlit is enough for an internal tool. A customer-facing bot needs a JavaScript widget, a route to a person when the answer is missing (email or a help desk ticket), and a feedback control on every reply. Log every question that fell below the threshold. That log is your writers’ to-do list.

Step 7: Test on real tickets, then keep testing

Before launch, run a few hundred real questions from past tickets and check each: was the answer right, and did it cite the right page? Repeat after every large content change. Follow-ups such as “what about annual plans?” only work if conversation history goes into each retrieval; the guide to chatbots with memory covers the options.

The main cost is not the per-token model fees (see OpenAI’s API pricing page). It is the engineer who owns ingestion, permissions, testing and the widget for as long as the bot runs.

Path 2: use a platform (Wonderchat)

A platform runs the same pipeline (chunking, embedding, retrieval, a strict prompt, citations), so your team’s time goes into the content. Here is the same build on Wonderchat’s AI Customer Service Agent.

Step 1: Connect the content

Point it at your help center, docs and website, and upload files. It chunks and indexes them; there is no ingestion script to maintain.

Step 2: Test it on your own questions

Every reply shows its source, and when the content does not cover a question, the agent says so instead of improvising. Run last month’s real tickets through it and click through the sources.

Step 3: Set the handover

On every plan the agent hands a conversation to a person with the full chat attached, as a ticket or by email, and live chat lets your team step in real time. It can also create a ticket in Zendesk or Freshdesk with the conversation attached. Use Wonderchat’s help desk, included on every plan, or keep yours and let the agent hand over into it.

Step 4: Put it where customers ask

The website widget and search bar come with every plan. Slack and WhatsApp come from Starter, while Microsoft Teams, voice chat, HubSpot and the analytics dashboard come from Basic, and Salesforce comes with Enterprise; email and the other channels are available too. It answers in 40+ languages, and the same engine runs the AI Sales Agent and the Internal AI Agent.

Step 5: Read the list of what it could not answer

The agent keeps the questions it could not answer in a review inbox: the Path 1 log, already built. Wonderchat agents flag the questions their customers’ content did not answer. Each is a page to write.

How long it takes: most teams are live the same day. Large documentation sets take longer. Wonderchat’s support team sees the slowest go-lives on accounts with more than 500 documentation pages: a median of 15 days, against the same day for 80% of agents that go live. The extra days go on retiring duplicates and archived pages.

What it resolves: Wonderchat reports about 75% of evaluated conversations resolved without a person (all accounts, long-run average). Jortt, a Dutch accounting platform, resolves about 92% of roughly 30,000 monthly inquiries without a person.

What it costs: Free includes 50 AI replies a month, refilled monthly, with no card: a plan, not a trial. Paid plans are Starter (500 AI replies a month), Basic (3,000) and Scale (9,000), with Enterprise on a custom quote. The meter is AI replies, not seats. Details are on the Wonderchat pricing page.

Security: SOC 2 Type II, GDPR, EU-hosted in Frankfurt, HIPAA BAA available. SAML SSO and private crawling come with Enterprise, and PII redaction is available.

Build or buy, side by side

Question

Build it yourself

Wonderchat

| Time to the first live answer

As long as ingestion, permissions, an interface and testing take your engineers

80% of agents that go live do so the same day; sets over 500 pages take a median 15 days

Who maintains the pipeline

Your engineers, permanently

The platform; your team maintains the content

Citations and “not covered” replies

You build both

Source on every reply; says so when the content does not cover it

| Unanswered-question log

You build it

Built in: the review inbox lists every question it could not answer

Cost model

Per-token model fees, hosting and engineering time

Free plan; paid plans metered on AI replies

Keep it accurate after launch

  • Write the missing pages first. Check each new page against the questions that prompted it.

  • Retire before you add. Every archived page left in the index is a future wrong answer with a real citation attached.

  • Measure resolution, and say what it counts. Track the share of conversations resolved without a person, plus customer satisfaction. A rate without a denominator is a guess wearing a number.

  • Connect it to where the work happens. A bot that cannot open a ticket or pass a lead to your CRM leaves the customer at a dead end.

Where Wonderchat loses

Build it yourself when one assistant must serve several departments with different permissions tied to your own identity system. A department tag on every chunk and a filter driven by the login is what a custom build does best; test that requirement on your own roles before choosing any platform, Wonderchat included. Build it too when the answer lives in a live database (an order status, an account balance) or when policy says no data leaves your own cloud. If the job is taking actions rather than answering (cancelling an order, changing a booking, issuing a refund), Ada, Decagon and Sierra take multi-step actions and are the better choice. If your help center already lives in Fin, formerly Intercom (Salesforce completed the acquisition in September 2026), Fin’s own AI agent has the deepest ecosystem around it. If it lives in Zendesk, Zendesk’s own AI agents are already installed.

Verdict: build or buy?

Buy, unless you can name the requirement a platform cannot meet. For a support bot answering from public help content, the pipeline is solved, and rebuilding it buys you maintenance, not answers. Spend the engineering hours on content and handover.

Build for role-based permissions inside one assistant, answers from live databases, or data that stays in your own cloud, and only if one engineer can own it for as long as it runs. Either way, read the unanswered-question list weekly and fix the content before you touch the model. If you are buying, the comparison of the best RAG chatbots in 2026 sets the platforms side by side, and the guide to AI knowledge base chatbots covers how to prepare the content they answer from.

Frequently asked questions

What is a RAG chatbot?

A chatbot that retrieves passages from your own content before it answers, then has a language model write the reply from those passages only. For support, that means answers drawn from your help center and docs, with a link to the page used.

Does RAG stop AI hallucinations?

It reduces made-up answers; it does not end them. The model can still answer from an outdated page that retrieval picked up, with a real citation. The safeguards are a strict prompt, a source on every reply, saying so when nothing matches, and pruning archived content.

How long does it take to build a RAG chatbot?

On a platform such as Wonderchat, most teams are live the same day; sets over 500 documentation pages take a median of 15 days. A custom build takes as long as ingestion, permissions, an interface and testing take your engineers, and then needs a permanent owner.

How do you keep one department’s documents away from another?

Tag every chunk with its department and access level at ingestion, take the user’s role from their login, and filter on it inside the retrieval query. One shared index with filters is easier to maintain than a separate chatbot per department.

Can a RAG chatbot hand a conversation to a person?

It should. When retrieval finds nothing, the bot should say so and route the conversation by email or as a help desk ticket. Wonderchat hands over with the full chat attached on every plan, by email or as a ticket, including into Zendesk or Freshdesk from Basic.

Stop answering the same questions. Let your docs do it.

Luke Tan

Luke Tan is the technical co-founder of Wonderchat. He is an RAG nerd, with an avid interest in gaming. If he is not prompting AI to figure out the next cool feature to build, he can be found trying out new AI tools.