Skip to the experiment
Jev Guide

Choice

Route a message.

A support inbox gets messages about billing, logins, bugs, pricing, and everything in between. A Choice question asks Jev to pick one department from a fixed set, and returns a probability for every option so your code can see how close the call was, not just the winner.

Choice

Route a message

Live testing off
Sample
Customer message

Read-only while live testing is unavailable.

Run
Live testing is currently unavailable on this deployment.
Output

Chosen: billing

Charges, invoices, refunds, payment methods, subscription costs

  1. billing91.0%
  2. account3.0%
  3. other3.0%
  4. technical2.0%
  5. sales1.0%

Jev put 91.0% on billing, with account next at 3.0%. Probabilities describe the distribution over the options, not a guarantee that the choice is correct. Confidence: 0.86.

Illustrative example

Not a live or recorded response — shown to illustrate the shape of an answer.

Build this

message-routing.ts
import { choice, TypeSafeClient } from "@typesafe-ai/sdk";
 
const client = new TypeSafeClient(); // reads TYPESAFE_API_KEY, defaults to jev-latest
 
const message = "Hi, I was charged twice for my subscription this month. The two charges show up on my card statement on the 3rd and the 4th. Can you refund one of them?";
 
const { answers } = await client.systemOne({
state: message,
model: "jev-latest",
questions: {
department: choice(
"Which department should handle this customer message?",
{
billing: "Charges, invoices, refunds, payment methods, subscription costs",
account: "Login, password, profile, permissions, closing or changing an account",
technical: "Bugs, errors, outages, integrations, something not working",
sales: "Pricing questions, plan comparisons, upgrades, purchasing for a team",
other: "Anything that does not fit the departments above",
},
),
},
});
 
const { choice: result, probabilities, confidence } = answers.department;
 
// Your code decides what to do with the answer.
if (confidence < 0.5) {
console.log("Unsure. Route to a person.", probabilities);
} else {
console.log("Route to " + result + " (confidence " + confidence.toFixed(2) + ")");
}

Type-checked against @typesafe-ai/sdk 0.6.0 as part of this site's build. Not executed against the live API by this guide.

npm install @typesafe-ai/sdk — requires Node.js 20+. Set TYPESAFE_API_KEY in your environment.

Keep TYPESAFE_API_KEY on the server. Never embed it in client code or ship it in a browser bundle.

Reading the result

The department with the highest probability is Jev's answer, shown as choice. When two departments are close — as in the ambiguous “Upgrade won't charge” sample above, which touches both sales and technical — probabilities typically split and confidence drops; the illustrative value shown for that sample here is a hand-authored example of that pattern, not a measured Jev response. Treat a flat, low-confidence distribution as a signal to ask a person rather than route automatically; see Confidence for how that number is derived.

This recipe reuses the exact department definitions, question, and model alias from the live demo on the Jev Guide homepage, so the same input is asked the same way in both places. Individual answers can still vary between calls, and jev-latest moves to a newer release over time.