Intelligent Ticket Router

Automatically classify support tickets and route to the right team with urgency assessment.

This workflow analyzes ticket content, assigns categories, determines urgency, and routes to specialized teams.

Implementation

1import { relay } from "@relayplane/workflows";
2
3const result = await relay
4 .workflow("ticket-router")
5
6 // Step 1: Classify ticket type and extract key info
7 .step("classify")
8 .with("openai:gpt-4o")
9 .prompt(`Classify this support ticket:
10
11Subject: {{subject}}
12Body: {{body}}
13
14Return JSON:
15{
16 "category": "billing|technical|account|feature_request|bug",
17 "subcategory": "specific classification",
18 "urgency": "critical|high|medium|low",
19 "sentiment": "frustrated|neutral|positive",
20 "keyEntities": ["product names", "error codes", "account IDs"]
21}
22
23Only respond with valid JSON.`)
24
25 // Step 2: Determine routing and SLA
26 .step("route")
27 .with("anthropic:claude-3.5-sonnet")
28 .depends("classify")
29 .prompt(`Based on this classification, determine routing:
30{{classify.output}}
31
32Teams:
33- Billing: billing issues, refunds, invoices
34- Engineering: bugs, technical errors, API issues
35- Account Management: enterprise customers, upgrades
36- Product: feature requests, product questions
37- Tier1: general inquiries
38
39Return JSON:
40{
41 "team": "team name",
42 "priority": 1-4,
43 "sla_hours": number,
44 "requires_escalation": boolean,
45 "suggested_tags": ["tag1", "tag2"]
46}`)
47
48 // Step 3: Generate initial response suggestion
49 .step("draft-response")
50 .with("anthropic:claude-3.5-sonnet")
51 .depends("classify", "route")
52 .prompt(`Draft an acknowledgment response for this ticket:
53
54Classification: {{classify.output}}
55Routing: {{route.output}}
56
57Requirements:
58- Acknowledge their specific issue
59- Set expectation for response time
60- Ask clarifying questions if needed
61- Empathetic tone if frustrated
62- Professional and concise`)
63
64 .run({
65 subject: ticketSubject,
66 body: ticketBody,
67 });
68
69// Parse routing decision
70const routing = JSON.parse(result.steps["route"].output);
71
72// Send to appropriate team
73await sendToTeam(routing.team, {
74 ticketId: ticket.id,
75 priority: routing.priority,
76 slaHours: routing.sla_hours,
77 draftResponse: result.steps["draft-response"].output,
78 tags: routing.suggested_tags,
79});

Integration with Support Systems

1// Zendesk integration example
2import { relay } from "@relayplane/workflows";
3
4async function handleNewTicket(ticket: ZendeskTicket) {
5 const result = await relay
6 .workflow("ticket-router")
7 .run({
8 subject: ticket.subject,
9 body: ticket.description,
10 });
11
12 const routing = JSON.parse(result.steps["route"].output);
13
14 // Update Zendesk ticket
15 await zendesk.tickets.update(ticket.id, {
16 assignee_id: getTeamId(routing.team),
17 priority: routing.priority,
18 tags: routing.suggested_tags,
19 comment: {
20 body: result.steps["draft-response"].output,
21 public: true,
22 },
23 });
24}

Benefits

  • Reduce median time-to-first-response by 60%
  • Route 85%+ of tickets correctly on first pass
  • Automatic SLA assignment based on urgency
  • Pre-drafted responses save agent time
Scale Impact: Handle 10x ticket volume with same team size