Get started

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 OpenChatly Team
Published
April 18, 2026
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

1

Copy the setup prompt into a new session

Open your Kortix workspace, 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.

Setup prompt

Set up a lead routing agent in this workspace.

  1. 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.

  2. 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.
  3. 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."

  4. Tell me which of these connectors are not connected yet.

  5. Open a change request with all of it. Do not merge it.

2

Connect your tools

Open Connectors in your workspace and connect your CRM and Slack. Credentials are brokered server-side and never enter the agent's machine.

HubSpot

Scores each new lead and writes the assigned owner.

Or useSalesforcePipedrive
Required
Slack

Notifies the assigned rep and escalates ambiguous leads.

Or useMicrosoft Teams
Required
3

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.

Prompt

Run one lead-routing sweep on HubSpot.

  1. Find contacts on lifecycle stage lead that do not have the kortix_routing_status property.
  2. Score each lead for intent with the rules in the lead-routing-rules skill.
  3. Route each lead by territory, then segment, then the round-robin rep with the fewest leads this week, and set the HubSpot owner.
  4. Post each assignment to #sales-routing with the reason, and mark high-intent leads clearly.
  5. Post any lead that no rule resolves to #sales-ops instead of guessing. Set kortix_routing_status to routed or flagged on every lead.
4

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 workspace.

kortix.yaml
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.
5

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.

6

Read the assignments

Each sweep ends with one post per lead in Slack. This is what a run looks like in the session:

Lead routing sweep · 14:30
Load the lead-routing-rules skill and run one complete lead-routing sweep.
Worked for 1m 08s
hubspot · search contactshubspot · list ownershubspot · update contact × 6slack · post message → #sales-routing × 5slack · post message → #sales-ops

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.

Illustrative example. Your counts depend on your inbound volume and routing rules.

The pattern

A 15-minute cron spawns a fresh session with scoped connector access to HubSpot and a channel into Slack. The territory, segment, and round-robin rules live as skills and memory. The agent assigns and notifies exactly per those rules, and hands anything it can't confidently route to a human.

Make it do more

Once it works, paste any of these into the same session.

Explain a routing decision

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.

Weekly load report

Every Friday at 16:00, post each rep's count of routed leads this week and the number of flagged leads to #sales-ops.

Skip reps who are out

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.

On this page

  • The problem
  • What we built
  • How it works
  • Make it do more
  • Guardrails
  • The outcome

Run this yourself

Install this exact setup — agent, connectors, schedule, and guardrails — in a guided flow.

More use cases.

  • How we handle GDPR data-subject requests on a deadline

    Legal·July 11, 2026

  • OpenChatly

    How we keep our docs in sync with the code

    Documentation·July 5, 2026

  • OpenChatly

    How we QA every pull request automatically

    QA·July 5, 2026

Own your AI.Start today, in our cloud.

Start for free

OpenChatly is the AI workspace for everything. One person directing, agents executing, from goal to finished work.

©2026 OpenChatly AI.沪ICP备2025124785号-5

Resource guide

  • Product overview
  • Skills marketplace

Terms of service

  • User agreement
  • Privacy policy

Contact us