Build a Claude API Support Ticket Summarizer Tool
If your support queue has tickets with 40-message threads, agents waste minutes just scrolling before they can respond. A Claude API support ticket summarizer tool solves this by condensing a full ticket history into a short brief: what the customer wants, what's been tried, and what needs to happen next. This article walks through building one, from prompt design to structured output you can drop straight into a helpdesk UI.
The core idea is simple: send the ticket thread (customer messages, agent replies, internal notes) to Claude with a prompt that asks for a specific summary format, then parse the response into fields your support tool can display — summary, sentiment, priority, suggested next action. Done right, this cuts triage time significantly and gives new agents instant context when a ticket gets reassigned.
Why summarize tickets with an LLM instead of rules
Keyword-based or regex summarizers break down fast because support conversations are messy — customers restate the same issue three different ways, agents ask clarifying questions, and the actual resolution might be buried in message 27. An LLM like Claude can read the whole thread and reason about what actually matters, which is why this is a better fit than traditional NLP pipelines for this specific task.
Designing the ticket summary prompt
The prompt needs to be explicit about format so you get consistent output across thousands of tickets. A loose "summarize this" prompt will give you inconsistent paragraph lengths and tone. Instead, ask for structured fields:
You are summarizing a customer support ticket thread for an agent who has not read it yet.
Return your answer in this exact format:
Summary: <2-3 sentence plain-language summary of the issue>
Customer sentiment: <frustrated | neutral | satisfied>
Status: <unresolved | waiting on customer | resolved>
Key facts: <bullet list of concrete details — order IDs, error messages, dates>
Suggested next action: <one sentence>
Thread:
{{ticket_thread}}
Keep the thread formatting consistent when you build it — label each message with sender and timestamp so Claude can track the chronology correctly, especially for threads where the issue changed partway through.
Calling the API
If you're building this with direct Claude API access, you'd call the messages endpoint and parse the structured text back out. Here's the same pattern using SubToAPI, which gives you an HTTPS endpoint with the same request shape, plus usage metadata per call so you can track summarization cost per ticket:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 400,
"messages": [
{
"role": "user",
"content": "You are summarizing a customer support ticket thread... [prompt as above]"
}
]
}'
In JavaScript, wire this into your helpdesk webhook so a summary gets generated the moment a ticket crosses a message-count threshold:
async function summarizeTicket(ticketThread) {
const res = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4",
max_tokens: 400,
messages: [
{
role: "user",
content: buildSummaryPrompt(ticketThread),
},
],
}),
});
const data = await res.json();
return parseSummaryFields(data.content[0].text);
}
If you'd rather get machine-readable JSON directly instead of parsing labeled text, define a tool/function schema with fields like summary, sentiment, status, and next_action, and have Claude call it instead of writing free text. Check /docs/tools for the request format — this is the more robust approach once you're past a prototype, since it removes parsing errors entirely.
Parsing and storing output
Even with a structured prompt, text output needs a small parser before you store it:
function parseSummaryFields(text) {
const fields = {};
const lines = text.split("\n");
for (const line of lines) {
const [key, ...rest] = line.split(":");
if (key && rest.length) {
fields[key.trim().toLowerCase().replace(/\s+/g, "_")] = rest.join(":").trim();
}
}
return fields;
}
This is good enough for a first version. Once you're relying on this in production, switch to the tool-calling schema mentioned above — it's worth the extra setup time.
Deciding when to trigger summarization
Running a summary on every single message is wasteful and adds latency agents don't need. Common trigger points:
- On ticket reassignment — a new agent needs context immediately.
- After N messages — e.g., once a thread passes 10 messages, auto-summarize.
- On ticket reopen — old context plus new complaint needs re-summarizing.
- Nightly batch — for tickets that sat idle, so the next morning's queue has fresh summaries.
Triggering on reassignment and reopen gives you the best cost-to-value ratio, since those are the moments where a human actually benefits from the summary existing.
Handling long threads and context limits
Support threads can get long — attachments, forwarded emails, copy-pasted logs. Strip out boilerplate (email signatures, "sent from my iPhone", quoted-reply chrome) before sending the thread to Claude. This keeps your token usage down and stops the model from treating signature blocks as part of the conversation. For very long threads, summarize in chunks of the oldest messages first, then feed that rolling summary plus the newest messages back in as the next summarization call — the same approach used for context-limited long documents.
Streaming for live agent tooling
If you're surfacing the summary inside a live agent dashboard rather than pre-generating it, streaming the response token-by-token makes the UI feel responsive instead of showing a spinner for several seconds. SubToAPI supports streaming on the same endpoint — see /docs/streaming for the event format if you want the summary to appear incrementally as the agent opens the ticket.
Getting started
To prototype this quickly: sign up at /signup for a free trial, grab an application key from the dashboard, and follow /docs/quickstart to make your first request. The /docs/messages reference covers the full request/response shape you'll need for the summarizer prompt above. Pricing starts at Solo for €9/month if you're running this as a side project, with Team and Scale plans for shared usage across a support org — see /pricing for details.
Questions
Does Claude need the full ticket history every time, or can I cache a summary? Cache the summary and only re-summarize when new messages are added since the last run. Re-running on the full thread every time wastes tokens and adds unnecessary latency for threads that haven't changed.
How do I stop Claude from hallucinating ticket details like order numbers? Instruct the model explicitly to only include facts present in the thread and to write "not mentioned" rather than guessing. Pairing this with a tool-calling schema for structured fields also reduces drift compared to free-text summaries.
Can this work for non-English support tickets? Yes — Claude handles multilingual input well, so you can either summarize in the original language or ask it to summarize in English regardless of the ticket's language, depending on what your agents read.