Territory & Round-Robin Assignment Engine
Assign every lead to the right rep automatically using territory rules and fair round-robin balancing - with caps, out-of-office handling, named-account protection, and a clear reason for every decision.
An internal web tool that imports a lead batch, applies your territory rules and round-robin balancing, respects caps + PTO + named-account ownership, shows the reason each lead was assigned, lets sales ops approve the batch, notifies owners, and exports a clean CSV.
Before you start
- A free Vercel account
- A free Supabase account
- A free Resend account (for owner notifications)
- Your territory/rules sheet, rep roster, and a sample lead batch (CSV or Google Sheet is fine)
The problem this kills
You assign leads by hand, or with a brittle rule buried in your CRM that nobody fully understands. New leads pile up while a rep is on vacation. The same eager rep grabs the easy ones. Someone owns an account already, but the lead still gets handed to a stranger - and now two reps are calling the same company. And every Monday you field the same complaint: "Why didn't I get that one?"
The honest answer is usually "I'm not sure." That's the real problem. Assignment is invisible, inconsistent, and impossible to defend.
What you'll build
A small internal web app - just for your team - that takes a batch of new leads and routes each one to the right rep, then proves why. It applies your territory rules first (region or zip, industry, company size, named accounts), then balances the leftovers with fair round-robin so the load is even. It honors daily caps, skips reps who are out of office, and never silently steals a lead that belongs to an existing account owner.
Before anything is final, sales ops sees the whole proposed batch - every assignment, every reason, and every "no rule matched" exception - and approves it. Only then are owners written and notified. Then you get a clean CSV with owner and reason for each lead, ready to drop into your CRM.
What's inside the Implementation Plan
The plan is a complete, paste-and-go runbook for an AI coding agent. Crucially, it opens by interviewing you about your business - your current routing process, the systems and sheets you use, the exact field names and code conventions in your data, your typical and peak lead volumes, your real approval and tie-break rules, and your messy edge cases. It reads back a short tailored spec, gets your thumbs-up, and only then builds. So you get a tool shaped around how your team actually works - not a generic template you have to bend to fit.
From there it walks you, step by step, through importing leads, rules, and roster; building the matching and round-robin logic; detecting rule gaps and conflicts; the human approval gate; owner notifications; and the CSV export. Every build step ends with a ready-to-copy prompt.
The governance it includes (this is the point)
- Login so only your team can open the tool.
- Row-level security so each organization only ever sees its own leads, rules, and roster.
- A complete audit trail - every assignment run gets a run ID, and you can see who approved what and when.
- A hard human-in-the-loop gate - the engine drafts assignments, sales ops reviews and approves, and only then are owners committed and emailed.
- Duplicate guards - a lead can't be assigned twice in one run, and existing account ownership is never overridden silently.
- A fair round-robin counter that survives reruns, so rebalancing a batch doesn't reset everyone to zero.
Who it's for
Sales ops, RevOps, and sales managers who hand-assign leads today and are tired of defending each decision. If you can write down your routing rules on a whiteboard, you can build the tool that enforces them - and finally answer "why didn't I get that one?" with a screenshot instead of a shrug.
You've got this - paste the first prompt and let the interview tailor the rest.