Skip to content
Hamza
AI engineering

How I Built Kairo, an AI Chat Agent, From Plan to Production (With the Eval Numbers)

The full build of Kairo, the AI assistant on this site: planning, retrieval, integrations, 141-case evals, safety, and deployment. Real scores, real mistakes, and a link to chat with it.

1 December 2026 · 7 min read

A chat assistant connected to an evaluation scoreboard

Kairo is the AI assistant on this website. It answers questions about my work, books calls on my calendar, collects leads and hands serious conversations to me on WhatsApp. It went live on 8 November 2026. This is the honest build log: how I planned it, what I connected, how I tested it, what broke, and what I would do again.

If you want to see the result first, open any page on this site and use the Kairo button on the right edge of the screen. Ask it something hard. Then come back and read how it was made. If you are a business owner thinking about an AI assistant, or an agency choosing a partner, this is the process I follow for client builds too.

The Kairo chat widget open on hamzabuildai.com, offering real open call times
Kairo on the live site, offering real open times from Cal.com. The full product tour is in the Kairo walkthrough.

Why build an AI assistant on your own site?

Two reasons. First, a visitor with a question at 11 PM should get an answer, not a contact form. That is the same speed-to-lead problem I solve for home service companies, which I explain in the speed to lead guide. Second, I sell AI systems, so my own site should be proof that I can build one properly, not a template with my logo on it.

I also treated it as a lab. I called the workshop Karkhana, which is the Urdu word for workshop, and set one rule for it: nothing ships without an eval score.

Step 1: Planning and strategy

Before writing code I wrote down what Kairo must and must not do. It answers from approved knowledge only. It books through Cal.com. It captures a lead with consent. It escalates to me on WhatsApp when it should. It never quotes prices, never invents a client result, and never follows instructions hidden in a visitor's message.

Then I made the big decisions in short written records, one per decision, with what I picked and what I rejected. Examples: one private repository with Python for the API and TypeScript for the widget; n8n for background jobs only, never on the live reply path, because every extra hop adds delay; a database in third normal form so the same fact is never stored in two places, a mistake I made in an earlier product and refused to repeat.

Step 2: Building the knowledge base and retrieval

Kairo uses retrieval augmented generation, or RAG: it searches a curated knowledge base and answers from what it finds. The knowledge is Markdown files with a status field, and only files marked approved are ingested. Visitor messages never become knowledge unless I approve them.

I read the research before choosing a design. Anthropic's Contextual Retrieval write-up showed that adding short context to each chunk and combining keyword with vector search cuts failed retrievals sharply. The Lost in the Middle paper explained why long prompts hide facts. So I kept chunks small and the system prompt short.

Choosing an embedding model with a bake-off

I ran four open embedding models and two rerankers on my own server, an ARM machine with 4 cores and no GPU, against 130 test questions. The result surprised me.

SetupHit@5Query time (median)Memory
bge-small-en-v1.50.7918 ms429 MB
bge-base-en-v1.50.82102 ms840 MB
bge-small + reranker0.85+1,463 msn/a

bge-small was within 3 points of the best model, 5.7 times faster, and used half the memory. The rerankers lifted accuracy but added 1.4 to 2.6 seconds per message on this CPU, which a chat reply cannot absorb. I chose the small model and no reranker.

The mistake that taught me the most: tuning on the test set

Combining keyword search with vector search raised hit@5 to 0.85 and became the live setup. Then I tried tuning the weights. On the half of the questions I tuned on, the new weights looked slightly better. On the other half, which I had held back, they were worse: hit@5 fell from 0.81 to 0.76. The weights had fitted noise. Because I had split the data, I caught it before shipping. If you ever see an AI vendor quote one accuracy number with no held-out set, ask about this.

Step 3: Integrations

  • Cal.com: Kairo reads real availability and books inside the chat.
  • WhatsApp Cloud API: hot leads and escalations reach me as a message, with the conversation summary.
  • A model router: LiteLLM runs inside the API with fallbacks between models. Groq retired two of my original models on 16 August 2026, which broke my first fallbacks. Lesson: model names live in settings, not in code.
  • Paid providers only in production, because free tiers may use prompts for training and Kairo's chats contain names and emails.
  • A CRM view: leads from the site and forms flow into one place with a follow-up digest, using the same pattern I build for clients in GoHighLevel setup for home services.

Step 4: Evals, how I know it works

An eval is a repeatable test for an AI system. I wrote 141 visitor messages, each with the behavior Kairo should show (answer, book a call, escalate, or decline), the facts the reply must contain, and things it must never say. The set covers case study details, process questions, objections, safety attacks, typos and Roman Urdu, and questions Kairo should admit it cannot answer.

I score answers with an AI judge, and I log every run in Langfuse, an open source tool for tracing and evaluating AI applications, which I self-host. The scoring approach follows the ideas in the RAGAS paper: check faithfulness, relevance and coverage separately.

The Langfuse dashboard for the Kairo project showing 770 traces, 3.5 thousand scores and 0.31 dollars of model cost
The Kairo project in Langfuse over 30 days. Most traces are eval runs, which is the point: every change is scored.
MeasureResult
Cases passed (strict judge)83% of 141
Faithfulness (no unsupported claims)93%
Forbidden content (prices, invented facts)0% of answers
Cost per answerabout $0.0002
Time to first answer (median)0.6 seconds
Correct tool choice (book, escalate, answer)about 91%

Never trust an uncalibrated judge

My first AI judge agreed with my own grading on only 14 of 28 answers, 50%. It was far too strict. I graded 28 answers myself, wrote down my rules (a list question needs every item, not half), and rebuilt the judge. Agreement rose to 75%, and 82% if you count two answers that broke my own rules. I froze that judge and report results only against it.

The evals also found real bugs. Two answers invented that I work with a team, copied from the wording of a testimonial. I fixed it at the source with a pinned policy: Hamza works alone. A score only helps if you read the failures.

Step 5: Safety and cost controls before launch

  • Cloudflare Turnstile proves a real browser is chatting before Kairo spends anything. If it fails, the visitor still gets a booking link, not a dead chat.
  • Rate limits per visitor and per address, a daily budget check and a kill switch.
  • Answers only from approved knowledge, with a safe "I don't know, shall I ask Hamza?" path.
  • Prompt injection and impersonation cases in the eval set, so a safety fix cannot quietly regress.

Step 6: Deployment

The widget is one small script that loads after the page is interactive and lives in its own shadow DOM, so it never slows the page or clashes with its styles. The API, Redis, Langfuse and the workflows run in Docker on my own server through Coolify, behind a Cloudflare tunnel. Secrets live in the server's settings, never in git. Every change runs against the eval set first.

What is next: voice

I am giving Kairo a voice on the open source LiveKit stack, with open speech models on my own server, so a visitor can talk to it instead of typing. You can follow the progress on the Kairo Voice page.

What I would tell a business owner

  1. 1Decide what the assistant must never do before deciding what it should do.
  2. 2Write the test set before you pick the model.
  3. 3Hold some test cases back so you do not fool yourself.
  4. 4Calibrate any AI judge against a human, once, and freeze it.
  5. 5Put limits on cost and abuse before the first public visitor.

The same discipline runs through my client work. For a home service company it becomes an AI receptionist that answers every call and books the job; see the HVAC, plumbing and roofing builds. For a sales team it looks like the platform in How I Built Mint IQ. If you want something similar for your business, book a strategy call or just ask Kairo.

Want this built for your business?

Book a 20-minute call. You leave with 2 or 3 fixes, whether we work together or not.

Book a strategy call

Keep reading