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";23const result = await relay4 .workflow("ticket-router")56 // Step 1: Classify ticket type and extract key info7 .step("classify")8 .with("openai:gpt-4o")9 .prompt(`Classify this support ticket:1011Subject: {{subject}}12Body: {{body}}1314Return 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}2223Only respond with valid JSON.`)2425 // Step 2: Determine routing and SLA26 .step("route")27 .with("anthropic:claude-3.5-sonnet")28 .depends("classify")29 .prompt(`Based on this classification, determine routing:30{{classify.output}}3132Teams:33- Billing: billing issues, refunds, invoices34- Engineering: bugs, technical errors, API issues35- Account Management: enterprise customers, upgrades36- Product: feature requests, product questions37- Tier1: general inquiries3839Return JSON:40{41 "team": "team name",42 "priority": 1-4,43 "sla_hours": number,44 "requires_escalation": boolean,45 "suggested_tags": ["tag1", "tag2"]46}`)4748 // Step 3: Generate initial response suggestion49 .step("draft-response")50 .with("anthropic:claude-3.5-sonnet")51 .depends("classify", "route")52 .prompt(`Draft an acknowledgment response for this ticket:5354Classification: {{classify.output}}55Routing: {{route.output}}5657Requirements:58- Acknowledge their specific issue59- Set expectation for response time60- Ask clarifying questions if needed61- Empathetic tone if frustrated62- Professional and concise`)6364 .run({65 subject: ticketSubject,66 body: ticketBody,67 });6869// Parse routing decision70const routing = JSON.parse(result.steps["route"].output);7172// Send to appropriate team73await 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 example2import { relay } from "@relayplane/workflows";34async function handleNewTicket(ticket: ZendeskTicket) {5 const result = await relay6 .workflow("ticket-router")7 .run({8 subject: ticket.subject,9 body: ticket.description,10 });1112 const routing = JSON.parse(result.steps["route"].output);1314 // Update Zendesk ticket15 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