Case 03 · n8n · OpenAI · SLA Control
HouseBox — Automated Ticket Routing & SLA Control
End-to-end customer inquiry triage powered by LLMs, intelligent owner assignment, single-source logging in Google Sheets, and three-tier SLA monitoring with automated escalation across Telegram and executive email.
- 11 ticketstested (10 production workflows + 1 spam)
- 5 categoriesrouting taxonomy + spam filtering
- 4 SLA tiersfrom P1 (15 min) to P4 (2,880 min)
- 3 escalation tiersL0 (Owner), L1 (Team Lead), L2 (Director)
Video not loading? Open on YouTube
900 monthly inquiries and an 11-hour response time: manual triage was crippling customer support
“Manual ticket sorting creates a critical bottleneck: agents spend valuable time reading and dispatching emails instead of resolving complex customer problems, while urgent complaints risk going unnoticed.”
Business Context. HouseBox is a growing e-commerce retailer specializing in home goods. Incoming customer inquiries arrive across three primary channels: email, Telegram, and phone. Prior to automation, the entire intake was handled manually by a small team of 3 customer support agents.
Baseline Challenges:
- High ticket volume: approximately 900 customer inquiries per month.
- Repetitive inquiries: ~50% of all incoming requests were standard questions regarding order status and delivery tracking.
- Slow response times: average first response time (FRT) reached 11 hours.
- Declining customer loyalty: customer satisfaction score (CSAT) dropped from 4.3 to 2.9 over a three-month span.
Project Objective. Automate the entire triage sequence: classify email topics using AI, assign a dedicated owner, compute the contractual SLA deadline, record the inquiry in Google Sheets, and automatically escalate breached tickets before issues impact customer trust.
End-to-End Architecture: Two Decoupled Pipelines in n8n
Rather than relying on a fragile monolithic process, the system is separated into two isolated n8n workflows: an event-driven intake and AI classification pipeline, and a scheduled polling pipeline for SLA auditing and escalation.
Pipeline 1 · Intake & AI Ticket Routing
- Gmail Trigger[M5-TEST] emails
- Ticket Contextfield normalization
- AI ClassifierOpenAI + Chain of Thought
- Output ParserJSON schema validation
- Flatten Resultflat data structure
- Not Spam?promotional filter
- Google Sheetslogging (status: open)
- Telegraminstant owner alert
Pipeline 2 · SLA Monitoring & 3-Tier Escalation
- SLA Watcherevery 5 minutes
- Read Open Ticketsquery status = open
- SLA Breached?current time > deadline
- Compute Escalationminutes overdue calculation
- Route EscalationSwitch: L0 / L1 / L2
- L0: Owner (TG)0–15 min overdue
- L1: Team Lead (TG)15–30 min overdue
- L2: Director (Email)>30 min overdue
Automation vs. AI: Strict Separation of Concerns
A foundational architectural principle: automation orchestrates the business process, data transport, and timing, while artificial intelligence interprets unstructured message content and makes expert classification decisions.
Deterministic Process Control
The n8n platform guarantees technical execution reliability and deterministic routing:
- Ingesting email events via the Gmail Trigger node filtered by subject line.
- Extracting ticket metadata: ticket ID, sender address, timestamp, and thread link.
- Enforcing data types and JSON output structure via Output Parser.
- Conditional routing: discarding promotional noise via the Not Spam? node.
- Two-way synchronization with Google Sheets (appending rows and polling statuses).
- Executing automated SLA health checks every 5 minutes via Schedule Trigger.
- Dispatching targeted alerts via Telegram Bot API and critical escalation emails via Gmail API.
Semantic Analysis & Expert Evaluation
The language model performs the cognitive duties of a Tier-1 support dispatcher:
- Determining inquiry intent and assigning it to one of 5 business categories (or classifying as spam).
- Analyzing customer sentiment:
positive,neutral,frustrated,angry. - Evaluating urgency and business impact, assigning priority from P1 (critical) to P4 (informational).
- Assigning a designated functional owner (Owner) or
nullfor spam. - Setting contractual SLA resolution time in minutes (sla_minutes strictly as an integer).
- Generating step-by-step decision justification (reasoning) in 2–3 sentences using Chain of Thought prompting.
Workflow Architecture & Implementation
Switch between tabs to inspect the execution logic and node configurations of each pipeline in n8n.
Primary Workflow: Ticket Ingestion & Routing
Triggered by the arrival of a new email in the support inbox bearing the [M5-TEST] tag. The workflow normalizes message data, fetches a validated JSON response from the language model, filters out non-actionable spam, logs the ticket into the database, and immediately notifies the assigned owner on Telegram.
Thanks to the Not Spam? filter node, promotional outreach does not clutter agent queues and is excluded from the operational database.
- Gmail Trigger: fetches incoming emails and extracts raw message parameters.
- Ticket Context: normalizes fields (ticket_id, from_email, subject, body, created_at, thread_link).
- AI Ticket Classifier: LangChain/Tools Agent powered by OpenAI with strict system prompts and Chain of Thought.
- Output Parser & Flatten Result: validates JSON schema types and flattens nested fields for downstream processing.
- Not Spam? (If Node): validates category; spam messages route to an empty terminal branch.
- Log to Tickets & Notify Owner: appends the ticket into Google Sheets with status 'open' and dispatches an instant Telegram card to the assigned owner.
SLA Watcher: Scheduled Auditing & 3-Tier Escalation
The secondary workflow operates independently on a 5-minute schedule timer. It queries Google Sheets for all unresolved tickets (status = open), evaluates the calculated SLA deadline against server UTC time, and calculates the exact overdue duration in minutes upon breach detection.
Based on the overdue duration, the Route by Escalation node directs the incident across three escalation tiers:
- L0 (0–15 min overdue): reminder alert sent to the ticket owner on Telegram urging prompt action.
- L1 (15–30 min overdue): escalation alert sent to the Support Team Lead on Telegram with full context and reasoning.
- L2 (>30 min overdue): critical escalation email dispatched to the Director via Gmail.
- SLA Watcher (Schedule Trigger): runs automatically every 5 minutes.
- Read Open Tickets: reads Google Sheets rows filtered by
status = open. - SLA Breached? (If Node): evaluates condition
now > sla_deadline. - Compute Escalation Level: JavaScript node calculates minutes overdue and tags the incident as L0, L1, or L2.
- Route by Escalation (Switch Node): routes the payload to the corresponding notification channel.
- Dispatch: delivers customized Telegram alerts (L0, L1) or sends an emergency email to executive leadership (L2).
AI Classifier: Prompt Architecture & Structured JSON Enforcement
To prevent hallucinations and schema drift, the system prompt is structured across five functional blocks, and the model output is strictly enforced via an Output Parser node.
Five System Prompt Modules
1. Role: Senior Customer Support Coordinator for HouseBox. Explicit constraint to base decisions solely on provided facts.
2. Context: Business profile of HouseBox, intake channels (email, TG, phone), volume, and recurring customer requests.
3. Taxonomy & Routing Rules: Strict matrix mapping categories to designated functional owners and SLA response windows.
4. Chain of Thought: Requires internal step-by-step reasoning across problem dimensions before output generation. The reasoning field delivers a concise summary in 2–3 sentences.
5. Format & Types: Strict requirement to return sla_minutes as an integer (number), not as text, and format response as raw JSON without markdown formatting.
{
"category": "delivery|returns|payment|product|complaint|spam",
"priority": "P1|P2|P3|P4",
"owner": "delivery_manager|returns_manager|payment_manager|product_manager|support_lead|null",
"sla_minutes": 15|120|1440|2880,
"reasoning": "2–3 sentences explaining priority rationale",
"summary": "1 sentence summarizing ticket inquiry",
"customer_sentiment": "positive|neutral|frustrated|angry"
}
Critical Engineering Detail. The sla_minutes parameter must always be returned as an integer. This enables n8n to perform native arithmetic date-addition calculations to derive the exact sla_deadline timestamp without error-prone string parsing.
Output Parser: Guaranteed Data Structure
The Output Parser node validates that the language model response conforms exactly to the required JSON schema before downstream processing. For promotional spam, the model correctly outputs owner: null, allowing the conditional routing node to filter it out cleanly without pipeline failures.
category: "spam", assigned owner: null, and set priority to P4. The message was cleanly diverted by the Not Spam? node without polluting the operational database.Google Sheets: Operational Ticket Registry & Single Source of Truth
Google Sheets serves as the lightweight, auditable database for the project. Every classification result is recorded with its calculated SLA deadline, assigned owner, and real-time resolution status.
Inquiry thematic scope:
- delivery
- returns
- payment
- product
- complaint
- spam
First response time limits:
- P1 · 15 min
- P2 · 120 min
- P3 · 1,440 min
- P4 · 2,880 min
Emotional tone of customer messages:
- positive
- neutral
- frustrated
- angry
Proof of Work: Verified Alerts Across All Escalation Tiers
Every notification level was verified across real test scenarios: from instant ticket owner dispatch to multi-stage escalation during overdue SLA breaches.
1. New Ticket Owner Assignment
Telegram · New TicketInstant Telegram notification dispatched to the assigned specialist (delivery_manager) upon registration of a P3 inquiry. Contains subject, summary, SLA deadline, and direct Gmail thread link.
2. Tier L0: Initial SLA Breach
Telegram · 0–15 Min OverdueWarning alert sent to the assigned agent on Telegram when an inquiry first exceeds its SLA deadline (14 minutes overdue). Prompts immediate resolution before managerial escalation.
3. Tier L1: Team Lead Escalation
Telegram · 15–30 Min OverdueAutomated alert to the Customer Support Team Lead on Telegram when an agent fails to address a breached ticket within 30 minutes (47 minutes overdue). Includes full Chain of Thought context.
4. Tier L2: Executive Director Email
Gmail Email · >30 Min OverdueCritical executive escalation: when a high-priority P2 complaint remains unresolved past secondary thresholds (107 minutes overdue), an urgent email is dispatched directly to the Director.
Key Technical Decisions
Three core architectural decisions that ensured system reliability, schema resilience, and high fault tolerance.
Strict Structured Output
Utilizing the Structured Output Parser node enforces strict JSON typing directly from the LLM. The system is immune to formatting hallucinations, missing mandatory keys, or type mismatches. For spam inquiries, the model outputs owner: null, enabling graceful conditional filtering without integration crashes.
Numeric SLA Handling
Enforcing sla_minutes strictly as an integer (e.g. 15, 120, 1440 rather than "120 minutes") allows n8n to execute native date arithmetic. The deadline timestamp is derived directly via timestamp addition in JavaScript expressions, bypassing fragile regex or date parsing routines.
Independent Watcher Pipeline
Completely decoupling event-driven email ingestion from scheduled 5-minute SLA auditing prevents race conditions and queue blocking. Even during sudden inquiry surges, periodic SLA auditing executes reliably without putting strain on the primary triage pipeline.
Testing Results & Verification
During end-to-end practical testing, the system demonstrated 100% operational accuracy across all defined test scenarios: from routine routing to executive escalation.
| Processed test emails | 11 (10 production + 1 spam) |
|---|---|
| Unique tickets in registry | 10 |
| Business categories covered | 5 categories + spam |
| Priority range tested | P1–P4 (15 to 2,880 min) |
| Escalation tiers verified | L0 (Owner), L1 (TL), L2 (Director) |
| SLA Watcher audit frequency | every 5 minutes |
- Zero-touch automated classification and team dispatch without manual intervention
- Reliable spam filtering via Not Spam? node preventing database pollution
- Transparent decision auditing via captured Chain of Thought reasoning
- Multi-tier automated SLA enforcement with alerts across Telegram and Gmail
Technologies
- n8n Workflow Automation
- OpenAI Chat Model (GPT)
- Structured Output Parser
- Gmail API & Triggers
- Google Sheets API
- Telegram Bot API
- Chain of Thought Prompting
- SLA Monitoring Engine
See the complete system in action in the project video walkthrough.
Watch the demo