▶️ Context

▶️ Problem

▶️ Solutions

Built an n8n agent that ingests an incoming ticket (email/chat), classifies it via an LLM (OpenAI, gpt-4.1-mini) against a structured schema, and automatically:

  1. Determines the category (support / sales / tech / billing / spam) using clear criteria.
  2. Assigns a priority (P1–P4) based on a 3-dimensional analysis (urgency, business impact, VIP context), with dedicated special rules — e.g., a VIP client always gets at least P2, legal complaints always get P1.
  3. Calculates the SLA deadline (15 min / 2 hr / 24 hr / 48 hr) and stores it in a format ready for later comparison against the current time.
  4. Assigns an owner (support_lead / sales_lead / tech_lead / finance_lead) by category, with a fallback to support_lead for any ambiguous case.
  5. Logs the ticket in Google Sheets as the central tracker (status, deadline, reasoning, customer sentiment).
  6. Monitors SLA breaches via a separate check cycle and escalates through Slack/Email along a 3-tier chain (L0 — reminder to owner → L1 — team lead → L2 — director).
  7. Generates a thread_link to the original Gmail thread so the responsible person can jump straight into context.

The key architectural decision was using a Structured Output Parser with a strict enum-based schema (rather than free-text LLM output), guaranteeing the result is always valid JSON — ready for direct writing into the tracker and downstream automation, with no manual text parsing required.