How we route inbound leads to the right rep
The lead-routing agent we run on Kortix — every 15 minutes it scores each new HubSpot lead, assigns it to the right rep by territory, segment, or round-robin, and notifies the rep in Slack, flagging anything ambiguous for a human instead of guessing.
- Written by
- The Kortix Team
- Published
- Reading time
- 8 min read
- Topics
- Sales, Case Study, Enterprise
A new inbound lead is worth the most in the first few minutes after it lands. Every minute it sits unassigned is a minute a rep isn't calling it, and the minute it does get routed still depends on someone checking the queue, knowing which territory owns which region, and remembering whose turn it is in the rotation. That's a lot to ask of a manual process running every fifteen minutes, all day.
We run a lead-routing agent on Kortix that does exactly that check, every 15 minutes: read HubSpot for new leads, assign each one to the right rep, notify them in Slack, and flag anything it can't confidently route for a human. It never deletes or merges a lead — assignment and notification are the only actions it takes.
- Team
- Kortix
- Runs on
- Cron, every 15 minutes
- Connected systems
- HubSpot · Slack
- Mode
- Fresh session · assigns + notifies, never deletes or merges
The problem
Routing rules live in more than one place: territory boundaries by region, segment specialists by company size or industry, and a round-robin pool for whatever's left over. A rep checking the lead queue has to hold all of that in their head, get it right every time, and still do it fast enough that the lead is still warm when the notification lands.
The common fallback is a static routing workflow inside the CRM — a fixed if/then chain that breaks the moment a territory is split, a rep goes on leave, or a lead doesn't cleanly fit one bucket. Those leads get stuck in a queue, silently misrouted to whoever built the workflow's default, or followed up on days later once someone notices. None of that is fast, and none of it flags the leads that most need a human's judgment.
What we built
On Kortix, a cron fires an agent every 15 minutes. It spawns a fresh session with scoped access to HubSpot, reads every new inbound lead that hasn't been routed yet, scores it for intent, matches it against the territory and segment rules, and falls back to whichever rep in the round-robin pool has taken the fewest leads so far this week. It assigns the HubSpot owner, posts a notification to the rep's Slack channel, and calls out anything high-intent so it gets worked first. A lead it can't confidently route — missing territory data, no segment match, a genuine tie — goes to a separate Slack channel for a human to assign by hand. It never deletes or merges a lead.
How it works
Copy the setup prompt into a new session
Open your Kortix project, start a new session, paste this prompt and send it. The agent writes the agent file, the routing rules skill and the 15-minute trigger, and opens a change request for you to review. Prefer clicks? Choose Use this template instead.
Set up a lead routing agent in this project.
-
Create the agent agents/lead-routing.md. Its job is to assign each new HubSpot lead to the right rep and notify the rep in Slack. It may use the HubSpot connector and post to Slack.
-
Create the skill skills/lead-routing-rules/SKILL.md with these rules:
- A new lead is a contact on lifecycle stage lead without the kortix_routing_status property. Skip every contact that has it.
- A lead is high-intent when it meets two or more of these: a VP-level title or above, company size at or above our enterprise threshold, a timeline or budget inside this quarter, a demo request or repeat pricing-page visits.
- Route in this order: the territory owner for the region, then the segment specialist for company size and industry, then the round-robin rep with the fewest leads this week. Break ties alphabetically.
- When no rule resolves a lead, never guess an owner. Post it to #sales-ops with what you checked.
- Write only the HubSpot owner and kortix_routing_status, set to routed or flagged. Never delete or merge a lead.
-
Add a cron trigger lead-routing-sweep to kortix.yaml. It runs the lead-routing agent every 15 minutes with the prompt "Load the lead-routing-rules skill and run one complete lead-routing sweep."
-
Tell me which of these connectors are not connected yet.
-
Open a change request with all of it. Do not merge it.
Connect your tools
Open Connectors in your project and connect your CRM and Slack. Credentials are brokered server-side and never enter the agent's machine.
Scores each new lead and writes the assigned owner.
Notifies the assigned rep and escalates ambiguous leads.
Run it once with this prompt
Merge the change request, then start a session with the lead-routing agent and send this prompt. Check each owner and routing reason before you let the schedule take over.
Run one lead-routing sweep on HubSpot.
- Find contacts on lifecycle stage lead that do not have the kortix_routing_status property.
- Score each lead for intent with the rules in the lead-routing-rules skill.
- Route each lead by territory, then segment, then the round-robin rep with the fewest leads this week, and set the HubSpot owner.
- Post each assignment to #sales-routing with the reason, and mark high-intent leads clearly.
- Post any lead that no rule resolves to #sales-ops instead of guessing. Set kortix_routing_status to routed or flagged on every lead.
Let the 15-minute schedule take over
The change request added this trigger to kortix.yaml. From now on the agent
runs every 15 minutes, each run in a new session on its own cloud computer.
To change the time, edit the cron line, or open Triggers in the project.
triggers:- slug: lead-routing-sweep name: Lead routing sweep on: cron: "0 */15 * * * *" run: agent: lead-routing prompt: Load the lead-routing-rules skill and run one complete lead-routing sweep.Send unroutable leads to a person
The agent assigns a lead only when a rule resolves it. A lead with missing data, a gap in the territory map or an empty round-robin pool goes to #sales-ops with what the agent checked, and a person assigns it in HubSpot. The agent writes only the owner and the routing status. It never deletes or merges a record.
Read the assignments
Each sweep ends with one post per lead in Slack. This is what a run looks like in the session:
Routed 5 new leads: 2 by territory, 2 by segment and 1 by round-robin. 2 of them are flagged high-intent. 1 lead had no region, size or industry, so it is waiting in #sales-ops for a person to assign.
Make it do more
Once it works, paste any of these into the same session.
When a rep asks in #sales-routing why a lead came to them, reply in the thread with the rule that matched and the fields it used.
Every Friday at 16:00, post each rep's count of routed leads this week and the number of flagged leads to #sales-ops.
Before you assign a round-robin lead, skip any rep marked out of office in memory, and say so in the routing reason.
Guardrails
The agent writes to the lead record, so its write access is narrow and its escalation path is explicit:
- Never delete or merge. The agent can set a lead's owner and a routing-status marker. It cannot delete a lead, merge two records, or touch any other field, no matter how confident the routing rules are.
- Ambiguous means human, not a guess. A lead with no territory match, no segment match, and no clean tiebreak in the round-robin pool is flagged in a dedicated Slack channel for a person to assign. The agent never invents a fallback owner.
- Scoped secrets. The HubSpot credential is encrypted in the Secrets Manager and injected into the sandbox at runtime, scoped to the agents you grant them to.
- Everything is code. The territory map, segment rules, round-robin pool, and intent-scoring criteria are files in the repo, versioned and changed through a reviewed change request rather than a CRM workflow builder.
The outcome
- Sweep of the new-lead queue, all day
- Every 15 min
- Leads deleted or merged by the agent — ever
- 0
- Territory, segment, and round-robin in one pass
- 3-way routing
Leads that used to sit in a queue waiting for someone to notice now land on the right rep's desk within 15 minutes, tagged with why they were routed there and whether they need to be worked first. The agent assigns and notifies; a human still owns every lead it can't confidently place.
