Skip to content

DocsExamples

4 min read · updated

Support routing

Send each support ticket to the right queue from your backend, and give a person only the tickets decisio cannot stand behind.

The model names the queue, and your code routes only on a certified answer:

Figure · How to use it

The model judges the input; your code chooses the action.

  1. InputA support ticket
  2. QuestionWhich support queue should handle this ticket?
  3. Typed answerA queue key and probabilities
  4. Your codeRoute a certified answer; send the rest to review.

The answer is under answers.queue. Check the certificate required by your application before automating the action.

Source: this recipe’s question and application policy. No model result is illustrated here.

Save the complete caller as support-routing.py and run it with Python 3.12 or later. Set DECISIO_BASE_URL to your server, or leave the local default. Until you register and certify this question, the caller sends answers to review.

python
import json
import os
import urllib.error
import urllib.request
QUESTION = {
"type": "choice",
"instructions": "Which support queue should handle this ticket?",
"criteria": {
"billing": "Invoices, charges, refunds",
"access": "Login, passwords, permissions",
"bug": "The product behaves wrongly",
"shipping": "Orders and deliveries",
"other": "Anything else"
}
}
BASE_URL = os.environ.get("DECISIO_BASE_URL", "http://127.0.0.1:8000").rstrip("/")
TIMEOUT = 15
REVIEW = "to a person"
def route(text):
request = urllib.request.Request(
BASE_URL + "/v1/systemone",
data=json.dumps({"state": text, "questions": {"queue": QUESTION}}).encode(),
headers={"Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(request, timeout=TIMEOUT) as response:
answer = json.load(response)["answers"]["queue"]
if not isinstance(answer, dict) or answer.get("type") != QUESTION["type"]:
return REVIEW
if not (answer.get("choice") in QUESTION["criteria"]):
return REVIEW
# A gold certificate is about correctness; agreement alone is insufficient.
if (answer.get("certified") is True
and answer.get("certificate_kind") == "gold"
and isinstance(answer.get("certificate"), str)
and answer["certificate"]):
return f"send to {answer['choice']}"
return f"to a person, {answer['choice']} suggested"
except (urllib.error.URLError, TimeoutError, OSError, ValueError, KeyError, TypeError):
return REVIEW
if __name__ == "__main__":
print(route("My card was charged twice this month. Please refund one of the charges."))
Output
to a person, billing suggested

Good fit

  • A fixed list of queues your team already routes to.
  • Past tickets with the queue a person chose, to teach and certify from.
  • A person or a queue for what is left over.

Not a good fit

  • Queues that change every week: each change makes a new task to teach.
  • No labelled tickets to teach and certify from.

One choice question, with a description for each queue and an other queue, so a ticket that fits none of them is not forced into one.

Teach the question from past tickets and ask for a certificate at your error target, here 5%.

Send at least 118 labelled tickets. The server holds back half to certify, and a 5% certificate needs 59 of those. More examples certify a larger share.

Prepare support-routing-labels.jsonl with one JSON object per line, containing state and answer. Use real inputs and labels chosen by a person; each answer is one of the question’s option keys. The code below builds complete requests using the same question as the caller.

python
import json
import os
import urllib.request
QUESTION = {
"type": "choice",
"instructions": "Which support queue should handle this ticket?",
"criteria": {
"billing": "Invoices, charges, refunds",
"access": "Login, passwords, permissions",
"bug": "The product behaves wrongly",
"shipping": "Orders and deliveries",
"other": "Anything else"
}
}
# One JSON object per line: state and the answer chosen by a person.
with open("support-routing-labels.jsonl", encoding="utf-8") as source:
rows = [json.loads(line) for line in source if line.strip()]
examples = [
{"request": {"state": row["state"], "questions": {"queue": QUESTION}},
"answer": row["answer"]}
for row in rows
]
body = {"id": "support-routing", "examples": examples, "certify": {"alpha": 0.05}}
base_url = os.environ.get("DECISIO_BASE_URL", "http://127.0.0.1:8000").rstrip("/")
request = urllib.request.Request(
base_url + "/v1/tasks", data=json.dumps(body).encode(),
headers={"Content-Type": "application/json"},
)
# Registration reads all your examples; allow more time than an ordinary decision.
with urllib.request.urlopen(request, timeout=300) as response:
record = json.load(response)
print(json.dumps(record.get("certificate"), indent=2))

Needs the reader’s own human-labelled JSONL file.

Save the registration script beside the labels file and run it with Python. Registration replaces a task of the same id. Check the returned certificate: a null threshold means no answer can be certified.

Certify answers runs this call on a server, with its answer.

The caller acts only when certified is true and certificate_kind is gold, with a certificate id. A learned table’s agreement certificate measures agreement with the model, so it goes to review in this recipe.

  • A certified answer goes to its queue on its own.
  • Everything else goes to a person, with decisio’s suggestion beside it.
  • When traffic moves away from the tickets you certified on, certification is suspended, so the shift goes to people instead of into the wrong queues (Watch for drift).
  • 43.3% of a support inbox's messages answered on their own at a 5% error target, 3.2% of them wrong: BANKING77's 77 intents, Gemma 4 31B taught with 10 examples per intent, 3,080 test messages.
  • 97.0% of 400 held-out tickets routed right over 20 queues by Gemma 4 31B with the plain question, and 97.2% after teaching it from 200 labelled tickets: decisio's triage demo.

The inbox: measured on decisio 0.14.0, one RTX PRO 6000 Blackwell, 2026-10-16.

The triage demo: measured on decisio v0.6.0, one RTX PRO 6000, 2026-10-05.