j.jevmanual.
ExampleChecked 2026-09-21·jev-1.13.0

Build a Support Ticket Router with Jev

Route a ticket, prioritize urgency, and flag refund requests while keeping payment actions outside the classifier.

Beginner30 minutesPython 3.10+Choice · Score · Noul
On this pageWhat you’ll buildArchitecturePrerequisites and sample inputStep 1 — Prepare the evidenceStep 2 — Define the atomic questionsStep 3 — Read answers and apply a gateStep 4 — Keep execution separateRun itExpected fixture resultRead the probabilitiesFailure cases and production improvementsComplete codeWhat to test before shipping

What you’ll build

Route a ticket, prioritize urgency, and flag refund requests while keeping payment actions outside the classifier. The result is a runnable decision pipeline, with a fixture mode for checking local behavior and a live mode for evaluating your own TypeSafe account. It prints a recommendation without performing external side effects.

Architecture

Ticket → one shared-state request → department / urgency / refund / churn → queue recommendation

A ticket can belong to billing without being urgent, and can request a refund without threatening cancellation. Four separate questions preserve those distinctions. The application adds flags; a payment service independently verifies transactions and eligibility.

Ticket → one shared-state request → department / urgency / refund / churn → queue recommendation

Prerequisites and sample input

Use Python 3.10+; these standalone examples use only the standard library. Live evaluation also requires TYPESAFE_API_KEY in the environment. Download the complete script below rather than copying disconnected fragments.

{
  "ticket": {
    "subject": "Duplicate subscription charge",
    "message": "I was charged twice this month. Please refund the duplicate before Friday."
  },
  "customer_plan": "pro"
}

Step 1 — Prepare the evidence

Keep the input shape stable and distinguish verified application facts from user claims. A ticket can belong to billing without being urgent, and can request a refund without threatening cancellation. Four separate questions preserve those distinctions. The application adds flags; a payment service independently verifies transactions and eligibility.

Step 2 — Define the atomic questions

{
  "department": {
    "type": "choice",
    "instructions": "Which team should handle this ticket?",
    "criteria": {
      "billing": "Payments and refunds",
      "technical": "Bugs and outages",
      "sales": "New purchases",
      "other": "No listed category fits"
    }
  },
  "urgency": {
    "type": "score",
    "instructions": "How urgent is the request?",
    "criteria": [
      "No deadline",
      "This week",
      "Within one day",
      "Immediate harm"
    ]
  },
  "refund_requested": {
    "type": "noul",
    "instructions": "Does the customer explicitly request a refund?"
  },
  "churn_risk": {
    "type": "noul",
    "instructions": "Does the customer explicitly threaten cancellation?"
  }
}

The question names map outputs back to your code. They are not inference instructions. Put the actual judgment in instructions, and use criteria for category descriptions or ordered levels.

Step 3 — Read answers and apply a gate

The standalone script checks required answer keys, types, allowed categories, numeric ranges, and confidence. Missing or malformed data stops the decision path. The following action policy uses educational thresholds; none have been measured on your data.

def decide(answers, state):
    department = answers["department"]
    queue = department["choice"] if department["confidence"] >= .85 else "manual_review"
    return {"queue": queue,
            "priority_review": answers["urgency"]["score"] >= 2,
            "refund_workflow_flag": answers["refund_requested"]["noul"] >= .8,
            "retention_review": answers["churn_risk"]["noul"] >= .8,
            "refund_executed": False}

Step 4 — Keep execution separate

The program prints a route or candidate result. A real executor must apply its own permissions, validation, idempotency, and confirmation requirements. A model label is evidence for a decision, not authorization to perform a consequential action.

Run it

Download the complete support-ticket-triage.py program. Then run:

python support-ticket-triage.py
# After configuring TYPESAFE_API_KEY, opt in to a live billed call:
python support-ticket-triage.py --live

Fixture mode makes no network request and requires no credential. Live mode makes a single call with a 30-second timeout. It does not silently retry or execute any downstream action. For a production queue, add a bounded retry policy for transient failures and a durable review destination.

Expected fixture result

{
  "queue": "billing",
  "priority_review": false,
  "refund_workflow_flag": true,
  "retention_review": false,
  "refund_executed": false
}

This output is deterministic fixture data, not a measured Jev response. A live model may produce different values and routes. Keep the full returned probability distributions when diagnosing that difference.

Read the probabilities

A Choice winner alone does not reveal ambiguity. Compare its confidence and distribution with the selected label. A Score is an ordered semantic value; use its legend before applying numeric thresholds. A Noul is the probability of yes and has no separate confidence field.

Failure cases and production improvements

A message can quote another customer, mention a past refund, or combine a billing issue with an outage. Test those boundary cases. Never infer refund eligibility from a request to be refunded.

Pin the tested model, log the returned version and rubric revision, and keep a small evaluation set under version control. Re-test after changes to inputs, provider, questions, or policy. Avoid logging sensitive input by default.

Complete code

The downloadable standalone script includes request construction, fixture data, response validation, the decision function, and command-line execution. It uses the direct HTTP API so no SDK dependency is required. For SDK versions of the core ticket request, see Python and JavaScript.

What to test before shipping

  • A routine duplicate-charge ticket routes to billing.
  • A department confidence below .85 routes to manual_review.
  • A refund flag never executes a payment.
  • An empty message fails review rather than generating a fabricated category.
  • Network failures, invalid JSON, and missing fields must never become an automatic action.
  • Compare several thresholds on labeled data and record the resulting review volume.
Search the manual