Lead routing rules
@revopslab/lead-routing-rules
Design, test, and apply lead routing rules outside your CRM. Write ordered rules in a JSON file (existing-account match, partner, segment, region, junk filters), prove them with rule tests, then route a leads CSV with weighted round robin, out-of-office skips, and a fallback queue. Works with HubSpot, Salesforce, or any CSV.
- Activity
- New: be the first to try it
- Installs
- 0 installs
- Likes
- 0 likes
- Clones
- 0 clones
- 1{
- 2 "pools": {
- 3 "enterprise": { "members": ["Rep A", "Rep B"] },
- 4 "mid-market": { "members": ["Rep C", "Rep D"], "weights": { "Rep C": 2 } },
- 5 "smb": { "members": ["Rep E", "Rep F", "Rep G"] }
- 6 },
- 7 "out_of_office": ["Rep G"],
- 8 "account_match": { "rule_id": "existing-account" },
- 9 "rules": [
- 10 { "id": "spam-or-test", "when_any": [{ "field": "email", "op": "contains", "value": ["test@", "example.com"] }, { "field": "company", "op": "in", "value": ["test", "asdf", "n/a"] }], "assign": { "queue": "discard-review" }, "reason": "Looks like a test or junk submission" },
- 11 { "id": "free-email-students", "when": [{ "field": "is_free_email", "op": "exists" }, { "field": "employees", "op": "missing" }], "assign": { "queue": "nurture" }, "reason": "Personal email and no company size" },
- 12 { "id": "partner-referral", "when": [{ "field": "lead_source", "op": "==", "value": "Partner referral" }], "assign": { "owner": "Partner Manager" }, "reason": "Partner-sourced leads go to the partner manager" },
- 13 { "id": "enterprise", "when": [{ "field": "employees", "op": ">=", "value": 1000 }], "assign": { "pool": "enterprise" }, "reason": "1,000+ employees" },
- 14 { "id": "mid-market", "when": [{ "field": "employees", "op": ">=", "value": 200 }], "assign": { "pool": "mid-market" }, "reason": "200 to 999 employees" },
- 15 { "id": "smb", "when": [{ "field": "employees", "op": ">=", "value": 1 }], "assign": { "pool": "smb" }, "reason": "Under 200 employees" }
- 16 ],
- 17 "fallback": { "queue": "routing-review" },
- 18 "tests": [
- 19 { "name": "big company goes to enterprise", "lead": { "email": "ops@bigco.test.org", "company": "BigCo", "employees": "5,000" }, "expect_rule": "enterprise", "expect_to": "enterprise" },
- 20 { "name": "employee range uses the low end", "lead": { "email": "a@mid.io", "company": "Mid", "employees": "201-500" }, "expect_rule": "mid-market" },
- 21 { "name": "gmail with no size is nurture", "lead": { "email": "someone@gmail.com", "company": "Self" }, "expect_rule": "free-email-students", "expect_to": "nurture" },
- 22 { "name": "partner beats size", "lead": { "email": "x@huge.io", "employees": "20000", "lead_source": "Partner referral" }, "expect_rule": "partner-referral" },
- 23 { "name": "no size and work email falls back", "lead": { "email": "x@unknown.io", "company": "Unknown" }, "expect_rule": "fallback", "expect_to": "routing-review" }
- 24 ]
- 25}
