# Routing support requests

A practical workflow: classify a request, check confidence and retain a manual route.

Source: https://shvydko.ai/en/docs/patterns/routing

## Decide before acting

Imagine a support service that routes technical failures to engineering, payments to finance and delivery issues to logistics. Shvydko returns a category; your application decides whether there is enough information to route automatically.

Use the team question from the quickstart. Add examples mentioning both payment and delivery to test the rule for identifying the main reason for contact.

- [Example context and criteria](https://shvydko.ai/en/docs/quickstart#request)

## Define a safe function result

reviewed_threshold is a threshold you have validated, not a universal constant. Start by collecting suggested routes and comparing them with agents' decisions. Enable automatic execution only after evaluation.

### Python · no external actions

```python
def decide_route(result, reviewed_threshold):
    answer = result["answers"]["team"]
    choice = answer.get("choice")
    confidence = answer.get("confidence")
    allowed = {"engineering", "finance", "logistics"}

    if (
        choice not in allowed
        or not isinstance(confidence, (int, float))
        or confidence < reviewed_threshold
    ):
        return {"route": "manual_review", "request_id": result["request_id"]}

    return {"route": choice, "request_id": result["request_id"]}

# Pass a threshold selected on your own labelled calibration data.
# This function chooses a route; it does not create a ticket or send a message.
```

## When to add a second question

You can add an independent urgency assessment as a Score question in the same request, or check whether a necessary fact is present with Noul. If the second decision depends on the selected category, create a separate request after receiving the first response.

Keep your own ticket ID and the request_id. Before taking an external action, check whether it has already been performed for that ticket: your application must ensure the business operation is idempotent.

## What to monitor after launch

- The share of cases requiring manual review and errors in each category.
- New inquiry topics that do not fit an existing category.
- Latency, HTTP errors and costs by request volume.
- Changes in results after editing criteria or updating the model.

- [Check Usage](https://shvydko.ai/en/console/usage)
- [Evaluation plan](https://shvydko.ai/en/docs/evaluation)

## Related documentation

- [Choice](https://shvydko.ai/en/docs-markdown/primitives/choice.md)
- [Decision confidence](https://shvydko.ai/en/docs-markdown/confidence.md)
- [How to evaluate the model](https://shvydko.ai/en/docs-markdown/evaluation.md)
- [Python over HTTP](https://shvydko.ai/en/docs-markdown/integrations/python.md)
