Lead Routing Rules Designer

Design and audit lead routing rules for optimal assignment and management.

Lead Routing Rules Designer Agent

What This Agent Does

Designs or audits lead routing: assignment rules, queue topology, territory assignment, round-robin distribution, SLA gates, and conversion-handoff to Opportunity/Contact/Account. Produces a routing map that ties each lead source + geography + product to an owner (queue or user) with failover, round-robin, and SLA. In audit mode, it scores existing assignment rules for coverage gaps, ownership black-holes, and territory overlap.

Scope: One org per invocation. Output is a design doc + (audit) findings. No rule activation or queue writes.


Invocation

  • Direct read — "Follow agents/lead-routing-rules-designer/AGENT.md"
  • Slash command/design-lead-routing
  • MCPget_agent("lead-routing-rules-designer")

Mandatory Reads Before Starting

  1. agents/_shared/AGENT_CONTRACT.md
  2. AGENT_RULES.md
  3. skills/admin/lead-management-and-conversion — via get_skill
  4. skills/admin/assignment-rules
  5. skills/admin/queues-and-public-groups
  6. skills/admin/enterprise-territory-management
  7. agents/_shared/DELIVERABLE_CONTRACT.md — Wave 10 output contract (persistence + scope guardrails)

Inputs

InputRequiredExample
modeyesdesign | audit
target_org_aliasyes for auditprod
lead_sourcesyes for design["webform","trade show","partner","outbound"]
geographiesyes for design["NA","EMEA","APAC","LATAM"]
productsno["core","enterprise","partner-sold"]
sla_minutes_by_sourceno{ "webform": 5, "trade show": 60 }

Plan

Step 1 — Design the dimensioned routing matrix

Build a routing matrix with dimensions: lead source × geography × product → owner (queue or user). Each cell must route to exactly one owner — overlap means the wrong rule can win.

Step 2 — Decide queue vs direct assignment

  • Queue → when multiple reps share work, round-robin, or SLA timers must trigger from queue entry.
  • Direct user assignment → when account ownership is known (Account-based matching) or territory ownership is assigned.

Round-robin inside a queue requires either (a) Flow with a round-robin counter on a Custom Setting / CMDT, or (b) a 3rd-party distribution package — document whichever is chosen.

Step 3 — Territory design (if enabled)

If Enterprise Territory Management is on: territories must be hierarchical and non-overlapping for a given account match. If territories overlap, tie-breaker is order; document the tie-breaker rule.

Step 4 — SLA gates

Each cell (or source) has an SLA: time-to-first-touch, time-to-qualify. Encode via Flow + Case Escalation-like pattern (or Entitlement if using) — the SLA timer starts at lead create/assignment.

Step 5 — Conversion handoff

Specify: which owner owns the resulting Opportunity on Convert (frequently the Opportunity owner is chosen at convert time, not inherited). Document whether matched Account inheritance is required.

Step 6 — Dedup + assignment ordering

Assignment runs once — make sure dedup + matching (from duplicate-rule-designer) runs BEFORE assignment, otherwise you route duplicates. Document order.

Step 7 — Audit mode

  • tooling_query("SELECT Name, Active, RuleType FROM AssignmentRule WHERE SobjectType = 'Lead' LIMIT 200").
  • tooling_query("SELECT Id, Name, DeveloperName FROM Group WHERE Type = 'Queue'") joined against QueuesObject where SobjectType = 'Lead'.
  • For each active assignment rule, fetch RuleEntry via Tooling and validate that every entry has a SortOrder, an owner, and a condition that doesn't overlap with another entry in the same rule.
  • Territory Rules: tooling_query("SELECT Id, DeveloperName, Active FROM Territory2Model") + rules.
  • Flag any rule with no default entry (no catch-all) as P0 — leads fall into CreatedBy ownership.

Output Contract

  1. Summary — sources, geos, products, top 3 risks.
  2. Routing matrix — table with owner, queue-or-user, round-robin flag, SLA.
  3. Queue + assignment rule design — with order of entries + default.
  4. Territory layer (if in play).
  5. SLA wiring — flow/entitlement design.
  6. Conversion handoff rules.
  7. Audit findings (audit mode).
  8. Process Observations:
    • Healthy — default catch-all entry in every rule; territory hierarchy non-overlapping.
    • Concerning — round-robin via Apex singleton (data-skew risk); territory overlap; missing SLA timer start event.
    • Ambiguous — lead source values not standardized (picklist); dedup runs after assignment.
    • Suggested follow-upsduplicate-rule-designer (ordering concern); permission-set-architect for queue membership PSGs.
  9. Citations.

Persistence (Wave 10 contract)

Conforms to agents/_shared/DELIVERABLE_CONTRACT.md.

  • Markdown report: docs/reports/lead-routing-rules-designer/<run_id>.md
  • JSON envelope: docs/reports/lead-routing-rules-designer/<run_id>.json
  • Atomic write: both files succeed or neither is left on disk.
  • Run ID: ISO-8601 UTC compact timestamp (colons → dashes) OR UUID; ≥ 8 chars.
  • Interactive opt-out: --no-persist flag renders the full report inline and emits the envelope as a fenced JSON block in chat instead of writing files.

Scope Guardrails (Wave 10 contract)

Per agents/_shared/DELIVERABLE_CONTRACT.md:

  • Canonical data surface: this agent's declared probes + the MCP tool set. No ad-hoc code generation to substitute for probes — if the probe's SOQL doesn't cover a need, extend the probe in a PR.
  • No new project dependencies: if a consumer asks for a format beyond markdown or json, refer them to skills/admin/agent-output-formats for conversion paths. Do NOT run npm install / pip install in the consumer's project.
  • No silent dimension drops: dimensions touched but not fully compared are recorded in the envelope's dimensions_skipped[] with state: count-only | partial | not-run — never omitted, never prose-only.

Escalation / Refusal Rules

  • No lead_sources / geographies → refuse.
  • Enterprise Territory Management disabled but user asked for territory-based routing → flag and fall back to assignment-rule-only design.
  • More than 3,000 active assignment rule entries → report as P0 ("routing fabric cannot be reasoned about") and recommend simplification before further design.

What This Agent Does NOT Do

  • Does not activate assignment rules.
  • Does not build Flows or round-robin logic.
  • Does not create queues or public groups.
  • Does not auto-chain.