Subsystem 02.4 · 2026 — present
Sales Autopilot
Self-hosted AI outbound engine
An engine that researches each prospect’s website, writes to them from a real mailbox, carries the reply conversation within limits you set — and hands qualified opportunities to a person.
01What it is
Operators import leads, describe the companies they sell for — voice, offerings with price floors, boundaries, knowledge — and draw a strategy as a graph of twenty-three node types. An execution engine runs every lead through that graph.
It crawls and analyses the lead’s site, qualifies them, picks a contact, drafts a message (a person approves the first touch by default), sends it over SMTP, reads replies over IMAP, classifies what each reply means, continues the conversation and escalates to a human when it should.
02The problem
Personalised outreach is manual work: research, writing, follow-ups, reply triage. Most automation just blasts templates, loses the thread, or keeps mailing people who asked to stop.
The design rule here is that the model proposes and the code disposes. Stop requests, bounces, sending caps, approvals and budgets are enforced in code — never left to a prompt.
03What I built
- The system and its contracts, split into milestones and parallel tracks that AI coding agents build under my direction — every milestone reviewed, integrated and verified.
- A crash-safe scheduler on Postgres alone, a never-send-twice outbox, and a signal system that lets a reply interrupt a multi-day wait.
- An LLM layer with seven roles, provider fallback, structured outputs and budgets; a visual strategy editor; and an MCP server that exposes the whole system to AI clients through scoped keys.
04Architecture
05Technology
- Interface
- Next.js 16React 19React FlowTanStack QueryZustand
- Services
- NestJS 11Prisma 7AI SDKMCP SDKnodemailerimapflow
- Data
- PostgreSQL 17
- AI
- AnthropicOpenAIOpenRouter · Ollamadeterministic mock provider
- Delivery
- Docker ComposeCaddy
06Engineering notes
- 01
A scheduler that survives a crash
One SQL statement claims due runs with FOR UPDATE SKIP LOCKED. Runs hold a sixty-second lease renewed every twenty seconds, and each step commits only if the worker still holds the lock token — a worker that lost its lease writes nothing.
- 02
Never send twice
The Message-ID exists before the first attempt and sending is never retried. Right before SMTP, the worker re-checks the run, the campaign, the lead, the suppression list and the caps. A send with an uncertain outcome is recorded as unknown — and left alone.
- 03
The model proposes; the code disposes
Bounces, auto-replies and stop requests are detected in code, in English, German and Albanian, before any model sees the message. “Goal reached” only counts above a confidence threshold, and pressure on a boundary hands the thread to a person.
- 04
Deliverability by design
Sending windows follow the prospect’s timezone. New mailboxes warm up from ten a day, adding five daily up to thirty, with jittered gaps. Three hard bounces in the last fifty sends pause the mailbox automatically.
- 05
AI on a budget
Every call has a timeout, jittered retries and a fallback model. Budgets are checked per batch, campaign and company before each call; oversized prompts are trimmed by priority but never lose their boundaries; scraped pages and inbound mail are fenced off as untrusted input.
- 06
Agents that can edit safely
The copilot and MCP clients change strategies only through diff proposals checked against the version they were based on. A propose-only key is always a dry run, and applying a proposal is a single undo step.
07Results
- 111k
- lines of TypeScript
- 800+
- tests
- 161
- HTTP routes
- 54
- MCP tools
- 23
- strategy node types
- 7
- AI roles with fallbacks
- Runs the whole loop end to end — research, outreach, reply handling and hand-off to a person.
- Every rule that matters — stop requests, caps, approvals, budgets — enforced in code and covered by tests.
- In active development, with more of the system growing around it.