All projects

AI AUTOMATION / N8N

AI Customer Support Ticket Automation

An end-to-end support workflow built to receive customer tickets from Gmail, prevent duplicates, classify and validate incoming issues with an LLM, route priority cases, draft a customer reply, require human approval, send the approved response, and preserve a traceable lifecycle.

n8nGmailGroqPostgreSQLSlackJavaScriptHuman-in-the-Loop

01 / OVERVIEW

Automation that keeps a human in control.

The workflow connects the customer inbox to a structured processing path. Each stage has a defined responsibility: Gmail provides the input, JavaScript normalizes the message, PostgreSQL protects against duplicates and stores state, AI handles classification and drafting, Slack surfaces urgent work, and human approval gates the final customer reply.

Gmail intakeAI triagePostgreSQLSlack escalationHuman approvalAudit logging

02 / ARCHITECTURE

A pipeline with explicit decisions.

01Gmail Trigger
Receives unread support mail
02Normalize + Deduplicate
Extracts stable ticket fields
03AI Classify + Validate
Constrains the AI output
04Persist + Assign
Creates ticket and maps support team
05Escalate + Draft
Slack alert and customer response draft
06Approve + Send
Human gate before Gmail reply

Core path

Gmail → content extraction → duplicate check → AI classification → validation → ticket creation → team assignment → priority handling → response drafting → approval → customer reply.

03 / CONTROLS

Reliability comes from constraints.

01

Duplicate protection

The workflow checks the external Gmail message ID before creating a ticket, with the duplicate branch stopping further processing.

02

Structured validation

The classification output is parsed and checked against allowed categories, priorities and sentiments, plus required fields and human-review rules.

03

Deterministic routing

Support-team assignment is handled by a fixed category-to-team map rather than leaving routing decisions entirely to the model.

04

Grounded response drafting

The response prompt limits the draft to the ticket information and prohibits invented order, tracking, payment, policy or resolution details.

04 / HUMAN APPROVAL

The AI drafts. A person decides.

After the draft is saved, the ticket enters pending_approval. Gmail's send-and-wait approval step pauses execution until the reviewer chooses Approve or Reject.

ApproveRecord approval → send Gmail reply → mark the ticket sent → record the customer-reply event.
RejectRecord rejection → reopen the ticket → preserve the rejection and reopening events in the audit trail.
Customer-safe behaviorThe outbound reply is blocked until the approval branch explicitly succeeds.
TraceabilityThe approval outcome is retained with the ticket's event history.

05 / AUDIT TRAIL

Track the ticket lifecycle as data.

The ticket_events table records the important transitions instead of relying only on the workflow canvas. Events used in the project include:

ticket_createdticket_assignedhigh_priority_alert_sentresponse_draftedapproval_requestedresponse_approvedresponse_rejectedcustomer_reply_sentticket_reopened

Why this matters

A ticket can be inspected after execution to understand what happened, in what order, and what branch the workflow took.

06 / ERROR HANDLING

Failures are logged as events.

A separate error workflow captures failed executions and stores the workflow name, workflow ID, execution ID, failed node, error message, execution reference and timestamp in a dedicated error table before sending a Slack notification.

01Error Trigger
Receives the failed execution
02Persist Error
Stores failure details
03Notify Slack
Alerts the operator

A controlled SQL failure was used during testing to verify that this path worked.

07 / TESTING

Test the workflow, not just the configuration.

Normal ticket

Low or medium tickets continue through classification, assignment, drafting and approval without the high-priority Slack branch.

High / Critical ticket

High and critical priority tickets take the alert path and record the escalation event.

Duplicate

A repeated ticket returns duplicate: true and is stopped before ticket creation.

Rejection

A rejected response reopens the ticket rather than sending a customer reply.

Approval

An approved draft is sent through Gmail and the ticket is marked sent.

Failure

An intentional PostgreSQL error verifies error capture and Slack notification.

08 / EXECUTION EVIDENCE

Screenshots from the working automation.

These screenshots document the actual n8n workflow, execution branches, human-approval step, PostgreSQL records, Slack notifications and tested duplicate/error paths used in the project.

Evidence-first portfolio: each image is included as a captured project artifact rather than a decorative mockup. Click any screenshot to open the full-size view.

09 / REPOSITORY

Explore the implementation.

The complete workflow documentation, SQL, testing notes and project evidence are maintained in the repository.

Next projectAURA One Showcase