# Leadline

> A speed-to-lead system that answers, qualifies, and books a new lead in seconds.
>
> https://pravda.systems/work/leadline · 2026-07-17

**Problem.** A new lead that waits an hour for a reply has usually already hired whoever answered first. Businesses lose real, high-value jobs to response time alone, most of all after hours, while their team is on the job and the inbox sits unread.

**Solution.** A speed-to-lead system: the moment a lead arrives by web form or email, it answers in seconds, runs a context-aware qualification conversation scored against the business's own definition of a good lead, books the good ones into a calendar, and alerts a real person the instant a hot lead appears, writing every message, decision, and timestamp into a per-lead audit record.

**Outcome.** Live in production. The first real production lead got a context-aware answer in 16.98 seconds, measured server-side from logged timestamps. A full agent-run acceptance pass (real browser, real sign-ins, real leads) passes end to end, and surfaced and fixed a conversion-critical sign-up defect before any client hit it.

## Key metrics

- **16.98s** Time to a specific answer — Intake to the context-aware AI answer on the first real production lead (n=1, a single lead — stated because the sample is small). This is the product's answer time; the 0.098s receipt it replaced was a deterministic DB write, not an answer. _(verified: Computed from the production lead_events rows as min(ai_reply.at) - min(lead_received.at) (app-leadline docs/METRICS.md, 2026-07-18; FIRST_RUN_ANSWER_MS in src/lib/verified.ts).)_
- **152** Commits — Solo build, spec-driven, from empty repo to a passing end-to-end acceptance run. _(verified: git rev-list --count HEAD, 2026-07-17.)_
- **16.1k LOC** Application code — TypeScript and TSX across the app, the qualification brain, the worker, and the design system. _(verified: git ls-files '*.ts' '*.tsx' | xargs wc -l, 2026-07-17.)_
- **158** Unit tests — Offline tests over the make-or-break logic: the deterministic decision loop, field extraction, metrics derivations, anonymization. _(verified: vitest run, 158 passed, 2026-07-17.)_

## The problem

The business that answers a new lead first usually wins the job. Speed, not price or quality,
decides most of them. But a growing trades company or clinic runs inbound leads at volume while
its team is on the job, so calls and form fills sit for hours. By the time anyone follows up, the
customer has already booked whoever picked up in the first minute. The cost is real, repeated, and
worst after hours, and the generic lead tools do not bend to one business's idea of a good lead,
its calendar, or its records.

## What I built

Leadline answers every lead the instant it arrives (by web form or by email) and does four
things in plain view: it **answers**, **qualifies**, **books**, and **alerts**. It answers in
seconds, always disclosing that it is automated. It runs a short context-aware conversation
that asks only what is missing, scores the lead against the business's own rules, books qualified
leads into a real calendar, and pings a real person the moment a hot lead appears. Every message,
score, decision, and timestamp is written into a per-lead audit record: the trust story and the
source of every number shown.

## How it works

The response path is deterministic before it is smart: intake stamps the arrival time, writes the
lead and the instant receipt with no model call, and only then runs the AI. That keeps the hero
response-time number honest: it can never depend on a language model. The model work runs on an
always-on worker that polls a job queue, so the web tier stays fast and the conversation engine
(Claude Sonnet, through a single config-switchable gateway) runs off the request path. The database
is the conversation memory, which makes the worker reboot-safe with no session state to lose. An
invited business teaches the system its own material through a studio (drop documents, see the gap
map, test the answers, confirm), and nothing unconfirmed ever answers a real lead.

## Results

Leadline is live in production. The first real production lead got a context-aware answer in
16.98 seconds, measured from logged timestamps on a single lead. That number replaced an earlier
0.098-second figure, and the distinction is the honest one: 0.098s was the deterministic receipt
the system wrote on arrival, not an answer, and it was retired as the hero metric the moment the
context-aware reply became the only reply a lead sees. A full agent-run acceptance pass (a real browser driving real
sign-ins and real leads end to end, then restoring the database to its exact baseline) passes, and
did the job an acceptance test is for: it caught a conversion-critical defect (first-time invited
sign-ups never created their account or budget) that no unit test could see, which was then fixed
and re-validated on a genuine fresh sign-up. Every number on the product traces to the audit trail
or is labeled external market evidence.

## Tech

- **Languages:** TypeScript, SQL
- **Frameworks:** Next.js 16 App Router, Drizzle ORM, React
- **Infrastructure:** Vercel, Neon Postgres, always-on Windows worker, Resend, Vercel Blob, Clerk
- **AI/ML:** Claude (headless via the CLI, Sonnet for conversation), single-call-site engine gateway with config-switchable tiers
