JEV FOR INBOX ROUTING

Jev Email Triage

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.

LIVE WORKFLOWSimulated inbox · Real Jev decisions

No account connection, mock result, or automatic side effect. The button calls the same live model as the main Playground.

01 / LIVE INBOX

Turn five unsorted messages into work queues

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.

No email account connected. Sample inbox only.
Inbox presetSwitching a preset does not call Jev.
Five editable simulated emails
INBOX · 5 MESSAGES

One click · one shared state · exactly five Choice questions

ROUTED WORKTypeSafe Jev
Run Jev to organize the inbox.

Your routed inbox will appear here.

Run the Customer Support inbox without editing to see real Jev decisions.

02 / FROM INBOX TO QUEUES

Jev decides. Application software acts.

Incoming emailSimulated message
Jev chooses a queueBounded Choice
ProbabilityReturned distribution, when available
Application thresholdLocal demo policy
Auto Route or Manual ReviewApplication placement

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.

POSSIBLE DOWNSTREAM WORK

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.

THIS DEMO’S BOUNDARY

No side effects

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

Uncertainty becomes visible work

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.

AUTO ROUTE

Selected probability meets policy

The email appears under its chosen operational queue. This is still a model estimate, not guaranteed correctness.

MANUAL REVIEW

Uncertain is a valid destination

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

Shared definitions, independent decisions

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

Public Jev projects use the same classification shape

MOCKED EMAIL ROUTING

typesafe-jev-workflow

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 ↗
BATCH CLASSIFICATION

jev-mcp · jev_classify

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

One State, five Choice questions, local policy

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.

email-triage.ts
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

A routing simulator, not an email service

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

Workflow checked against working references

Verified on .

Jev Playground is independent and is not affiliated with TypeSafe AI or the referenced community projects.

KEEP LEARNING

Understand the model, then inspect another complete workflow.

Jev Playground Jev Browser Agent