Route a support ticket
Open in playground →Pick a queue and an urgency, each with a probability for every option, so low-confidence tickets can go to a person.
Challenges
- Routing needs more than a label. To send unsure tickets to a person, you need to know how sure the model is, so every option comes back with a probability.
- The queue must be one of your four names exactly, never
Billing teamor a category you did not list. - The refund is implied, not asked for in so many words: the customer wants "the second charge back".
import os
from typellm import TypeLLMClient
client = TypeLLMClient(api_key=os.environ["TYPELLM_API_KEY"])
response = client.generate(
context="Subject: Charged twice this month\n\nHi, I upgraded to the Pro plan on the 3rd and my card was charged twice, $49 each time. I can't find a way to get the second charge back in the billing page. Please help, this is my company card.",
questions={
"queue": {
"type": "string",
"enum": [
"billing",
"technical",
"account",
"sales"
],
"instructions": "Which team should handle this ticket?",
"return_probabilities": True
},
"urgency": {
"type": "string",
"enum": [
"low",
"medium",
"high"
],
"instructions": "How urgent is it?",
"return_probabilities": True
},
"wants_refund": {
"type": "boolean",
"instructions": "Is the customer asking for money back?",
"return_probabilities": True
},
"summary": {
"type": "string",
"instructions": "Summarise the problem in one short sentence."
}
},
)
print(response)Generation(
result={
'queue': {
'value': 'billing',
'probabilities': {
'billing': 1,
'technical': 0,
'account': 0,
'sales': 0,
},
},
'urgency': {
'value': 'high',
'probabilities': {
'low': 0.011,
'medium': 0.075,
'high': 0.914,
},
},
'wants_refund': {
'value': True,
'probabilities': {
'true': 0.998,
'false': 0.002,
},
},
'summary': 'Customer was double-charged $49 for a Pro plan upgrade and cannot locate a refund option in the billing page.',
},
thinking={},
usage=Usage(input_tokens=195, thinking_tokens=0),
)