Routing
Route a support request
Send each message to the right handler, with an explicit fallback.
01 The question
Which support team should handle this message? Choose other when the request does not fit a listed team.
- billing
- Charges, invoices, payments, and refunds.
- technical
- Errors, outages, login problems, and integrations.
- sales
- Pricing, plans, demos, and procurement.
- other
- Unclear, unrelated, or not covered by these teams.
Copy includes the complete instructions, criteria, usage notes, and attribution.
02 Input
A single customer message. Add account or product context only when it helps classification.
{
"message": "I was billed twice for my September subscription. Can you check?"
}03 Answer & policy
A team label, probabilities for all options, and confidence in the selected label.
Your code decides what happens next.
The demo sends uncertain and other results to human review. The 0.7 threshold is illustrative; choose it using representative labeled requests.
04 Use it in your code
Node.js 24 · TypeSafe SDK 0.6.0 · Set TYPESAFE_API_KEY in your environment. Run on your server; API calls incur provider charges.
import { choice, TypeSafeClient, type JsonValue } from "@typesafe-ai/sdk";
// Illustrative input, not a recorded model test.
const state: JsonValue = {
"message": "I was billed twice for my September subscription. Can you check?"
};
const client = new TypeSafeClient();
try {
const response = await client.systemOne({
model: "jev-latest",
state,
questions: {
intent: choice(
"Which support team should handle this message? Choose other when the request does not fit a listed team.",
{
"billing": "Charges, invoices, payments, and refunds.",
"technical": "Errors, outages, login problems, and integrations.",
"sales": "Pricing, plans, demos, and procurement.",
"other": "Unclear, unrelated, or not covered by these teams."
}
)
},
});
const answer = response.answers.intent;
const handler = answer.choice === "other" || answer.confidence < 0.7
? "human_review"
: answer.choice;
console.log({ handler });
} catch (error) {
console.error("Decision unavailable; use your fallback or human review.", error);
process.exitCode = 1;
}The wrapper and example input are provided by Jev Directory. Checked against SDK types; no live model call was made. Pin a model version before evaluating production behavior.
Before you adapt it
- Include an out-of-scope choice so unrelated requests are not forced into a team.
- Confidence is a routing signal, not proof that the selected team is correct.
More about the original project or pattern
What it does
Intent routing classifies a request into a bounded set of destinations and lets application code call the appropriate handler. A destination may be deterministic logic, a specialist language model, a human queue, or an explicit no-match path.
What you can reuse
Reuse the architecture rather than a single prompt: define mutually legible destinations, include a safe unclear option, ask one narrow Choice question, and keep handler selection in code. This makes the available actions inspectable and lets every route carry its own risk policy.
How it fits
The incoming request is the state. Jev returns a typed choice with probabilities and confidence. A switch or routing table maps that answer to a handler, while low-confidence and unknown cases take an explicit fallback.
Setup and compatibility
The source is an official TypeSafe architectural pattern. Follow the current SDK quick start linked from the documentation rather than copying version-sensitive setup from this directory.
Limitations
A Choice question must return one of its available options, so an unclear or none option matters when requests may fall outside the taxonomy. Routing quality still depends on representative testing, unambiguous criteria, and a sensible fallback. This entry reports the vendor’s recommended pattern, not an independent benchmark.
Sources
Primary source: TypeSafe intent routing.