# Support routing

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

Source: https://opendecisio.com/docs/use-cases/support-routing/

The model names the queue, and your code routes only on a [certified answer](https://opendecisio.com/docs/glossary/#certified-answer):

 

[Figure: The model judges the input; your code chooses the action. Input: A support ticket. Question: Which support queue should handle this ticket?. Typed answer: A queue key and probabilities. Your code: Route a certified answer; send the rest to review..]

 

## TL;DR

 

Save the [complete caller](https://opendecisio.com/examples/recipes/support-routing.py) 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](https://opendecisio.com/docs/glossary/#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
```

 

## Is it a good fit?

 

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.

 

## 1 Write the question

 

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.

 

## 2 Teach it and certify it

 

Teach the question from past tickets and ask for a certificate at your [error target](https://opendecisio.com/docs/glossary/#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](https://opendecisio.com/docs/glossary/#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](https://opendecisio.com/examples/recipes/support-routing-register.py) beside the labels file and run it with Python. Registration replaces a [task](https://opendecisio.com/docs/glossary/#task) of the same id. Check the returned certificate: a `null` [threshold](https://opendecisio.com/docs/glossary/#threshold) means no answer can be certified.

 

[Certify answers](https://opendecisio.com/docs/tasks/certify/#2-teach-the-task-with-a-certificate) runs this call on a server, with its answer.

 

## 3 Route on the certificate

 

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](https://opendecisio.com/docs/tasks/drift/)).

 

## What it did

 

- **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.

 

 

## Limits

 

- An HTTP error, timeout or invalid response goes to the review path, like an uncertified answer ([Handle review and service failures](https://opendecisio.com/docs/use-cases/#handle-review-and-service-failures)).
- Keep the question and options stable after registration, and certify again after changing the task or [serving setup](https://opendecisio.com/docs/glossary/#serving-setup) ([Keep a certificate valid](https://opendecisio.com/docs/production/#keep-a-certificate-valid)).

 

## What next

 

- [Certify answers](https://opendecisio.com/docs/tasks/certify/): the promise, and the slider on this same inbox.
- [Certified answers on real tasks](https://opendecisio.com/demos/teach-and-certify/): the inbox, message by message.
- [Use cases](https://opendecisio.com/docs/use-cases/): the other recipes.
