Most support questions on a rewards platform have been asked before: when are points paid, why was my review rejected, how do I withdraw. The chatbot's job is to find the written answer to those and to hand the rest to a person without making anything up. It is a retrieval system first and a language model last.
Options
Before building it I wrote down five options and compared them on monthly cost, answer quality, server load and how far each could be customised.
| Option | Note from the comparison |
|---|---|
| A hosted chat widget | Compared, not chosen |
| A custom bot that sends every question to a language-model API | Compared, not chosen |
| A self-hosted open-source model | Needs a GPU server, and the service runs on a machine without one |
| A rule-based FAQ bot | No natural-language understanding |
| FAQ retrieval first, a model only as fallback | Chosen: near-zero monthly cost, high answer quality, low server load, high customisability, and an API key that was already in hand |
The cost figures in that comparison were estimates built on an assumed split between retrieved and generated answers, so none of them are quoted here.
The pipeline

A question passes through these stages.
Cache. The question is normalised and hashed. An in-process cache of 500 entries with a seven-day lifetime answers repeats without any search.
Audience filter. Each FAQ is tagged with who it is for: testers, advertisers, guests, or everyone. The search considers the FAQs tagged for the asker’s type or for everyone.
Lexical search. MongoDB’s text index over the FAQ collection, weighted 10 for the question, 5 for curated keywords and 1 for the answer. The top five results are kept if their normalised score is at least 0.3. Korean attaches particles to nouns, which a general-purpose text index does not strip, so if nothing passes there is a second lexical pass with a small tokenizer of its own: split on whitespace, drop one trailing particle from longer tokens, and score matches against keywords, then the question, then the answer.
Short-circuit. If the best lexical score is 0.7 or higher, the search stops there and the embedding comparison is skipped.
Embedding search. The question’s vector is computed once, at the start of the call, with a small embedding model. Each FAQ document stores its own vector, built from its question and the start of its answer. Similarity is a plain cosine loop in Node over every active FAQ, keeping matches of 0.75 or more. There is no vector index, and at about a hundred FAQs none is needed: the loop is a hundred dot products.
Fusion. If only one list has results, it is used as it is. If both do, each FAQ scores 0.4 × lexical + 0.6 × embedding.
Accept. The top result is returned if it scores 0.4 or more, together with up to two more results as suggested questions.
Model fallback. Below 0.4, a small chat model answers from a hand-written prompt about the platform’s rules, the user’s type and the last four turns of the conversation. The answer is scanned for a list of hedging phrases. A confident answer is returned and cached. A hedged one is returned with a block that points the user to a one-to-one inquiry.
Timeout and errors. The whole call races a 20-second timer. A timeout, or any error, escalates to a person. A failed embedding call does not fail the request: the search continues with the lexical stage alone.
What gets logged
An answer from the cache, from an FAQ, from the model or from the escalation branch writes one row. The 20-second timeout and the error path return without one. This is the row’s shape.
// chatbot log: one row per answer (shape)
{
sessionId, userId, userType,
query,
response,
source, // "faq_keyword" | "faq_embedding" | "ai_generate" | "escalation"
matchScore, // the match score; null for cached, generated and escalated answers
faqItemId, // which FAQ answered, when one did
responseMs,
createdAt
}
An admin route aggregates these rows by source, by most frequent question and by day.
What the evaluation showed
In November 2026 the retriever was evaluated on the 103 active FAQs and 206 paraphrases of them written by people.
The finding that mattered was about the score. The retriever’s score cannot be used as a confidence value. The lexical short-circuit returns as soon as the text index is confident, and the text index is confident about shared words, not shared meaning. A question that reuses the wording of one FAQ while asking about another reaches the top with a score of 1.0, and the embedding stage that would have corrected it never runs.
That matters for anything built on top of retrieval that needs to know it has the right FAQ, not just a plausible one. A later feature, a chat that pays points, could not rest on a score that is sometimes wrong at its maximum. It got a separate, stricter matcher based on character similarity to the FAQ’s own question. At a threshold of 0.85 it matched 103 of 103 original questions with no wrong match, and the highest similarity between two different FAQ questions was 0.769, which leaves a margin below the threshold. It is a verbatim matcher for the FAQ’s own wording, and the paraphrase set was not used to score it.
The arithmetic of the fusion has a second consequence. When both lists have results, a FAQ that appears only in the lexical list scores at most 0.4 × 0.7 = 0.28, since anything at 0.7 or above would have short-circuited. That is below the 0.4 needed to be accepted. In the fused path the embedding score decides and the lexical score can only raise a candidate the embedding stage already found.
Failure modes
| What happens | What the system does | Covered by |
|---|---|---|
| The embedding call fails | Lexical results alone are used | The matcher’s fallback branch |
| The whole call exceeds 20 seconds | The user is handed to a person | The timeout race in the orchestrator |
| Nothing scores 0.4 | The model answers from the domain prompt | The accept threshold in the orchestrator |
| The model hedges | The answer is returned with an inquiry block and logged as an escalation | The hedge scan |
| A feature flag routes a user to another chat flow, which throws | The route falls back to this bot | Route tests: the fallback path, and flag-off output byte-identical to before |
Limits
- The score is a ranking signal, not a probability. The evaluation above is the evidence. Anything that needs certainty uses the stricter matcher.
- The tests mock the matcher. Audience filtering, input validation and fallback are tested. The scoring and fusion are exercised by the evaluation script, which is run by hand and not in CI.
- The cache is per process. With two server instances there are two caches, and a repeated question can miss once on each. The cache evicts in insertion order.
- The thresholds have not been validated against labelled data. The design document lists threshold validation as a phase that is still open. The paraphrase set is what a retune would use.
- A linear scan stops being free. At a hundred FAQs it is nothing. At tens of thousands it would need a vector index.
