The classification engine is the first service called on every new ticket. It uses OpenAI’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/yocxy2/2a/llms.txt
Use this file to discover all available pages before exploring further.
gpt-4o-mini model to read the raw user_description and return a structured JSON payload containing the ticket category, a suggested customer-facing response, and a numeric confidence score. That score then gates whether the ticket is auto-resolved or routed to a human agent.
The
OPENAI_API_KEY environment variable must be set before starting the backend. Without it the OpenAI client will fail to initialise and all classification calls will fall back to the default error response.Classification categories
GPT-4o-mini classifies every ticket into exactly one of the following six categories. The category is stored on the ticket record and used to filter tickets in the agent dashboard.- Billing — payment issues, invoices, charges
- Technical — bugs, errors, platform behaviour
- Shipping — delivery status, tracking, logistics
- Returns — refund requests, product returns
- Account — login, passwords, profile settings
- Other — anything that doesn’t fit the above
How classification works
classifyTicket() in src/services/aiService.ts makes a single chat.completions.create call with the following model parameters:
| Parameter | Value | Reason |
|---|---|---|
model | gpt-4o-mini | Fast and cost-efficient for classification tasks |
temperature | 0.3 | Low temperature for consistent, deterministic outputs |
response_format | { type: 'json_object' } | Enforces structured JSON output every time |
aiService.ts:
Confidence scoring
Theconfidence_score is the model’s self-reported certainty that the classification and suggested response are correct. It drives automated routing:
confidence_score >= 0.7→ ticket status is set toai_resolved. The AI response is considered reliable and no human review is required by default.confidence_score < 0.7→ ticket status is set topending_agent. The ticket is queued for a human support agent to review.
0.5 always routes the ticket to pending_agent, making it the safe default when the model returns an unexpected value.
Embedding generation
generateEmbedding() converts any text string into a dense vector representation suitable for pgvector similarity search. It uses OpenAI’s text-embedding-3-small model, which produces a 1536-dimension vector.
- RAG search — to embed the incoming ticket description before running pgvector cosine similarity against knowledge base articles.
- Entity storage — to embed each extracted entity name before storing it in the
entitiestable. - Entity search — to embed a ticket query before finding the nearest entities in the knowledge graph.
Entity extraction
extractEntities() sends the ticket text to GPT-4o-mini with a dedicated system prompt instructing it to identify named entities. It returns an array of ExtractedEntity objects, each with a name and a type from the fixed taxonomy below.
Supported entity types: Person, Place, Concept, Product, Organization
json_object response format as classification:
Fallback behavior
If the OpenAI API call fails for any reason (network error, rate limit, invalid API key, etc.),classifyTicket() catches the error and returns a safe fallback object instead of propagating the exception:
confidence_score of 0.3 is always below the 0.7 threshold, so the ticket will be routed to pending_agent. This ensures a human agent reviews any ticket the AI could not classify — no ticket is silently dropped.