We are going to build a customer support triage agent that reads unstructured tickets, classifies urgency, and drafts replies. A traditional ML pipeline would need a trained classifier, a sentiment model, and hardcoded response templates. With an LLM on Oxlo.ai, we get classification, reasoning, and natural language generation from a single API call.
What you'll need
- Python 3.10 or newer
- The OpenAI SDK:
pip install openai - An Oxlo.ai API key from https://portal.oxlo.ai
Step 1: Initialize the Oxlo.ai client
The client is a drop-in replacement for the OpenAI SDK. We point it at Oxlo.ai and pass your key.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
Step 2: Define the agent system prompt
This single prompt replaces what would traditionally be three separate systems: a classifier, a sentiment analyzer, and a template engine. Edit the categories or tone to match your product.
SYSTEM_PROMPT = """You are a support triage agent. Read the customer ticket and return valid JSON with exactly these keys:
- urgency: one of low, medium, high
- category: one of billing, technical, account
- summary: one sentence describing the core issue
- suggested_reply: a concise, empathetic response that addresses the specific problem and offers a concrete next step.
If details are missing, infer from context. Do not output text outside the JSON object."""
Step 3: Ingest a raw ticket
In production this might come from a webhook or mailbox. Here we will use a plain multiline string to simulate an incoming ticket.
raw_ticket = """
Subject: Double charged this month
Body: Hi, I noticed two charges on my card for the Pro plan. I only have one account. Can you fix this ASAP? I also need the invoice for accounting.
"""
Step 4: Classify and draft in one shot
Traditional ML would require feature engineering and a labeled dataset to reach this point. The LLM generalizes from instructions, so we get structured output without retraining. We use JSON mode to keep the response machine readable.
import json
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": raw_ticket},
],
response_format={"type": "json_object"},
temperature=0.2,
)
result = json.loads(response.choices[0].message.content)
print(json.dumps(result, indent=2))
Step 5: Add lightweight validation
LLMs are flexible, but production code should still verify the shape of the output. A short guard function prevents malformed replies from reaching your users.
def validate(result: dict) -> dict:
assert result.get("urgency") in {"low", "medium", "high"}, "bad urgency"
assert result.get("category") in {"billing", "technical", "account"}, "bad category"
assert result.get("suggested_reply"), "missing reply"
return result
validated = validate(result)
Step 6: Package the agent
Now we wrap the call and validation into a single function. Because Oxlo.ai uses flat per-request pricing, long tickets with full conversation history do not inflate your cost the way token-based providers would.
def triage(ticket_text: str) -> dict:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": ticket_text},
],
response_format={"type": "json_object"},
temperature=0.2,
)
data = json.loads(response.choices[0].message.content)
return validate(data)
Run it
Test the agent with a technical emergency ticket. The model infers urgency from phrases like "demo in 20 minutes" without any explicit keyword list.
test_ticket = """
Subject: Login broken after update
Body: I updated the mobile app yesterday and now I cannot log in at all. I have a demo in 20 minutes. Please help.
"""
output = triage(test_ticket)
print(json.dumps(output, indent=2))
Expected output:
{
"urgency": "high",
"category": "technical",
"summary": "User is unable to log in after a mobile app update and has an upcoming demo.",
"suggested_reply": "I understand how critical this is with your demo coming up. I am escalating this to our mobile team immediately and will send you a direct link to the previous stable APK within the next five minutes."
}
Next steps
Swap in deepseek-v3.2 or kimi-k2.6 if you need stronger reasoning for nuanced escalations, or add function calling so the agent can query your billing system before it claims a refund has been issued. If you are handling multilingual tickets, qwen-3-32b is a strong alternative on Oxlo.ai for zero-shot cross-lingual classification.
Top comments (0)