Skip to content
Optimal Lab

AI Automation · interactive

Classify, then route

An LLM step reads each support email and labels it; the workflow then sends it to the billing, bug, sales or general queue. The routing is a plain switch on the label, so the label's exact form matters.

prompt: "What category is this email?"
  • Charged twice this month"Billing issue" → no route
  • Export button does nothing"bug" → bug
  • Pricing for 200 seats?"Sales / pricing inquiry" → no route
  • Invoice shows wrong VAT number"billing" → billing
  • App crashes on login (iOS)"Technical problem - Bug" → no route
  • Love the product!"Feedback" → no route
  • Can I get a refund?"Refund request" → no route
  • Partnership idea"sales" → sales

billing

1

bug

1

sales

1

other

0

dead letter

5

The model's labels are sensible to a human (“Billing issue”, “Refund request”) but don't exactly match any branch. 5 of 8 emails fall through.

Classifier output

Step 3 of 4

  1. 1

    Ask for a choice, not prose

    List the exact labels, with a one-line definition and an example for each.

    Ambiguous categories confuse people too.

  2. 2

    Use structured output

    A JSON schema with an enum makes invalid labels impossible, not just unlikely.

    { enum: ["billing", "bug", "sales", "other"] }

  3. 3

    Give the unknown somewhere to go

    An “other” label and a default branch, so nothing silently disappears.

    Alert if “other” grows.

  4. 4

    Sample and review

    Check a handful of routed items weekly, add misrouted ones to your test set, and add a confidence threshold for a human queue.

    See confidence thresholds.

In production

Tools and technologies

Workflow tools pair an LLM step with a switch node.

Not tied to one language — use these names when you search docs or design a system.