Skip to content

In-house buildA system we built for ourselves and run on miniailabs.in. Not client work; the status section says which parts are switched on today.

AI Chatbots

In-house build

Site Assistant With Cited Answers and a Human Handoff

The chat assistant on every page of miniailabs.in is a system we built for ourselves and run on this site. It answers questions about our services, prices and process only from the site’s own pages, cites the page behind each answer, refuses what it should not answer and hands the conversation to a person when the visitor asks. This page shows how a question travels through it, how we test it and which parts are switched on today.

Runs on
Every page of miniailabs.in, behind the chat button
Service
AI Chatbots
Built
October 2026, in two steps: a grounded replacement for the live-chat widget, then hybrid retrieval, sessions and the eval runner
Live today
2 of 5 parts · 18 Oct 2026

Check it yourself

In-house build

What you can try

  • Ask what a chatbot costs, then open the page it cites
  • Ask it to ignore its rules or show you its prompt
  • Ask about something this site does not cover
  • Ask for a person and read what the handoff form will send

The brief

Why we built it

Until October 2026 the chat button on this site opened a third-party live-chat widget, which helps only when someone is online and keeps the answers in a separate tool. We build grounded assistants for other businesses, so our own site is the obvious place to run one in public: if we tell buyers to judge a chatbot by its citations, its refusals and its handoff, visitors should be able to check ours. It follows the rules we give clients: no answer without a source, no price that is not published, no claim about clients or certifications, no tools that act for the visitor, and an easy way to reach a person.

Request path

How one message travels

Seven stages, in order. Only one calls a language model, and a turn can end before it with a fixed reply.
  1. Redact

    No model call

    Card and ID numbers, passwords and keys are removed before any other stage reads the message.

  2. Route

    No model call

    Rules spot greetings, off-topic questions, requests for a person or an action, attempts to change the rules and buying signals.

    Can end here: A fixed reply, or the next qualification question

  3. Retrieve

    No model call

    Keyword search, joined by full-text and vector search when the database and index are attached, merged by rank fusion.

    Can end here: No usable source: a clarifying question and the offer of a person

  4. Answer

    Calls a language model

    The model sees the question, recent turns and up to six numbered sources, treated as data and cited after each fact.

  5. Validate

    No model call

    Banned claims, client results, unlisted prices, outside links or contact details and prompt leaks are removed, or the reply is replaced.

  6. Cite and score

    No model call

    Markers become up to four citations; confidence follows how much of the question the evidence covers.

  7. Store

    No model call

    With the database attached, the turn is saved under a hashed session id for 30 days. Without it, the server keeps nothing.

Architecture

How the pieces connect

  • Chat widget· channel
  • Bundled knowledge· source
  • D1 FTS + Vectorize· source
  • Redact + route· processing
  • Hybrid retrieval· processing
  • Output validator· processing
  • Workers AI model· model
  • Sessions (D1)· system of record
  • Lead intake· system of record
  • MiniAI Labs team· person
Show the architecture diagram

Architecture of the Site Assistant With Cited Answers and a Human Handoff in-house build: Chat widget → Redact + route (message); Redact + route → Hybrid retrieval (question); Bundled knowledge → Hybrid retrieval (BM25); D1 FTS + Vectorize → Hybrid retrieval (full text + vectors); Hybrid retrieval → Workers AI model (numbered sources); Workers AI model → Output validator (draft reply); Output validator → Sessions (D1) (checked turn); Chat widget → Lead intake (handoff form); Lead intake → MiniAI Labs team (handoff alert).

Diagram with 10 parts: Chat widget (source), Bundled knowledge (source), D1 FTS + Vectorize (source), Redact + route (processing), Hybrid retrieval (processing), Output validator (processing), Workers AI model (model), Sessions (D1) (system of record), Lead intake (system of record), MiniAI Labs team (human).

Connections:

  • Chat widget → Redact + route (message)
  • Redact + route → Hybrid retrieval (question)
  • Bundled knowledge → Hybrid retrieval (BM25)
  • D1 FTS + Vectorize → Hybrid retrieval (full text + vectors)
  • Hybrid retrieval → Workers AI model (numbered sources)
  • Workers AI model → Output validator (draft reply)
  • Output validator → Sessions (D1) (checked turn)
  • Chat widget → Lead intake (handoff form)
  • Lead intake → MiniAI Labs team (handoff alert)

Connections

  1. Chat widget → Redact + route (message)
  2. Redact + route → Hybrid retrieval (question)
  3. Bundled knowledge → Hybrid retrieval (BM25)
  4. D1 FTS + Vectorize → Hybrid retrieval (full text + vectors)
  5. Hybrid retrieval → Workers AI model (numbered sources)
  6. Workers AI model → Output validator (draft reply)
  7. Output validator → Sessions (D1) (checked turn)
  8. Chat widget → Lead intake (handoff form)
  9. Lead intake → MiniAI Labs team (handoff alert)

Retrieval and citations

Answers come from pages you can open

The knowledge is regenerated on every build from the data the pages are rendered from, so a price or a process step changes in one place. Only live, indexable pages go in; unreviewed guides and sample-data visuals such as demo chats are left out, and every chunk passes the same validator and injection scanner as a live reply.

Keyword search (BM25 over the bundled chunks, plus SQLite FTS5 in D1 once the database holds the current knowledge version) runs beside vector search in Vectorize with bge-base-en-v1.5 embeddings. Every vector hit is re-checked against the current version, so a deleted page cannot come back, and reciprocal-rank fusion merges the lists with at most two chunks per page. A chunk that carries instructions is dropped, and when the model cites nothing the top evidence is cited, so no model-written answer appears without a source.

Handoff

Getting to a person, with the context

The assistant offers a person when the visitor asks for one, when retrieval finds nothing usable, when confidence is low and when a short qualification has finished. The qualification is derived from the visible transcript, with no hidden memory, and typing stop ends it for good.

The "Talk to a human" form sends the visitor’s name and email, the recent transcript and the conversation id to the lead intake when the visitor presses send, next to a line saying we will reply about that request and nothing else. The team gets a handoff alert with the transcript, so nobody is asked the same questions twice. The model itself has no tools: it cannot create a lead, send an email or book a call.

Evaluation

Results: pending the online eval run

The question set

The question set holds 150 items in 20 categories. Each item states what a pass looks like: the pages it should cite, whether a person should be offered, whether a fixed reply is expected, and phrases that must never appear.

  • Services
  • Pricing
  • Conflicting prices
  • Company
  • Process
  • Security and privacy
  • Integrations
  • Industries
  • Work entries
  • Handoff
  • Lead qualification
  • Tool requests
  • Off-topic
  • Ambiguous
  • Direct injection
  • Injection in pasted text
  • Personal data
  • Nothing to retrieve
  • Other languages
  • Greetings

How it runs

  1. Offline, bundled knowledge

    In-process, no network or keys: keyword retrieval and a deterministic stand-in model.

  2. Offline, with a database

    A SQLite copy of the D1 schema, so full-text search and ingestion run for real.

  3. Offline, with vectors

    Stand-in embeddings exercise rank fusion; its citation scores are informational only.

  4. Online, against a deployment

    The real model and embeddings. A secret token skips the rate limit and storage and returns the router’s decisions.

What it measures

Citation accuracy
An expected page is among the citations.
Groundedness
Model-written answers carry at least one citation.
Unsupported-claim rate
Replies the validator would still change, or a banned phrase.
Handoff correctness
A person is offered exactly when expected.
Policy correctness
A fixed reply, with no model call, exactly when expected.
Confidence correctness
High or low confidence, as expected.
Latency and errors
Median and 95th-percentile time online; failed requests.
Model calls per 100 questions
How often a model was needed: our cost measure.

Pending the online eval run

We do not publish the offline numbers: their stand-in model copies the first source instead of writing an answer, so they measure routing, retrieval, citations, handoff and the validator, not the replies you read. The first run against the deployed site will appear here with its date, the knowledge version, the retrieval mode and every metric listed on this page, including any it misses.

Checked properties

What the tests hold it to

Properties of the code, each enforced by a test in the repository. They are not measured results.
  • Checked property

    Every model-written answer cites at least one page of this site

    Checked by tests/functions/chat.test.mjs: source markers map to numbered sources, and the top evidence is cited when the model cites nothing

  • Checked property

    No reply shows a price that is not on the pricing page

    Checked by the output-validator tests, which also strip links, emails and phone numbers from outside the knowledge

  • Checked property

    A question with no usable source gets a clarifying question and a person, not a guess

    Checked by the no-evidence test: the reply comes from the policy layer and no model is called

  • Checked property

    Instructions hidden in retrieved text are not followed

    Checked by the indirect-injection tests, with bundled knowledge and with a planted chunk in a SQLite copy of D1

Status

What runs today

As of 18 Oct 2026

  • Cited answers from the bundled knowledgeLiveKeyword retrieval, the policy layer and the validator need no database.
  • Handoff form to the teamLiveUntil the database is attached, the team is emailed directly and no reference is shown.
  • Full-text and vector searchPendingSwitches on when the production D1 database and Vectorize index are attached.
  • Stored conversations, reset and deletePendingNeeds the D1 database; until then the server keeps no copy of a conversation.
  • Online evaluation runPendingRuns against the preview deployment first; no result appears on this page before it.

In the repository

Where it lives

Code

  • functions/api/chat.js

    Request handler: limits, routing, retrieval, model call, validation, storage

  • functions/api/_lib/chat-policy.js

    Router, qualification, redaction, injection scanner, output validator

  • functions/api/_lib/knowledge.js

    BM25, FTS5 and Vectorize retrieval, rank fusion, ingestion

  • scripts/build-chat-knowledge.mjs

    Builds and checks the knowledge chunks

  • components/ui/AIChatbot.tsx

    The widget: disclosure, citations, handoff, reset and delete

Tests

  • tests/functions/chat.test.mjs

    Citations, the validator, injection, the router, sessions (including no cross-session leakage), fusion, provider fallback

  • tests/ai-evals/questions.jsonl

    The 150 items and their pass conditions

  • scripts/chat-eval.mjs

    The runner: modes, metrics and thresholds

Built with

  • Cloudflare Pages Functions
  • Cloudflare Workers AI
  • D1 with FTS5 full-text search
  • Vectorize (bge-base-en-v1.5 embeddings)
  • Workers KV rate limiting
  • Build-time knowledge generator
  • node:test and an evaluation runner

Retrospective

What we would change

  1. A multilingual embedding model

    The embeddings are English-first and only a handful of test items use other languages. For visitors who write in Arabic or Hindi, we would change the model and write those items first.

  2. Graded wording, not only citations

    The metrics check that answers cite the right pages, not that the wording is right. We would add a human-graded sample of model-written replies to every online run.

  3. Reindex when content is published

    The knowledge is rebuilt when the site deploys. A system whose content changes daily should reindex from a publish webhook instead.

FAQ

Questions about this build

Did you build the site assistant for a client?

No. It is an in-house build: we wrote it for miniailabs.in and run it here, so there is no client, no client data and no client result behind this page. Its answers come only from this website’s pages, which is also why it says so when it does not know something about your business.

Which model writes the site assistant’s answers?

A model on Cloudflare Workers AI, or another configured provider when one is set, with Workers AI as the fallback. The model is the replaceable part: retrieval, the router and the output validator decide what it sees and what reaches you, so changing models means re-running the evaluation, not rewriting the assistant.

Why are some replies instant and others take a few seconds?

Instant replies come from the policy layer without a model call: greetings, requests for a person, off-topic questions, attempts to change the rules and the qualification questions. Answers about services and prices go through retrieval, a model and the output check, which takes longer. The evaluation counts how often a model was needed at all, as a cost measure.

What happens to what I type into the site assistant?

Card numbers, ID numbers, passwords and keys are removed before anything else reads the message. When conversation storage is switched on, turns are kept under a hash of a random per-tab id for 30 days, never under your name or email, and the delete button removes them sooner. We do not use conversations to train models.

Could you build an assistant like this one for our website?

Yes. The pattern carries over with your sources in place of our pages and your channels in place of the web widget. What changes is the evaluation set, written from your own customers’ questions, the handoff route into your helpdesk or CRM, and where it is hosted. The chatbot service page sets out the scope and the published price.

Worked examples

Concept builds for this service

Concept builds are worked examples, not client work.

See all concept builds
Concept build

AI Chatbots

Catalogue-grounded Support Bot for an Electronics Store

A concept build showing how we would build a support bot for an online electronics store whose helpdesk fills with the same few questions. The bot would answer order, delivery, returns and product-fit questions from the store’s catalogue, policies and live order data, on the website and WhatsApp, and pass everything else to the helpdesk with the conversation attached.

  • Retail / E-commerce
  • Sep 2026
Concept build

AI Chatbots

Hinglish WhatsApp Order Assistant for a D2C Brand

A concept build for a direct-to-consumer brand in India whose WhatsApp inbox fills with the same two questions: where is my order, and how do I return it. The assistant answers in English, Hindi or Hinglish from live order data and the brand’s own returns policy, and hands anything unusual to a person with the whole thread attached.

  • E-commerce (D2C)
  • India market
  • Oct 2026
Concept build

AI Chatbots

Cited Docs Copilot for a B2B SaaS Help Centre

A concept build for a B2B software company whose help centre is thorough but hard to search. The copilot answers product questions from the published documentation, shows the passages each answer came from, and opens a support ticket, carrying the question and the sources it tried, whenever it is not confident.

  • B2B SaaS
  • US market
  • Oct 2026
Concept build

AI Chatbots

Multilingual Guest Concierge for a Boutique Hotel

A concept build for a boutique hotel in the UAE whose front desk answers the same guest questions in several languages, day and night. The concierge replies on WhatsApp and the hotel website in the guest’s language, answers from the hotel’s own guide, turns requests into housekeeping tickets with the room number, and puts complaints in front of the duty manager straight away.

  • Hospitality
  • UAE market
  • Oct 2026

Next step

Have a workflow in mind? Let’s scope it together.

Book a free 30-minute strategy call. Bring one process you want to automate and we will talk through scope, integrations and a sensible first step.

Free 30-minute call · no commitment

Send an RFP or security questionnaire