Queues can connect to tools
Billing could become a ticket queue, Technical a support queue, Sales a CRM lead, and Spam / Archive an application-controlled archive action.
JEV FOR INBOX ROUTING
Start with five unsorted emails. One Jev evaluation classifies each message, then application policy decides which ones can be routed automatically and which need review.
No account connection, mock result, or automatic side effect. The button calls the same live model as the main Playground.
01 / LIVE INBOX
Customer Support provides clear routing examples. Ambiguous Inbox contains realistic borderline messages for testing review policy. Inspect or edit any message, then run one real Jev evaluation.
Run the Customer Support inbox without editing to see real Jev decisions.
02 / FROM INBOX TO QUEUES
If Jev returns billing, application code could create a billing ticket. If Jev returns technical at 62%, an 80% application threshold places it in Manual Review. Jev supplies the bounded judgment; your software validates it and decides what happens next.
Billing could become a ticket queue, Technical a support queue, Sales a CRM lead, and Spam / Archive an application-controlled archive action.
It does not send email, move a Gmail message, create tickets, write to a CRM, delete anything, or perform any other action.
03 / WHY PROBABILITY MATTERS
A selected queue is useful, but an application also needs a policy for confidence. This demo auto-routes only when the returned selected probability meets the adjustable threshold. A lower value or missing distribution goes to Manual Review.
The email appears under its chosen operational queue. This is still a model estimate, not guaranteed correctness.
The reviewer sees Jev’s selected queue, its probability, and the runner-up when available. Review is deliberate workflow handling, not a failed request.
04 / ONE EVALUATION, FIVE ROUTES
The queue catalog appears once in shared State alongside all five emails. Five Choice questions—one per stable email ID—ask for five separate routing judgments. One evaluation returns those bounded decisions together; the answers do not feed into one another.
This is a batching pattern, not a claim about universal cost savings. The Jev API guide explains the request and response contract, while What Is Jev? explains why typed questions differ from chat.
05 / REAL-WORLD PATTERN
The public project routes mocked emails with a Jev Choice decision. Its handlers set a demonstration destination; they do not send mail or perform payment actions.
Inspect the repository ↗The public MCP server demonstrates classifying multiple items against one shared class catalog in one call. Each result remains a bounded classification.
Inspect jev-mcp ↗Larger systems may connect this pattern to inboxes, ticketing, or downstream tools. This Jev Playground page connects to none of them.
06 / IMPLEMENTATION
This original TypeScript example mirrors the workflow: assemble a bounded queue catalog and five emails, call typesafe-ai/jev once, validate every answer, then apply an application-owned threshold. It contains no Gmail or external mail API code.
import { createGateway, experimental_evaluate as evaluate } from 'ai';
const gateway = createGateway({ apiKey: process.env.AI_GATEWAY_API_KEY });
const QUEUES = {
billing: 'Payments, invoices, refunds, and subscription billing.',
technical: 'Product faults, errors, broken features, and technical failures.',
sales: 'Pre-purchase pricing, demos, procurement, and commercial evaluation.',
account: 'Identity, ownership, access administration, and account recovery.',
general: 'Legitimate operational mail that fits no other queue.',
spam_archive: 'Scams, unsolicited promotions, bulk mail, or no-action newsletters.',
};
export async function triageInbox(emails: Array<{
id: string; from: string; subject: string; body: string;
}>) {
if (emails.length !== 5) throw new Error('This workflow requires five emails');
const state = [
'TASK',
'Route each email to exactly one operational queue.',
'',
'QUEUE DEFINITIONS',
...Object.entries(QUEUES).map(([id, definition]) => `${id}: ${definition}`),
'',
'INCOMING EMAILS',
...emails.flatMap((email) => [
'', `EMAIL ${email.id}`, `FROM: ${email.from}`,
`SUBJECT: ${email.subject}`, 'BODY:', email.body,
]),
].join('\n');
if (state.length > 8_000) throw new Error('Inbox is too large');
const questions = Object.fromEntries(emails.map((email, index) => [
`email_${index + 1}`,
{
type: 'choice' as const,
instructions: `Which work queue should email ${email.id} be routed to?`,
criteria: QUEUES,
},
]));
const result = await evaluate({
model: gateway.evaluationModel('typesafe-ai/jev'),
state,
questions,
maxRetries: 0,
abortSignal: AbortSignal.timeout(30_000),
providerOptions: { gateway: { zeroDataRetention: true } },
});
const AUTO_ROUTE_THRESHOLD = 0.8; // Application policy.
return emails.map((email, index) => {
const answer = result.answers[`email_${index + 1}`];
if (!answer || answer.type !== 'choice' || !(answer.choice in QUEUES)) {
throw new Error(`Invalid routing answer for ${email.id}`);
}
const probability = answer.probabilities?.[answer.choice];
return {
email,
queue: answer.choice,
probabilities: answer.probabilities,
status: probability !== undefined && probability >= AUTO_ROUTE_THRESHOLD
? 'AUTO_ROUTE'
: 'MANUAL_REVIEW',
};
});
}For server-side credentials, public errors, and production safeguards, continue to the Jev API guide.
07 / LIMITATIONS
Probability expresses the model’s distribution over the allowed queues. It is not guaranteed correctness. For another complete decision workflow, inspect the Jev Citation Verifier.
08 / SOURCES
Verified on .
Jev Playground is independent and is not affiliated with TypeSafe AI or the referenced community projects.
KEEP LEARNING