---
name: "inbound-lead-router"
description: "Build an inbound lead router: define ordered territory rules and owner pools, assign named accounts and existing owners first, rotate leads round-robin with capacity and out-of-office rules, start an SLA timer that counts business hours by lead tier, warn and escalate before and at breach, and report speed-to-lead weekly. Use when inbound leads wait in a queue or assignment is manual."
---

# Inbound lead router

## Goal
Every inbound lead gets an owner within a minute, a clear reason for that choice and a response clock that cannot be forgotten. Part of GTM engineering. Fed by: icp-scoring-model (tier), crm-hygiene-pipeline (account match), website-visitor-deanonymizer. Feeds: attribution-ledger, multi-channel-orchestrator.

## When to use
- Leads wait in a shared inbox or a queue.
- Territories change and routing is manual.
- You have no data on speed-to-lead.

## Inputs
- Lead sources and their fields.
- Owners, regions, segments, capacity, absence dates.
- Territory definitions and named account lists.
- SLA targets by tier and business hours with timezone.

## Data model
`leads`: `lead_id, created_at, email, country, state, employees, icp_tier, account_id, source`
`rules.json`: `business_hours, sla_minutes, pools, territories, default_pool, away, max_open`
`routed`: `lead_id, owner, territory, reason, sla_minutes, sla_due, routed_at`
`responses`: `lead_id, first_response_at`

## Step 1. Define the order of rules
First match wins. A typical order:
1. Existing open opportunity or customer: route to that account's owner.
2. Named account lists: route to the named owner.
3. Territory rules by country, state or segment.
4. Default pool.
Write every rule with a plain-language name. The name is the reason shown to the rep.

## Step 2. Define pools and capacity
Each pool lists owners. Add `max_open` per owner and away dates. A skipped owner is never assigned until back.

## Step 3. Round-robin
Within the pool, rotate. Skip owners who are away or at capacity. Store the position so the rotation continues after a restart. If nobody in the pool is available, fall back to the default pool and flag it.
Run `scripts/route_leads.py route leads.csv rules.json` on past leads to check fairness before going live.

## Step 4. Start the SLA clock
SLA minutes depend on the tier (for example A 15, B 60, C 240). The due time counts only business minutes. A lead arriving after hours is due early the next working day by the same count. The script does this arithmetic.

## Step 5. Alert and escalate
- Notify the owner at assignment, with the lead, the reason and the due time.
- Warn at 75 percent of the SLA.
- At breach, notify the owner's manager, and reassign only if the manager says so.

## Step 6. Report
Weekly: median and 90th percentile minutes to first response by tier and owner, share met, breaches with reasons, and meeting rate by response-time bucket. Run `scripts/route_leads.py sla-check`.

## Tool options
Form tools and CRM workflows for capture and assignment. A scheduling tool for instant meeting booking. A dedicated routing product if you have many rules. A small webhook function with this logic if the CRM cannot express it. Whatever you use, log each decision with the rule name.

## Output
`routed.csv` and `sla_report.csv`.

## Success metrics
- Share of leads assigned within one minute.
- Median and 90th percentile time to first response, in business time.
- Share of SLA met by tier.
- Meeting rate by response-time bucket.
- Reassignments per week and why.

## Guardrails
- Route on business criteria, not on personal attributes of the lead.
- Keep the lead's personal data inside the CRM and the team that needs it.
- Spam and competitor leads go to a review queue, not to a rep.
- A human reads the lead before a reply goes out. Do not auto-reply with claims.
- Honour opt-outs and do not route people who asked not to be contacted.
