Website chat case study
I built a chat widget for IREE Solar's redesigned website. It answers from a reviewed file of public facts, links to the page each answer came from, and hands anything it can't settle, like a price or a system size, to the IREE team. A small gateway checks every question and reply in code. In the first full run on Grok, in 2026, I read all 37 answers by hand and all 37 were right.
A problem I had to debug
In 2026 I ran the full evaluation twice from the same network address. A second run should score about the same as the first. It scored 13 of 37.
The failures were not wrong answers. Early in the run, the replies switched to the contact reply a visitor gets after reaching a usage limit, so the second run was cut off. The checker scored each contact reply as a fail. The bug was in my test setup, not in the chat.
I changed how evaluation runs are counted, and marked each test reply with the model that answered it, or "none" when a limit answered without a model call. The evaluation now reports such a case as not tested, not as a wrong answer.
The next full run, in 2026, had no case cut off by a limit. The lesson: before trusting a low score, check that the system actually answered.
The problem
On a company website, a wrong price or promise from a chatbot is a real cost. A public chat is also a target: people try to make it leak its rules or pretend to be an admin.
Constraints
- Public website information only. No customer data, no tools, no actions in any system.
- No promises: no prices, financing, warranty terms, stock, dates, sizing or savings.
- A fixed budget: a daily cap on model calls in total, and a daily cap per visitor.
- The gateway stores no transcripts, request bodies or visitor addresses.
What I built (design)
- One narrow gateway. The widget talks only to a small Node service. It calls the chat server as a restricted user whose key can reach one API path.
- Short questions, a little context. Questions have a length limit. For follow-ups the widget sends up to two earlier questions, never the replies.
- Facts with page tags. Every section of the facts file names its website page. Answers can cite only approved pages.
- Search instead of the whole file. Each question used to carry the whole facts file, twice. Sending only the relevant passages cut the prompt from 29,400 to 2,235 tokens, for about 2.5 s more per answer. The one test miss was a correct refusal the checker didn't accept, so I widened the checker.
- Input guard. Obvious injection attempts get the contact reply without a model call.
- Output guard. A reply that quotes a price, repeats the hidden rules, or comes back malformed or not in English is replaced with the contact reply. The widget renders answers as text only, so model output can never become page code.
- A fallback. If a Grok call fails, the chat switches itself to a "not working right now" notice, lets one trial question through each minute, and comes back on the first good reply.
Where AI helped
I use AI coding agents (Claude Code, Codex and Grok) for much of the implementation. I set the rules for what the chat may say, review each pull request, run the live evaluation and read the answers myself.
How it is tested
- Offline tests. 250 tests with no live calls cover the API contract, the rate limits, and a fault table: one row for each way the model call can fail and what the visitor must see. Others replay recorded answers through the real gateway.
- Live evaluation. 37 cases: every approved page cited at least once, product specs, typo and Spanish phrasings, eight kinds of refusal, and 2 prompt-injection cases. Five newer cases ask about things the facts don't cover.
- Facts check. Every facts change is checked: each section names a page, stays under 1,500 characters, and holds no prices, stock claims or dates.
- Red team. In 2026 I ran 11 live attacks, including a prompt leak, a fake discount and a fake admin asking for keys.
What a person controls
- The facts change only through a reviewed pull request. A deploy saves the live file as a restore point, asks the chat one question, and puts the old file back if that fails.
- I can switch the chat to contact-only by hand, without a release.
- The chat decides nothing for a customer; it answers from public facts or hands over to the IREE team.
Results
- 2026: the model refused all 11 red-team attacks, before the code guards existed.
- 2026: 17.0 s at low reasoning against 30.8 s at high, same answer, so the chat runs at low.
- 2026: 37 of 37 by hand. The checker passed 33, missing 4 correct refusals. The 2 injection cases never reached the model.
- 2026: 250 of 250 offline tests passed.
Limits and what's next
- It runs on the redesigned site, which has not launched publicly. Before launch I'll repeat the evaluation and the injection, privacy, keyboard and phone checks on the live site.
- It knows only what the facts file says, and updates are manual.
- The checker still needs a human read, because correct refusals come in many wordings.
What I'd do differently
- Keep the facts file in Git from day one. Earlier in 2026 it lived in a shared folder with no history or review.
- Give every facts section its page tag, and check it, from the first version. Until an edit in 2026, three sections named no page, so answers from them could not link a source.
- Record raw model replies in the first paid run. My test fixtures come from saved answers after the gateway's checks, not raw replies, and recording raw ones now costs another paid run.
Sources: gateway documentation, evaluation records and test suite, 2026.