Context:
HouseBox is a fast-growing e-commerce store specializing in home organization products, storage containers, and kitchen modules. Handling dozens of inbound customer emails daily, the support team required 24/7 ticket classification and priority routing. Manual ticket triage delayed responses, while critical complaints and high-value B2B inquiries risk getting buried in general inquiries and spam.
Problem:
- Manual Ticket Triage: Support managers spent over 2 hours daily manually reading, categorizing, and forwarding emails to relevant departments.
- Lost Critical Escalations: High-priority issues—such as damaged goods upon delivery (P1) or wholesale B2B inquiries (P2)—were mixed with routine questions, causing high churn and potential chargebacks.
- Lack of SLA Enforcement: No automated tracking existed for response deadlines, leading to breached SLAs without management visibility.
Solution:
Engineered a closed-loop, two-track AI Ticket Routing and SLA Control system in n8n integrating real-time incoming classification with automated deadline enforcement:
- WF1: Intake & AI Classification Engine: Listens for inbound emails via Gmail API, extracts metadata, passes email content to Google Gemini API via Chain-of-Thought (CoT) prompting to evaluate sentiment, risk, and assign category (Delivery, Quality, Consultations, B2B, Spam) and priority (P1–P4) with SLA timeframes. Filters out spam (P4) and logs valid tickets to Google Sheets while notifying assigned department owners in Telegram.
- WF2: SLA Watcher & Escalation Engine: Runs on a 5-minute cron schedule, polls Google Sheets for
open tickets, evaluates current time against sla_deadline, computes overdue minutes, and routes breached tickets through a 3-tier escalation hierarchy:
- Level 0 (0–30 min overdue): Direct Telegram reminder to the assigned ticket owner.
- Level 1 (30–60 min overdue): Escalation alert dispatched to the Team Lead Telegram channel.
- Level 2 (60+ min overdue): Emergency HTML email dispatch to the Director containing full AI reasoning and context.
Process:
- Prompt Design
- Designed a structured System Message enforcing Chain-of-Thought (CoT) evaluation: the model assesses customer sentiment and business risk prior to outputting classification.
- Enforced strict JSON schema parsing (
category, priority, sla_minutes, owner, reasoning).
- Configured specific safety overrides: explicit urgency or repeated complaint markers ("writing second time", "refund money") automatically elevate priority to P1/P2.
- API & Workflow Engineering
- Gmail API & Deep Linking: Extracted thread identifiers to construct direct one-click Gmail inbox deep links (
[https://mail.google.com/mail/u/0/#inbox/](https://mail.google.com/mail/u/0/#inbox/){threadId}).
- Data Normalization & Logging: Computed dynamic deadlines (
created_at + sla_minutes) and logged structured records into Google Sheets API.
- Multi-Branch Escalation: Engineered conditional routing logic (
Switch by Level) driven by JavaScript date delta calculations (overdue_minutes).
Results:
- 0 Minutes Manual Triage: 100% automated email categorization and department routing upon receipt.
- < 15 Minutes P1 Response SLA: Guaranteed 15-minute SLA enforcement for critical product defect and risk complaints.