The Scenario
You've just joined the engineering team at a growing SaaS company. The support team receives customer tickets from multiple channels — all of them land in a single JSON log file. Right now, support staff are manually reading every ticket and deciding where it goes. It's slow, error-prone, and not scaling.
Your tech lead has asked you to build a ticket routing module: a Python script that reads the raw ticket data, assigns each ticket a priority level, routes it to the correct support queue, and outputs the processed results. This is a real, working proof-of-concept — not a diagram or design doc.
Ticket data arrives in this format:
{
"tickets": [
{
"id": "T-1001",
"customer_id": "C-4421",
"customer_tier": "premium",
"subject": "Cannot log in to account",
"description": "Unable to access my account for two days. Urgent.",
"submitted_at": "2026-03-15T09:32:00Z"
},
{
"id": "T-1002",
"customer_id": "C-8810",
"customer_tier": "standard",
"subject": "How do I export a report?",
"description": "I cannot find the export button on the reports page.",
"submitted_at": "2026-03-15T09:45:00Z"
},
{
"id": "T-1003",
"customer_id": "C-2233",
"customer_tier": "standard",
"subject": "Billing question",
"submitted_at": "2026-03-15T10:01:00Z"
}
]
}
Priority Rules
| Priority | Condition |
|---|---|
| HIGH | Ticket is from a customer_tier of "premium" OR the subject or description contains any of these keywords: "urgent", "cannot", "broken", "down", "failed" |
| MEDIUM | All other tickets that have a non-empty description |
| LOW | Tickets with no description (the field is absent or empty) |
Routing Rules
| Priority | Destination Queue |
|---|---|
| HIGH | "urgent-queue" |
| MEDIUM | "standard-queue" |
| LOW | "backlog-queue" |
Expected Output Format
Your script should print (or return) the processed tickets. The exact format is your choice — a list of dicts, a formatted print statement, or JSON — as long as it clearly shows each ticket's id, assigned priority, and destination queue.
On this page