Asadullah Yousaf

AI Receptionist Design: The LLM Writes, Code Decides

By Published 4 min read

agentic workflowsAI receptionistMastramulti-tenant SaaSlead qualification
Deskly owner dashboard showing first-reply time, booked leads and hot leads

TL;DR

A reliable AI receptionist lets the language model write the replies but keeps every business decision in tested code: lead scoring, owner assignment, booking, escalation and human handoff. In Deskly's live demo this gave a 13-second median first reply, with 91% of leads answered within a minute.

Key takeaways

  • Let the LLM write the words; let deterministic, tested code decide score, owner, booking and handoff.
  • Ask the same qualifying questions, one at a time, so every lead is scored on the same evidence.
  • Every lead needs one named owner, plus a timed staff reminder and then a manager alert if nobody acts.
  • Tenant isolation belongs in the database (Postgres Row-Level Security), never in the prompt.
  • Live demo result: 13 s median first reply, 91% answered within a minute, 4 of 11 leads booked.

Small service businesses lose leads in three predictable ways: the reply comes too late, each staff member asks different questions, and nobody clearly owns the lead. Deskly is an AI receptionist I built to fix all three. It replies to every inbound lead in under 60 seconds on WhatsApp, Instagram, web forms and missed calls, qualifies the lead, scores it Hot, Warm or Cold, assigns one named owner and books the appointment.

The design rule that made it reliable is simple: the LLM writes the words, tested code makes the decisions. This post explains why, and how the pieces fit.

Why shouldn't the LLM make the decisions?

Language models are good at conversation and bad at being consistent. Ask the same model to score the same lead twice and you can get two answers. For a business that is unacceptable: a Hot lead marked Cold is lost revenue, and a booking outside real opening hours is an angry customer.

So Deskly splits the work:

JobDone byWhy
Writing replies in the business's voice, in English or ArabicLLM (Gemini via Mastra)Natural language is what models are good at
Asking the next qualifying questionDeterministic workflowEvery lead must answer the same questions
Scoring Hot / Warm / ColdPure functionSame input, same score, unit-tested
Assigning the ownerPure functionRule-based by service, auditable
Booking a slotPure function over real hours, staff and service durationNever books an impossible slot
Escalating when nobody actsDurable scheduled job (Inngest)Must fire even if the server restarts

The scoring, assignment, opening hours, escalation and lead lifecycle logic lives in a pure domain package shared by the dashboard, the agent and the background jobs. Because those are plain functions, they are tested like any other code instead of being "prompted" into behaving.

How does a lead flow through the system?

  1. Lead arrives on WhatsApp, Instagram, the web form or as a missed call.
  2. Webhook is verified (Twilio signature), stored and acknowledged, then handed to the agent with a shared secret.
  3. AI replies within seconds, as the business, in the lead's language.
  4. Qualifying questions are asked one at a time, always the same set, configured per business in settings.
  5. Score is computed from the answers: Hot, Warm or Cold.
  6. One owner is assigned by service.
  7. Booking is offered from real availability, with confirmations, reminders and no-show follow-ups.
  8. Escalation: if the owner does not act, a timed staff reminder fires, then a manager alert.

The ordering matters. Acknowledging the webhook before the agent runs means a slow model call never makes the channel provider retry and create duplicates.

What happens when a human needs to step in?

Some conversations should never be handled by an AI. In a clinic, the obvious one is a medical question. Deskly's agent refuses medical advice and hands the conversation to staff. While staff are in the conversation the agent stays paused, and it resumes automatically when staff hand it back.

Guardrail evals run against the agent to check two things it must never do: give medical advice, and invent prices. Prices come from the business's own service settings, not from the model.

In the live demo, 1 of 11 leads (9%) was handed to a person, for a medical question or complaint. That is the handoff working as designed, not a failure.

How is each business's data kept separate?

Deskly is multi-tenant: many businesses on one deployment. Tenant isolation is enforced by Postgres Row-Level Security (through Drizzle on Supabase) and covered by RLS integration tests. The model never chooses the tenant: the system fixes it, and because the database itself enforces isolation, even a misbehaving agent cannot read another business's leads.

Replies to test leads are also blocked from ever reaching a real phone, which makes it safe to demo and test on the live system.

What were the results?

Deskly was demoed with a fictional business, Glow Aesthetic Clinic in Dubai. Over the last seven days of the live demo:

  • Median first reply: 13 seconds. 91% of leads were answered within a minute.
  • 36% of leads booked (4 of 11) in the same window.
  • 9% handed to a person (1 of 11), for a medical question or complaint.

The sample is small and it is a demo business, so treat these as proof the system behaves as designed, not as a conversion benchmark.

On the engineering side: about 22,000 lines of TypeScript across 2 apps and 5 packages, built over 11 milestones, with 27 test files plus a Playwright end-to-end test running against the live site.

What would I do the same way next time?

  • Decide the deterministic core first. Write scoring, assignment and booking as pure functions before writing a single prompt.
  • Put isolation in the database, not in the prompt or the application layer alone.
  • Use durable jobs for anything time-based. Reminders and escalations that silently die on a restart are worse than none.
  • Write guardrail evals for the things that would embarrass the business, starting with advice the business is not allowed to give and prices it never quoted.

Next on the roadmap is Instagram DM and comment triage: filtering incoming messages by keyword or intent, queuing anything borderline for staff approval, then engaging automatically once approved.

See the Deskly case study for screenshots, the full stack and the demo video, or try the live demo. For the retrieval side of agent systems, read Multilingual YouTube RAG: Architecture Notes.

Frequently asked questions

What is an AI receptionist for a service business?

An AI receptionist replies to inbound leads on channels like WhatsApp, Instagram, web forms and missed calls within seconds, asks qualifying questions, scores the lead, assigns it to a staff member and books an appointment from real availability, handing off to a person when needed.

Should the LLM decide how to score or route a lead?

No. In Deskly the language model only writes replies. Scoring, assignment, booking and escalation are pure, tested functions, so the same lead always gets the same outcome and the behaviour can be audited and unit-tested.

How do you stop an AI receptionist giving medical advice or inventing prices?

Deskly refuses medical advice and hands the conversation to staff, pausing the agent until staff hand it back. Guardrail evals check that the agent never gives medical advice and never invents prices, and prices come from the business's own settings.

How do you keep each business's data separate in a multi-tenant AI SaaS?

Enforce isolation in the database with Postgres Row-Level Security and cover it with integration tests. In Deskly the model never chooses the tenant; the system fixes it and the database enforces the boundary.

How fast should an AI receptionist reply to a lead?

Within a minute. Deskly's target is under 60 seconds on every channel; on the live demo over the last seven days the median first reply was 13 seconds and 91% of leads were answered within a minute.