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)
HouseBox Support Automation. An intelligent pipeline for processing incoming customer inquiries with strict response time monitoring.

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.

Figure 1. HouseBox Customer Support Baseline. Analysis of operational metrics and key turnaround bottlenecks prior to automation.

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

  1. Gmail Trigger[M5-TEST] emails
  2. Ticket Contextfield normalization
  3. AI ClassifierOpenAI + Chain of Thought
  4. Output ParserJSON schema validation
  5. Flatten Resultflat data structure
  6. Not Spam?promotional filter
  7. Google Sheetslogging (status: open)
  8. Telegraminstant owner alert

Pipeline 2 · SLA Monitoring & 3-Tier Escalation

  1. SLA Watcherevery 5 minutes
  2. Read Open Ticketsquery status = open
  3. SLA Breached?current time > deadline
  4. Compute Escalationminutes overdue calculation
  5. Route EscalationSwitch: L0 / L1 / L2
  6. L0: Owner (TG)0–15 min overdue
  7. L1: Team Lead (TG)15–30 min overdue
  8. L2: Director (Email)>30 min overdue
Figure 2. End-to-End Ticket Routing and SLA Logic. 7 key stages: from email intake in Gmail to automated multi-tier escalation upon SLA breach.
Figure 3. Full System Architecture in n8n. The upper workflow handles incoming ticket ingestion and database logging; the lower workflow periodically scans open tickets for SLA breaches.

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.

Automation Layer · n8n Engine

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.
AI Layer · OpenAI Chat Model

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 null for 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.

  1. Gmail Trigger: fetches incoming emails and extracts raw message parameters.
  2. Ticket Context: normalizes fields (ticket_id, from_email, subject, body, created_at, thread_link).
  3. AI Ticket Classifier: LangChain/Tools Agent powered by OpenAI with strict system prompts and Chain of Thought.
  4. Output Parser & Flatten Result: validates JSON schema types and flattens nested fields for downstream processing.
  5. Not Spam? (If Node): validates category; spam messages route to an empty terminal branch.
  6. Log to Tickets & Notify Owner: appends the ticket into Google Sheets with status 'open' and dispatches an instant Telegram card to the assigned owner.
Figure 4. Step-by-Step Ticket Ingestion Pipeline. Automated workflow from email reception to owner assignment and instant dispatch.

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.

JSON Response Schema
{
  "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.

Figure 7. Classifier System Instructions. Defining agent role, store context, category taxonomy, routing rules, and the SLA matrix.
Figure 8. Chain of Thought & Output Format. Enforcing step-by-step reasoning and strict numeric typing for the sla_minutes field.

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.

Figure 9. Output Parser in n8n. Validating ticket input payload and enforcing strict schema typing.
Figure 10. AI Classification of Promotional Spam. The model identified 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.

Categories (Category)

Inquiry thematic scope:

  • delivery
  • returns
  • payment
  • product
  • complaint
  • spam
Priorities & SLA

First response time limits:

  • P1 · 15 min
  • P2 · 120 min
  • P3 · 1,440 min
  • P4 · 2,880 min
Customer Sentiment

Emotional tone of customer messages:

  • positive
  • neutral
  • frustrated
  • angry
Figure 11. Operational Ticket Registry in Google Sheets. 10 unique test inquiries displaying calculated SLA deadlines, assigned owners, and open resolution statuses.
Open Live HouseBox Spreadsheet in Google Sheets →

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 Ticket

Instant 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.

Owner Notification. Registration of delivery ticket [M5-TEST] 01 with resolution deadline set to 02.10.2026.

2. Tier L0: Initial SLA Breach

Telegram · 0–15 Min Overdue

Warning 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.

Tier L0 Escalation. Warning notification sent to delivery_manager regarding an SLA breach of 14 minutes.

3. Tier L1: Team Lead Escalation

Telegram · 15–30 Min Overdue

Automated 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.

Tier L1 Escalation. Notification dispatched to Support Team Lead with complete customer context and AI reasoning.

4. Tier L2: Executive Director Email

Gmail Email · >30 Min Overdue

Critical 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.

Tier L2 Escalation. Executive email alert sent to the Director regarding an unresolved P2 incident (order item mismatch).

Key Technical Decisions

Three core architectural decisions that ensured system reliability, schema resilience, and high fault tolerance.

01 · Structured Output Enforcement

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.

02 · Integer-Based SLA Calculation

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.

03 · Decoupled SLA Architecture

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
Important Note on Metrics. The baseline operational figures (900 inquiries/month, 11-hour average response time, and CSAT drop from 4.3 to 2.9) illustrate the incoming business challenge faced by HouseBox prior to automation, rather than measured post-implementation results. This project fully engineered, deployed, and verified the end-to-end technical architecture, proving complete resolution of routing bottlenecks across an 11-ticket test suite.

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