Email Triage with AI: Route an Inbox by What Mistakes Cost
Hands-on lab · IDE in your browser

Email Triage with AI: Route an Inbox by What Mistakes Cost

Turn a shared office inbox over to a language model without writing code: write a prompt that routes every email to the right team, flags what cannot wait until tomorrow, sends ownerless emails to a person, and fixes the most expensive mistakes first, scored by a harness that prices each mistake the way the business feels it, then confirmed on emails the prompt has never seen.

Time
45 min
Checked steps
5
Level
Beginner
Setup
None
Read step 1

Hands-on labs require Pro · $29.99/mo · cancel anytime

Lab cockpit45 min · 5 stepsSession running
1 / 5 steps passingFlag what cannot wait · step 2 of 5
prompt.md▶ Run✓ Check
URGENT: <yes or no> Teams:- finance: supplier invoices and payment questions, bank and tax letters- people: job applications, staff sickness, holidays, pay, anything about working here- press: journalists, radio, podcasts, bloggers and reviewers- customer_care: customer orders, deliveries, refunds, complaints and feedback, newsletters- events: author events, signings, readings, book club, venue hire- spam: sales pitches nobody asked for, phishing, scams      
TerminalOutput

The job

Brightline Books' head office has one inbox for everything: supplier invoices, job applications, journalists, customer complaints, event bookings and spam. Someone spends the first hour of every day forwarding emails, and last month a journalist's same-day deadline sat unread until the next morning. You write the prompt that sorts the inbox. A harness runs it on 30 real-looking emails and adds up what each mistake would cost: a missed urgent email counts five times a misrouted one, and asking a person costs half.

5 steps, each checked when you finish it

A check runs your work at the end of every step. Hints and the full solution are there if you get stuck.

  1. 1

    Route every email to a team

    Brightline's head office inbox gets supplier invoices, job applications, journalists, customer complaints, event bookings and a steady stream of spam, all in one place.

  2. 2

    Flag what cannot wait

    Look at the costs from Step 1.

  3. 3

    Know when to ask a person

    Some emails belong to no team: water through the ceiling, a staff member who fell for a phishing email, a contract that is half events, half finance.

  4. 4

    Fix the expensive mistakes first

    Rules cover the general case.

  5. 5

    The held-out test and the monthly bill

    You tuned the prompt on the same 30 emails you scored it on, so part of the improvement is fitted to those emails.

Step 1 as it appears in the lab

The lab’s own text. The hint and the solution stay inside the lab.

Step 1: Route every email to a team

Brightline's head office inbox gets supplier invoices, job applications, journalists, customer complaints, event bookings and a steady stream of spam, all in one place. Someone spends the first hour of every day forwarding emails. You are going to hand that job to a language model, and you will do it without writing code: you write the instructions in prompt.md, and a test harness runs them on 30 real-looking emails whose right answers are known.

prompt.md has two parts, split by the line ---EMAIL---: your instructions above it, and below it the template each email is dropped into ({subject} and {body}). Text between <!-- and --> is a note for you and is never sent.

The harness does not count right answers. It adds up what the mistakes cost the business, roughly in minutes of someone's time:

MistakeCost
a reply the harness cannot read5
an urgent email marked not urgent5
an email sent to the wrong team1
a false alarm (marked urgent, is not)1
sent to a person to decide (triage)0.5
Do this

1. Click Run with the starting prompt. Every reply is a friendly paragraph that no program can read, so the cost is at its maximum.

2. Replace the TODO with the reply format (exactly two lines, TEAM: <team> and URGENT: <yes or no>, and nothing else) and the six teams, each with a short description of what it handles. Open teams.md: the office manager already wrote them down.

3. Run again, and read the list: the most expensive mistakes come first.

prompt.md, the file you edit8 lines
<!-- Notes between these arrows are for you; the harness removes them before sending. -->
You sort emails that arrive at Brightline Books' head office.
<!-- TODO (Step 1): say exactly what to reply (two lines: TEAM and URGENT) and list the six teams
     with a short description of what each one handles. teams.md has the descriptions. -->
Which team should handle this email?
---EMAIL---
Subject: {subject}
{body}
Provided for you:emails.jsonlholdout.jsonlrun_tests.pyteams.mdtriage.py

Frequently asked questions

Do I need to code to follow this lab?

No. You edit prompt.md, a plain text file, and click Run. A harness sends your prompt and each email to a hosted model, reads the answers and prints a scorecard.

Why score mistakes by cost instead of accuracy?

Because they are not equally bad. Missing an urgent email is weighted five times a wrong team, and sending an email to a person is cheaper than a wrong team but not free. Optimising that cost pushes the prompt toward what the business actually needs.

What is the triage option for?

It lets the model hand an email to a person when no team clearly owns it, instead of guessing. It is priced at half a wrong team, so the prompt uses it for ownerless emails and not as an escape for easy ones.

What does it cost to run?

The harness prices every call from its token counts. With a small open model, sorting 80 emails a day costs cents a month; the lab prints the estimate for your own prompt.

Automating an inbox with a language model, measured by cost

Email triage is one of the most common first automations with AI: read each email, decide who handles it and whether it is urgent. It is easy to make work on a few examples and easy to get wrong in ways that matter, because mistakes are not equal. A newsletter in the wrong folder costs seconds; a missed legal deadline costs far more. In this lab you build a triage prompt without code and measure it on a labelled test set with a cost-weighted score. You define an output format a program can read, describe each team, write an urgency rule based on time rather than tone, add a human-review option priced so it is used only when needed, aim few-shot examples at the costliest mistakes, and confirm the result on held-out emails along with the monthly model cost.