Start a project →

Case study · Automation · In build

Inbound Lead Conversion: every lead booked once, none lost.

The deterministic core of an AI lead-conversion system for service businesses. A lead comes in, is deduplicated, qualified against the business’s own rules, checked against its service area and calendar, booked exactly once, synced to the CRM and queued for a confirmation text, with every step on an audit trail.

Stage
Phase 1 of 10
Test scenarios
9
Built with
TypeScript · Postgres
Vendors
Mocked, on purpose
The engineFastify · Postgres 16 · Zod

One lead, seven steps, one trace

Phase 1 proves the part that has to be right before any AI voice or vendor is plugged in: that a lead is never lost, never double-booked and never contacted against its consent. Every step writes an audit record under the lead’s trace ID, so one query shows exactly what happened and why.

  • Canonical lead events arriving by webhook from any channel
  • 20 tables: leads, identities, consent, appointments, outbox, dead letters, callbacks, audit
  • Adapters for the CRM and the calendar, so vendors swap in without touching the core
  • Multi-tenant: each business brings its own services, area and rules
View the source on GitHub ↗

Built for the bad days

Nine tests, mostly for things going wrong

The happy path is one test. The rest check what happens when a webhook repeats, a vendor is down or a lead should not be booked at all.

Honest status

What is real, and what comes next

Qualification is rules for now, in the same structured shape a model will return: the model will suggest, and the engine still decides. When voice arrives, nothing downstream changes.

PartStatusHow
Lead event schema and validationRealZod
Event and person de-duplicationRealPostgres UNIQUE constraints
Exactly-once bookingRealidempotency key plus a recheck
Consent ledger and suppressionRealchecked before any outbound message
Outbox and dead lettersReal tablesthe delivery worker comes next
QualificationReal, rule-basedthe slot a model’s structured output will fill
CRM and calendarMockedadapters for HubSpot / GoHighLevel and Google Calendar
Voice (Retell), SMS and email (Twilio, Resend)Next phasesconfirmations are queued, not sent
Human transferPhase 6

Work with us

Want something like this built?

Automate your lead intake → See all work

This system is offered as a product: Lead Responder. Meet who builds it.

Ask the agentOnline now