A lead comes in through a webhook. Six steps later it is scored, in the CRM, in the sheet, emailed and announced to the team. When a provider goes down, nothing is lost.
Every small business that sells online has the same plumbing problem. A form fires, someone copies the lead into the CRM, someone else pastes it into a spreadsheet, the welcome email goes out a day late, and when the mail provider has a bad hour nobody notices which leads fell through.
RelayDesk is the control room for that plumbing. One FastAPI service takes the lead, runs it down a line of connectors and shows you exactly where every lead is: which step passed, which one retried, which one is waiting for you in the dead-letter queue.
POST /webhooks/lead
→ Normalize clean email, name, company
→ AI qualify score 0-100, priority, matched signals
→ CRM upsert create or update the contact
→ Sheets log append a row
→ Welcome email send to the lead
→ Team alert post to the sales chat
The dashboard draws this as a rack of units. Each unit shows how the last 50 leads went through it: passed, failed, retried, average time. Every run in the table gets a strip of six squares, so a broken step is visible from across the room.
Each provider unit has a switch that takes the provider down. Flip the email one, send a test lead, and you watch three attempts fail, the run stop at step five and the lead land in the dead-letter queue. Bring the provider back, press Replay, and the run continues from the welcome email. The CRM and the sheet are not touched twice.
Version 1 proved the idea: a lead goes in, six systems get updated. Version 2 is about the day things go wrong, because that is the day a client judges an automation.
- Smart retries. Each connector now tells the engine whether a failure is worth retrying. A provider timeout gets two more tries with a 0.2 s and 0.6 s backoff; a lead with no email fails at once and goes straight to the queue instead of wasting time.
- Replay picks up where the lead stopped. A dead letter keeps the payload and the position of the step that failed, so a replay continues from that step. The CRM and the sheet are written once, and the new run links back to the original.
- Every step is isolated. An exception inside any connector is caught, recorded with its message and duration, and the lead is parked in the queue. One bad provider never takes the service down.
- Safe to deliver twice. Form tools resend webhooks. An
Idempotency-Keyheader, backed by a unique index, returns the first run instead of sending a second welcome email. - Optional webhook secret. Set
RELAYDESK_WEBHOOK_SECRETand the endpoint requires the same value inX-RelayDesk-Secret, compared in constant time. - Stable CRM IDs. Record IDs come from SHA-256 of the email, so they survive restarts and match across machines.
- Sharper scoring. Keywords match whole words, and any budget the form sends, text, empty or negative, is handled without fuss.
- Contacts only get richer. A repeat submission with blank fields keeps what the CRM already knows.
- Pause means pause. A paused line answers 409 to webhooks and manual runs.
- Per-step numbers. Passed, failed, retried and average time for every unit, counted in SQL.
27 tests cover these cases: outages, flaky providers, replays, idempotency, the secret, HTML and JSON 404s. They run on an in-memory database and never touch data/.
The interface is new too. The line is the product, so the line is the screen: graphite surfaces, green, amber and red only where they mean passed, retried and failed, and the trace strip as the one detail that repeats everywhere. Light, dark and phone.
python -m venv .venv .venv\Scripts\activate # macOS / Linux: source .venv/bin/activate pip install -r requirements.txt python seed_demo.py # 11 runs, two outages, one replay uvicorn app.main:app --reload
Open http://127.0.0.1:8000. Swagger lives at /docs. Docker: docker compose up --build.
Send a lead:
curl -X POST http://127.0.0.1:8000/webhooks/lead \ -H "Content-Type: application/json" \ -H "Idempotency-Key: evt_001" \ -d @examples/lead-webhook.json
Tests: pytest -q
| Method | Path | What it does |
|---|---|---|
| POST | /webhooks/lead |
Run a lead down the line (secret and idempotency key optional) |
| POST | /workflows/{id}/run |
Manual run with any payload |
| POST | /api/dead-letters/{id}/replay |
Continue a failed run from the step that failed |
| GET | /api/runs, /api/runs/{id} |
Run history and per-step detail |
| GET | /api/dead-letters |
What is waiting and what was replayed |
| GET | /api/contacts, /api/workflows |
CRM contacts and the line definition |
| GET | /health |
Database check and which providers are down |
The connectors here are local stand-ins and never call a real provider. Each one is a class with execute(action, payload) returning a ConnectorResult. Write that class for HubSpot, SendGrid, Google Sheets or Slack, register it, and the engine, the retries, the replay and the dashboard work unchanged. More in docs/architecture.md.
This is a portfolio project, not client work.
Koncha Artyom · MIT License


