# Jev support handoff teaching example

This is a synthetic teaching dataset, not a customer case study or a validated support policy.

1. Install Node.js 22 or newer. Save `run.mjs`, `workflow.mjs` and `cases.mjs` together.
2. Run `node run.mjs`. This makes **zero API calls** and creates `preview.json`.
3. Create a local `.env.local` containing `TYPESAFE_API_KEY=your_key`. Exclude `.env*` from Git. Never use a browser environment variable for a secret.
4. Run `node --env-file=.env.local run.mjs --live`. This makes at most **six requests**, stopping on the first error. Your TypeSafe account is billed directly. The script does not use the website's free quota.
5. Open `results.json`. Compare `expected` with `action`; inspect `score`, `request`, `response`, `testedAt` and the actual returned model. Reruns may differ.

Known-rule cases do not need the model. `humanRequested`, `alreadyEscalated` and `insufficientContext` are human annotations / trusted application facts, not fields to infer using a keyword search. Known rules take priority in that order: existing queue, confirmed human request, insufficient context.

Default example thresholds: below 0.35 continue, 0.35 to below 0.75 clarify/review, at least 0.75 hand off. These are illustrative. Validate your thresholds on representative labeled data. Missing or invalid scores go to review, never silently to continued automation. No actual ticket, queue or customer message is changed by this script.

If authentication fails, check the environment variable and provider account. On timeout or service failure, review the case; do not blindly retry because a failed request can still cost money. The script records only an HTTP status or generic error, not the provider's raw error body.

To add cases, extend `cases.mjs` and write your expected outcomes **before** running the model. The website's recorded results refer only to its published fixtures and policy version. Keep a separate results file when you modify either.

References: https://docs.typesafe.ai/api and https://docs.typesafe.ai/primitives/noul
