Sub topic 7
Routing Messages to Queues and Agents
Prerequisites and scope
This chapter assumes you have read the chapters on triage and priority levels. You should know that each incoming message already carries a priority (P1, P2 or P3) and a category. Routing is the next step. It decides which queue holds the message and which agent works on it.
Triage answers "how urgent is this?" Routing answers "who should handle it, and where does it wait until then?"
The working model
A queue is an ordered list of cases waiting for an agent. An agent is a person (or a bot) who takes cases from a queue. A routing rule is a condition that places a message in a queue. A assignment method decides which agent in a queue gets the next case.
Routing therefore has two stages:
- Queue selection. Rules put each message in one queue based on its attributes.
- Agent assignment. The queue's assignment method picks an agent, or agents pull cases themselves.
Attributes you can route on
Rules need data to work with. Common attributes fall into four groups.
| Attribute group | Examples | Typical use |
|---|---|---|
| Priority | P1, P2, P3 | Urgent queue, shorter response targets |
| Topic | Billing, delivery, technical, account access | Skill-based queues |
| Customer | Verified account, existing customer, high-value customer | Priority account queue |
| Channel and language | X public reply, Instagram DM, TikTok comment, Spanish | Channel specialists, language queues |
Keep the attribute list short. Every attribute you add needs someone to keep it accurate. A rule based on "customer lifetime value" is useless if that field is empty for half of your customers.
Designing queues
Start with few queues. Each extra queue splits your agents into smaller pools, and small pools handle bursts badly. If the billing queue has two agents and both are on a break, billing messages wait even if the general queue is empty.
Queues are usually split along one of these lines:
- By priority. An urgent queue that is always worked first.
- By skill. Billing, technical support, account security.
- By channel. Useful when channels need different tools or tone, for example public replies versus direct messages.
- By language or region. Needed when agents cannot cover all languages.
A sound starting design for a small team is one urgent queue plus two or three skill queues. Add more only when data shows a real need, such as a topic that repeatedly waits too long because generalists cannot resolve it.
Queue order inside a queue
Within a queue, order matters too. A first-in, first-out order is fair, but it can leave a P2 waiting behind many P3 messages. Most teams sort by priority first, then by time waiting. Some also raise a message's rank as it approaches its response target, so that no case silently breaches the target.
Agent assignment methods
| Method | How it works | Strength | Weakness |
|---|---|---|---|
| Pull (claim) | Agents pick the next case from the queue | Simple, agents choose by skill | Agents may skip hard cases |
| Round robin | Cases are given to agents in turn | Even distribution | Ignores agent load and skill |
| Least busy | Case goes to the agent with the fewest open cases | Balances workload | Needs live tracking |
| Skill-based | Case goes to an agent with the matching skill tag | Better first-contact resolution | Fails when no skilled agent is online |
| Sticky (owner) | Case returns to the agent who handled it before | Customer continuity | Delays if that agent is away |
Most teams combine methods. A common setup is skill-based assignment with a least-busy tiebreak, and sticky assignment for ongoing cases with a fallback to the queue when the owner is offline for longer than a set time.
Writing routing rules as code
Routing rules are easier to review and test when they are written down explicitly. The Python function below builds on the triage rules from earlier chapters. It checks rules in order and returns the first match.
URGENT_WORDS = {"fraud", "hacked", "unsafe", "lawsuit", "refund"}
BILLING_WORDS = {"invoice", "charge", "charged", "billing", "payment"}
TECH_WORDS = {"error", "crash", "bug", "login", "broken"}
def route(text, priority, is_verified, language="en"):
words = set(text.lower().split())
if priority == "P1":
return "urgent"
if language != "en":
return f"language_{language}"
if is_verified:
return "priority_accounts"
if words & BILLING_WORDS:
return "billing"
if words & TECH_WORDS:
return "technical"
return "general"
tests = [
(("My account was hacked", "P1", False), "urgent"),
(("Why was I charged twice", "P3", False), "billing"),
(("App keeps showing an error", "P3", False), "technical"),
(("Hello, any news on my order?", "P2", True), "priority_accounts"),
(("Hola, necesito ayuda", "P3", False, "es"), "language_es"),
(("What are your opening hours", "P3", False), "general"),
]
for args, expected in tests:
result = route(*args)
assert result == expected, (args, result, expected)
print(args[0], "->", result)Three points in this code carry over to real tools:
- Order is part of the rule. A verified customer reporting fraud goes to
urgentbecause the priority check comes first. If you moved the verified check to the top, that customer would wait in a slower queue. - There is always a default. The last line returns
general, so no message is left unrouted. - Rules are tested. Each case in
testsdocuments an intended behavior, and theassertfails if a later edit changes it.
Keyword matching is crude. "I am not hacked, just curious how security works" matches hacked. Treat keyword rules as a first pass and let agents re-route a case with one action.
Where routing goes wrong
Misrouting and ping-pong
A message sent to the wrong queue gets passed between teams, and each pass adds waiting time. The customer sees a long delay with no progress. Track the re-route rate, the share of cases moved to a different queue after first assignment. A high rate for one rule points to a rule that needs fixing. Also let any agent re-route with a reason code, so you can see why cases move.
The clock keeps running
Response-time targets usually count from the moment the message arrives, not from the moment it reaches the right agent. Time spent in the wrong queue counts against you. Design your measurements so they use the original received timestamp, and do not reset it on transfer.
Orphaned messages
A queue with no online agent holds its messages indefinitely. Prevent this with an overflow rule: if a case waits longer than a set time, or the queue has no agents available, move it to a backup queue such as general or a team lead's queue. Use alerts when any queue's oldest message approaches its target.
Starvation of low priority
If the queue always serves P1 and P2 first, P3 messages can wait forever during busy periods. Age-based boosting solves this. A P3 case waiting past its response target moves up in the order.
Public and private messages
Public comments and direct messages often need different handling. A public complaint may go to a queue that can reply visibly and decide whether to move to a private channel. A DM asking for account details may need a queue with access to customer records. Tag the message type at routing time, so the agent does not need to work it out.
Routing and escalation
Routing places a case with the first handler. Escalation moves it to someone with more authority or expertise when a trigger fires. Keep these separate in your design. A routing rule decides the first queue. An escalation policy decides later moves. If you encode both in one set of rules, changes to one often break the other.
For example, the escalation policy in this tutorial sends P1 cases to a tier 2 specialist after 30 minutes without resolution. The routing rule only needs to say that P1 cases start in the urgent queue.
Checklist for a routing design
- List the attributes you can capture reliably at the moment a message arrives.
- Create the smallest set of queues that matches how work is actually divided.
- Write rules in priority order and end with a default queue.
- Choose an assignment method for each queue and a fallback when nobody is available.
- Add overflow and age-based boosting to prevent stuck or starved cases.
- Keep the original received timestamp through every transfer.
- Test the rules with sample messages, and review the re-route rate monthly.
Exercises
Exercise
Your billing queue has two agents, and during lunch both are away. Messages in that queue wait 90 minutes while the general queue is empty. Name two changes to the routing design that would prevent this.
Show answer
First, add an overflow rule that moves billing cases to the general queue (or a team lead's queue) when no billing agent is available or when a case has waited longer than a set time, for example 15 minutes. Second, stagger breaks so the billing queue always has someone online, or train general agents on common billing questions so they can handle simple cases. Merging billing into a broader queue is also valid if volume is low.
Exercise
A verified customer posts "I think my card was used for fraud on your site." Using the route function from this chapter, which queue receives it when triage assigns P1? What would happen if the is_verified check were placed before the priority check?
Show answer
With P1 it goes to urgent, because the priority check runs first and returns immediately. If the verified check came first, the message would go to priority_accounts, which may be worked more slowly than the urgent queue, so a fraud report could be delayed. Rule order changes the outcome.
Exercise
A case is received at 09:00, sits in the wrong queue until 09:40, and is then re-routed to the right agent, who replies at 09:50. The P2 first-response target is 60 minutes. What first response time do you record, and did the team meet the target?
Show answer
Record 50 minutes, measured from the original received time (09:00) to the first reply (09:50). The target of 60 minutes was met, but the 40 minutes in the wrong queue consumed most of it. The re-route should also be counted in the re-route rate for the rule that sent the case to the wrong queue.