Automated Ticket Routing for Multi-Team Engineering Organizations
Machine LearningModel answerLast updated
Build an ML system that assigns incoming support tickets to the right engineering team, handling thousands of teams and high throughput.
You're building a machine learning system to automatically route incoming bug reports to the correct engineering team in a large organization. The company has grown to manage thousands of internal teams across many products, and manual routing has become a bottleneck—tickets often get assigned to the wrong team, causing delays.
Your Task
Design an end-to-end ML pipeline that predicts which team should handle each new ticket. The system should also know when it's uncertain and escalate those cases to human reviewers.
Context and Constraints
Volume: The platform receives around 500,000 tickets daily, with peak traffic reaching thousands per minute. There are over 5,000 distinct engineering teams.
Ticket Content: Each ticket includes a title, description, the person who filed it, component tags, and sometimes attached logs or stack traces.
Latency: Classification can take 1–2 seconds. Faster is better, but this budget is acceptable.
Accuracy vs. Coverage: A wrong assignment wastes hours as the ticket bounces between teams. It's better to route 70% of tickets correctly than to route 95% with frequent mistakes.
Evolving Organization: Teams are created, merged, renamed, and reorganized regularly. The system must adapt without full retraining.
What to Cover
-
Feature Representation: How do you turn a ticket into features for the model? What metadata and signals matter most?
-
Modeling Approach: What architecture do you use? How do you handle 5,000+ classes efficiently? When and how might you use embeddings, traditional ML, or language models?
-
Confidence and Escalation: How do you decide when the model is confident enough to auto-assign versus when a human should decide?
-
Continuous Learning: How does the system improve over time using feedback from resolved tickets and reassignments?
-
Evaluation: What metrics determine whether the system is working well? How do you measure success beyond raw accuracy?
Discuss the trade-offs in your design and call out the risks or edge cases you'd monitor in production.
Hints
Hint 1
Start by defining what a correct label means—don't assume the first assignment is ground truth; look at which team ultimately resolved it.
Hint 2
With thousands of teams, a flat classifier is brittle. Consider retrieval-based methods that find candidate teams first, then rank them.
Hint 3
Misclassification cost is asymmetric: a wrong auto-assignment wastes more time than asking a human to triage. Design your confidence thresholds accordingly.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Automated Ticket Routing System
1. Clarify the Problem and Constraints
Before designing anything, establish key definitions:
Ground Truth: The "correct" team is the one that ultimately resolved the ticket, not the first team it was routed to. Initial assignments are noisy—exactly what we're trying to fix.
Throughput: 500K tickets per day averages to ~6/sec, with peaks around 50–100/sec. This is manageable, so the real challenge is the 5,000-class space, label noise, and organizational churn.
Error Cost: Routing to the wrong team wastes hours or days. Sending a ticket to human triage costs minutes. The system should maximize precision for a given coverage rate, not just raw accuracy.
Latency: The 1–2 second budget allows for a two-stage model but rules out running a large language model on every ticket.
2. Feature Engineering
Build a rich representation from multiple signal types:
Text Features:
- Embeddings of the title and description (sentence transformers or domain-tuned BERT)
- Extracted entities: service names, error codes, API endpoints, package names
Log and Stack Trace Features:
- Normalized stack trace signature (top N frames, exception type)
- Service or module names extracted from the trace, mapped to owning teams via a service catalog or CODEOWNERS file
Structured Metadata:
- Project, component tags, product area, environment (prod/staging), severity
- Reporter identity and their team affinity (which teams typically handle this reporter's issues)
Contextual Signals:
- Recent similar tickets and their resolving teams (temporal kNN)
- Whether an active incident matches this ticket's symptoms
Team Representations: Each team is also embedded as a searchable entity:
- Team charter and ownership documentation (embedded)
- Owned components and services (from metadata)
- A recency-weighted centroid of recently resolved tickets
This dual representation (tickets and teams as vectors) enables retrieval and handles cold starts when new teams form.
3. Model Architecture: Two-Stage Retrieval + Ranking
A flat 5,000-way softmax classifier is fragile: it requires retraining whenever teams change, performs poorly on rare teams, and doesn't generalize. Instead, use a retrieve-then-rank design.
Stage 1: Candidate Generation (~20–50ms)
Generate the top 30–50 candidate teams from multiple sources:
- Vector similarity: Embed the ticket, then run approximate nearest neighbor search against team embeddings (FAISS or similar).
- Historical kNN: Find the 20 most similar resolved tickets (based on text + metadata) and vote by their resolving teams.
- Deterministic rules: Direct matches from component ownership maps or CODEOWNERS hits in stack traces.
Merge and deduplicate these candidates.
Stage 2: Ranking (~100–300ms)
Train a gradient boosted decision tree (LightGBM or XGBoost) to score each (ticket, team) pair. Features include:
- Similarity scores from stage 1
- Component/ownership match indicators
- Reporter-team affinity (historical probability)
- Team's historical acceptance rate for this ticket type
- kNN vote share and rank
Use a listwise or pairwise ranking objective (e.g., LambdaRank) rather than pointwise classification. Then calibrate the scores (Platt scaling or isotonic regression) so the top-1 probability reflects true precision.
Why not an LLM everywhere? Running a large language model on every ticket is expensive and slow. Instead, use the lightweight pipeline for most tickets and reserve an LLM (with retrieval-augmented context showing candidate teams' charters) as a fallback for low-confidence cases—roughly 10–20% of volume. This keeps cost and latency under control while applying reasoning where it's needed.
4. Handling Cold Start and Concept Drift
New Teams: Because teams are represented as vectors and metadata, a newly created team becomes routable immediately once it has:
- A charter or ownership doc (for embedding)
- Assigned components or services
- Code ownership entries
Temporarily lower the auto-assignment threshold for new teams so their tickets go to the suggestion queue, generating high-quality labels quickly. If a team is formed by splitting another, inherit its parent's historical data.
Organizational Changes: Subscribe to events like team renames, mergers, and component reassignments. Remap historical labels where possible and mark stale labels as invalid. Rebuild team centroids nightly with recency weighting (e.g., exponential decay over 90 days).
Model Retraining: Retrain the retrieval encoder and ranker weekly or biweekly on a sliding window of recent data. Monitor per-team reassignment rates and input feature distributions. A sudden spike in reassignments for one team signals a shift in scope—automatically drop that team to suggestion mode and alert the team to update their metadata.
5. Confidence-Based Routing Logic
Use the calibrated top-1 probability p and the margin between top-2 candidates to decide:
- AUTO_ASSIGN if p ≥ τ_high (e.g., 0.85) and margin is substantial. Set τ_high per product area to guarantee ≥95% precision offline.
- SUGGEST if τ_low ≤ p < τ_high. Route to a triage queue with top-3 candidates and explanations. Triage is one click.
- FULL_TRIAGE if p < τ_low or the ticket is from an unknown product. A human routes from scratch, optionally aided by an LLM summary.
Human decisions are high-value labels and should be weighted more heavily in retraining. To prevent feedback loops, hold out a small random sample (~5%) of auto-assignable tickets and force them into SUGGEST mode to collect unbiased ground truth.
6. Feedback Loop
Capture reassignment and resolution events via an API:
POST /feedback
{ ticket_id, final_team_id, event: REASSIGNED | RESOLVED, timestamp }
A ticket's label is finalized when it's marked resolved. Filter out closures like "duplicate" or "won't fix" that don't reflect routing accuracy. Feed this data back into a training store, with human-triaged labels weighted 2–3x higher.
7. Evaluation Metrics
Offline (on historical held-out data):
- Top-1 and Top-3 Accuracy, reported both micro (overall) and macro (per-team average). Macro reveals performance on rare teams.
- Coverage at Fixed Precision: Percentage of tickets auto-assigned while maintaining ≥95% precision. This is the primary business metric.
- Calibration Error (ECE): Measures whether predicted probabilities match observed accuracy.
- Cost-Weighted Error: Misrouting to a sibling team (same org) is cheaper than crossing product boundaries. Build a cost matrix from historical bounce delays and optimize expected cost.
Online (in production):
- Reassignment ("bounce") rate
- Time to correct assignment
- Mean time to resolution (MTTR)
- Triage queue size and wait time
- Per-team override rate (how often teams manually reassign their auto-assigned tickets)
Guardrails:
- SLA breach rate for high-severity bugs must not increase
- No individual team's inbound volume should spike abnormally (detect via anomaly detection)
8. Key Trade-offs
- Retrieval vs. Flat Classifier: Retrieval adds complexity but enables extensibility, better long-tail coverage, and graceful handling of new teams. A flat classifier is simpler but brittle.
- Threshold Tuning: Higher τ means more human work but fewer mistakes. Lower τ increases automation but risks more bounces. Tune per product area based on business cost.
- LLM Cost: Using an LLM on every ticket is prohibitively expensive. Restricting it to low-confidence cases keeps cost manageable while improving hard cases.
- Retraining Frequency: Weekly retraining balances freshness with stability. More frequent updates risk overfitting to transient patterns; less frequent updates miss organizational changes.
9. Common Pitfalls
- Using first assignment as ground truth (circular and noisy)
- Ignoring class imbalance—some teams see 100x more tickets than others
- Failing to calibrate confidence scores, leading to over- or under-assignment
- Not accounting for organizational drift, causing model performance to degrade silently
- Optimizing for accuracy when the real goal is precision at scale
This design balances automation with safety, adapts to organizational change, and ensures the system improves continuously through human feedback.