Build a Support Ticket Classifier with the Claude API
What you're actually building
A support ticket classifier takes incoming customer messages — emails, chat transcripts, help desk form submissions — and assigns them a category (billing, bug report, feature request, account access, etc.), a priority level, and often a routing destination, without a human reading every single one first. The Claude API is well suited to this because the categories are rarely a clean fixed taxonomy: tickets are messy, multi-topic, and full of edge cases that break rule-based keyword matching.
This article walks through the actual build: prompt structure, output schema, confidence handling, batching strategy, and what breaks in production. By the end you'll have a working classifier you can drop into a help desk pipeline.
Why keyword rules and old-school NLP fall short
Before LLMs, ticket classification meant regex rules or a trained text classifier (Naive Bayes, SVM, or a fine-tuned BERT model). Both approaches have the same weakness: they need retraining or rule updates every time your product, pricing, or support categories change. A customer writing "my card got charged twice and now I can't log in" is both a billing issue and an account access issue — rigid rules pick one and get it wrong half the time.
Claude handles this naturally because it reasons about intent rather than matching tokens. It can also explain why it picked a category, which matters when you need a human to audit misclassifications.
Designing the classification schema
Decide your categories and priorities before writing any code. A typical schema:
{
"category": "billing | bug_report | feature_request | account_access | other",
"priority": "low | medium | high | urgent",
"sentiment": "positive | neutral | negative | angry",
"summary": "one sentence summary",
"confidence": 0.0
}
Keep the category list short (5–8 options max). Claude's accuracy and your reviewers' sanity both degrade once you have 20+ overlapping categories. If you need subcategories, do a second classification pass only on the ones that need it, rather than one giant taxonomy.
The prompt
Use a system prompt that locks the model into strict JSON output and gives it decision rules, not just a category list.
You are a support ticket classifier for a SaaS billing platform.
Classify the ticket into exactly one category, one priority, and one sentiment.
Categories:
- billing: payment, invoice, refund, subscription issues
- bug_report: something is broken or not working as expected
- feature_request: asking for new functionality
- account_access: login, password, 2FA, permissions
- other: anything that doesn't fit above
Priority rules:
- urgent: service is down, data loss, security concern
- high: blocking the customer's work, billing error in their favor
- medium: annoying but workaround exists
- low: cosmetic or nice-to-have
Respond ONLY with valid JSON matching this schema:
{"category": string, "priority": string, "sentiment": string, "summary": string, "confidence": number between 0 and 1}
The decision rules are doing the heavy lifting here. Without them, the model guesses priority based on tone alone, which is unreliable — a calm customer describing data loss should still get "urgent."
Calling the API
If you're sending this through SubToAPI, it looks like a standard Messages call with your sub_live_... key:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet",
"max_tokens": 300,
"system": "You are a support ticket classifier... [see prompt above]",
"messages": [
{"role": "user", "content": "I was charged twice this month and support never replied. This is the third time."}
]
}'
Expected output:
{
"category": "billing",
"priority": "high",
"sentiment": "angry",
"summary": "Customer reports duplicate charge and unanswered prior support requests.",
"confidence": 0.91
}
Low-latency models work fine here — this isn't a reasoning-heavy task, so there's no need to reach for the most expensive tier. Check /pricing and /docs/messages for model options and request formats if you're setting this up for the first time.
Parsing and validating the output
Always validate the JSON before trusting it in production. Claude is reliable at following the schema, but you should never skip this step:
function parseClassification(responseText) {
let parsed;
try {
parsed = JSON.parse(responseText);
} catch {
throw new Error("Non-JSON response from classifier");
}
const validCategories = ["billing", "bug_report", "feature_request", "account_access", "other"];
const validPriorities = ["low", "medium", "high", "urgent"];
if (!validCategories.includes(parsed.category)) parsed.category = "other";
if (!validPriorities.includes(parsed.priority)) parsed.priority = "medium";
if (typeof parsed.confidence !== "number") parsed.confidence = 0;
return parsed;
}
Route anything with confidence < 0.6 or priority === "urgent" to a human reviewer instead of auto-filing it. This single rule catches most of the real-world edge cases: sarcasm, multi-issue tickets, and language the model genuinely isn't sure about.
Handling volume and batching
If you're classifying tickets as they arrive, a single request per ticket is fine. If you're backfilling a queue of thousands, batch them with concurrency limits rather than firing everything at once — you'll hit rate limits and burn through quota fast. Running this through SubToAPI gives you a single API key across your team, usage metadata per request so you can see exactly what classification jobs are costing, and streaming support if you want to show live progress on a backfill job. See /docs/streaming for the streaming request format and /docs/tools if you want the classifier to also call a function that files the ticket directly into your help desk.
Keeping it accurate over time
Review misclassifications weekly, especially for "other" — it's the category that silently absorbs model confusion. If "other" climbs above 10–15% of volume, your category definitions are probably too narrow or your examples in the system prompt are stale. Add two or three real ticket examples per category directly into the system prompt as few-shot examples; this consistently improves accuracy more than rewriting the instructions.
questions
Can Claude classify tickets in languages other than English? Yes. Claude handles multilingual input natively — you don't need separate prompts per language, though adding the detected language to your output schema is useful for routing to native-speaking agents.
Should I fine-tune a model instead of prompting? For most teams, no. A well-written prompt with explicit decision rules and few-shot examples gets you 90%+ accuracy without the maintenance cost of a custom model, and it's trivial to update when categories change.
How do I get started without managing API keys and rate limits myself? Sign up at /signup for a free trial, generate a sub_live_... key from the dashboard, and follow /docs/quickstart — you get streaming, usage metadata, and team seats without building that infrastructure yourself.