How we run Kaizen

How we triage email with rules, AI and checks in code

Every five minutes through the working day, our operations platform sorts new email. The AI model is one step of several. Written rules go first, and checks in code decide what the model is never allowed to hide.

By Ashish Tonse 8 min read

Inbox that was automated mail
54%
New mail sorted every
5 minutes
Agreeing AI verdicts before a new rule
2

Before we automated anything, we looked at two years of our company inbox. More than half of it, 54%, was automated notifications: receipts, alerts, newsletters and account notices. The mail that mattered was in there too, and finding it took someone's attention every day.

So we built email triage into our internal operations platform. Every five minutes during the working day, it reads new mail and decides what happens to each message: archive it, mark it read and keep it, or leave it for a person.

The AI model is the smallest part of the system. What matters is the order of the steps, and which steps the model can never override. The lesson for anyone automating an inbox: decide which mistakes you could not undo, and put those decisions in code, not in a prompt.

Check the written rules before asking the AI

The system keeps a table of written rules. Each rule matches on a sender's address, a sender's domain or words in the subject line, and it puts matching mail in one of three tiers:

  • Archive: out of the inbox and marked read.
  • Keep, marked read: stays in the inbox, with no unread badge.
  • Leave alone: stays in the inbox, unread.

When more than one rule matches, the most specific one wins, and a rule for one inbox beats a rule for all of them.

Only a message that no rule covers goes to the AI model. The model reads the sender, subject and body, and returns a tier, a label, a confidence score and a one-sentence reason. Below a confidence of 0.6, nothing changes. If the call to the model fails, the message is left alone as well. The model's instructions include a plain rule: when in doubt, keep the message in front of a person, because archiving something important is far worse than leaving an extra message unread.

Each new message meets the written rules first, and the AI second Five new messages are checked in order. A receipt from a software vendor matches a written rule, so the AI is not asked and the receipt is archived. A question from a new contact matches no rule, and the AI is unsure at a confidence of 0.41, so the message is left alone in the inbox. A shipping notice matches no rule, and the AI is sure at 0.92, so it is marked read and kept in the inbox. An invoice from a contractor matches a written rule that keeps it in the inbox, unread, so the AI is not asked. A product announcement matches no rule, and the AI is sure at 0.88, so it is archived. Archived means out of the inbox and marked read. Read and kept means it stays in the inbox, marked read. Below a confidence of 0.6, the AI changes nothing. NEW MAIL 1. WRITTEN RULES 2. AI, IF NO RULE RESULT A receipt from a software vendor A question from a new contact A shipping notice An invoice from a contractor A product announcement MATCHED NOT ASKED ARCHIVED NO RULE UNSURE, 0.41 LEFT ALONE NO RULE SURE, 0.92 READ, KEPT MATCHED NOT ASKED INBOX, UNREAD NO RULE SURE, 0.88 ARCHIVED ARCHIVED: OUT OF THE INBOX, MARKED READ. READ, KEPT: STAYS IN THE INBOX, MARKED READ. BELOW 0.6 CONFIDENCE, THE AI CHANGES NOTHING.
The written rules decide first, and the AI model reads only what no rule covers. When the model is unsure, the message stays where it is.

If you are automating an inbox, start with rules. They need no model call, and anyone on the team can read them. Then tell the model which way to fail. A model that is unsure should change nothing.

Let the AI write rules only with evidence

When the model is very sure about a message, with a confidence of 0.85 or more, its verdict can become a new rule. The next message from that sender then skips the model. We put two limits on this.

First, a learned rule covers one exact sender address, never a whole domain. A large company can send automated receipts and a real person's support reply from the same domain. A rule for a whole domain is written by a person.

Second, the rule is written only when a second, separate message from the same address gets the same verdict. A single email, however it is worded, cannot write a permanent rule about itself. Someone would have to get the same result from the model twice, on two different runs.

The AI writes a rule only after two agreeing verdicts Three messages arrive from the same sender address. The AI reads the first, is sure it should be archived, and archives it, but writes no rule, because one verdict is not a pattern. The AI reads the second message and reaches the same verdict, so a rule is written: archive mail from this one address. The rule is written by the AI and covers that address only; a rule for a whole domain needs a person. The third message matches the new rule, is archived, and the AI is not asked. A fourth message comes from a different address at the same company. The rule does not apply to it, so the AI reads it on its own. One verdict on one message can be undone, while a rule applies to every later message. ONE SENDER ADDRESS, IN THE ORDER IT ARRIVED SAME COMPANY APPLIES First message AI: ARCHIVE, 0.90 ARCHIVED NO RULE YET Second message AI: ARCHIVE, 0.91 SAME VERDICT AGAIN RULE WRITTEN Third message MATCHED BY THE RULE ARCHIVED AI NOT ASKED Another address SAME DOMAIN RULE DOES NOT APPLY THE AI READS IT Rule: archive mail from this address WRITTEN BY THE AI. A WHOLE DOMAIN NEEDS A PERSON. ONE VERDICT ON ONE MESSAGE CAN BE UNDONE. A RULE APPLIES TO EVERY LATER MESSAGE.
One confident verdict archives one message. A second agreeing verdict writes a rule, and the rule covers that one address and nothing else on the domain.

One decision about one message can be undone. A rule applies to every message after it. When your AI can create lasting policy, ask it for more evidence than it needs to make a single decision.

Put the checks that matter in code

A model judges a message by its text, and text is where a personal note and a marketing email look most alike. A note from an event organizer to three named panelists can read like a promotion. So a few checks run after the verdict, in code, and they can only move a message toward a person:

  • If we have ever sent mail to the sender, the model cannot archive the message. It stays in the inbox, marked read. If that lookup fails, the sender counts as known.
  • If a message is addressed to two or more people and has none of the signs of bulk mail, such as an unsubscribe link, the model cannot archive it either.
  • If a contact at an active client sent the message, or is copied on it, it is never archived or marked read, whatever the rules or the model say.
  • Subject words such as "action required" or "please review and sign" keep a message in the inbox and flag it as urgent.

A message that one of these checks kept is never used to write a rule. The model's verdict on it was overruled, so it is not evidence about the sender.

Checks in code can only move mail toward a person Five messages that the AI or a written rule would archive, and the check in code that runs after the verdict. Mail from a past correspondent: the AI says archive, but we have written to this sender before, so it is kept in the inbox and marked read. A note addressed to three people with no unsubscribe link: the AI says archive, but mail addressed to several people without bulk-mail markers is kept and marked read. A thread with a client copied: the AI says archive, but a client contact is on it, so it stays in the inbox, unread. A notice whose subject says action required: a written rule for that sender says archive, but urgent words in the subject keep it in the inbox, flagged urgent. A mailing-list offer: the AI says archive, no check applies, and it is archived. The checks can only keep mail in front of a person; they never archive anything, and a message a check kept is never used to write a rule. MESSAGE VERDICT THEN A CHECK IN CODE RESULT Mail from a past correspondent A note to three people A thread with a client copied A notice: action required A mailing-list offer AI: ARCHIVE WE HAVE WRITTEN TO THIS SENDER KEPT, MARKED READ AI: ARCHIVE ADDRESSED TO 3, NO UNSUBSCRIBE LINK KEPT, MARKED READ AI: ARCHIVE A CLIENT CONTACT IS ON IT INBOX, UNREAD RULE: ARCHIVE URGENT WORDS IN THE SUBJECT INBOX, URGENT AI: ARCHIVE NO CHECK APPLIES ARCHIVED THE CHECKS CAN ONLY KEEP MAIL IN FRONT OF A PERSON. THEY NEVER ARCHIVE ANYTHING. A MESSAGE A CHECK KEPT IS NEVER USED TO WRITE A RULE.
Each check runs after the verdict and can only keep a message in front of a person. Mail that no check applies to is archived as usual.

List the mistakes you could not recover from, such as a client's email that disappears into an archive. Write each one as a check that can only raise a message's priority. Checks like these can be tested, and they stay the same when you change the model.

Send a client's meeting request straight to a phone

Most decisions about interrupting someone belong to our operations agent, which reads the triage results every fifteen minutes. One kind does not. A model can file a client's request for a call correctly, and the request can still wait in a queue while the times on offer run out. So this one path is written in code, with no AI step.

When a contact at an active client is on a message, the system checks the subject and body for a scheduling request. Some phrases are enough on their own, such as "can we schedule" or "find a time". Weaker ones, such as "your availability", count only next to a meeting word like "call" or "Zoom". Calendar invitations, acceptances and "please hold this time" notices do not count.

A match creates a top-priority work item and sends a phone alert that opens it. A follow-up on the same thread adds to that work item instead of creating another. No alert goes out once we have replied, and a repeat alert waits six hours.

A client's request for a meeting goes straight to a phone Three messages, each with a contact at an active client on it, checked in code with no AI step. The first, from a client contact, asks whether we can find a time for a call this week. It reads as a scheduling request, so a top-priority work item is created and a phone alert goes out that opens it. The second, also from a client contact, is a calendar invitation for a project review. It is a calendar notice, not a request, so it stays in the inbox. The third, with a client contact copied, asks for our availability on a budget question. A phrase about availability counts only next to a meeting word such as call or Zoom, and there is none, so it stays in the inbox. A follow-up on the same thread adds to the same work item. No alert goes out once we have replied, and a repeat alert waits six hours. A CLIENT CONTACT IS ON EACH MESSAGE CHECK IN CODE, NO AI Can we find a time for a call this week? FROM A CLIENT CONTACT Invitation: project review, Thursday FROM A CLIENT CONTACT Let me know your availability on the budget CLIENT CONTACT ON COPY SCHEDULING ASK FIND A TIME, CALL CALENDAR NOTICE NOT AN ASK NO MEETING WORD NOT AN ASK WORK ITEM + ALERT STAYS IN THE INBOX STAYS IN THE INBOX Meeting request CLIENT CONTACT OPENS WORK ITEM TOP PRIORITY A FOLLOW-UP ON THE SAME THREAD ADDS TO THE SAME WORK ITEM. NO ALERT ONCE WE HAVE REPLIED. A REPEAT ALERT WAITS SIX HOURS.
A client asking for time reaches a phone on the next triage run, with no model in the path. Calendar notices and questions without a meeting word stay in the inbox.

When the rule is clear and a miss is expensive, do not leave it to judgment. Write it as code, test it against real examples, and save the model for the cases that need judgment.

Keep a person on the Send button

Every decision is written to a triage log, along with the rule or model result behind it. Every fifteen minutes, the operations agent reads the entries that were not archived. It interrupts someone only for the short list of reasons we have written down, such as a person waiting on a same-day decision. Everything else goes into the queue for the next briefing. Archived mail appears in the briefing as a short summary, such as one line of receipts with each vendor and amount.

For a routine email it can answer with confidence, such as a request to confirm a meeting time, the agent also drafts a reply. The draft becomes a card with a Send button. The agent has no tool that sends email, so nothing leaves until a person taps Send. It never drafts on legal, pricing or personnel threads, and when it is unsure, it does not draft at all.

One more rule sits under all of this. Anyone can send us an email, so the text of every message is treated as data, not as instructions. The model is told so, and before a subject line or preview is saved to the log, the system removes text formatted to look like it came from the system instead of the sender.

The agent drafts a routine reply, and a person sends it Three emails that stayed in the inbox reach the operations agent. The first asks us to confirm that Thursday still works, a routine scheduling confirmation, so the agent drafts a reply. The draft becomes a card marked waiting for review, with the reply text and two buttons: Send, and Send to myself. Nothing sends until a person taps Send. The second is a request to renegotiate a rate, and the third is a contract change to review. Pricing and legal threads are never drafted, so both are queued for the briefing instead. The agent has no tool that sends email, so a draft is the only way out, and it is never used for legal, pricing or personnel threads, or for anything the agent is unsure of. MAIL LEFT IN THE INBOX A CARD IN THE APP Can you confirm Thursday still works? SCHEDULING CONFIRMATION A request to renegotiate a rate PRICING A contract change to review LEGAL DRAFTED Reply to a client WAITING FOR REVIEW Thursday still works on our side. Talk then. Send Send to myself NOTHING SENDS UNTIL A PERSON TAPS SEND NOT DRAFTED, QUEUED NOT DRAFTED, QUEUED THE AGENT HAS NO TOOL THAT SENDS EMAIL. A DRAFT IS THE ONLY WAY OUT. NEVER DRAFTED: LEGAL, PRICING, PERSONNEL, OR ANYTHING THE AGENT IS UNSURE OF.
A routine reply is drafted and waits on a card until a person taps Send. Legal and pricing threads are never drafted, and go to the briefing instead.

Keep sorting, deciding to interrupt and replying as three separate steps, each with its own written rules. Then make a draft the only way out.

Start with a list, not a model

Most organizations have an inbox like ours. Before choosing a model, write down three lists: the mail that written rules can handle, the mistakes you could never recover from, and who presses Send. Those lists are most of the design, and they are where our AI Workflow Review starts.

For how our agent decides what reaches a person at all, read How we cut thirteen alerting agents down to one. For the same approach applied to deadlines, read How to automate follow-up when deadlines slip. Everything else our agent does, and the rules it follows, is on How we run Kaizen on AI.

Want the same for your company?

Bring us two or three workflows that take up your team's week. We will tell you which one to automate first.

How we implement AI

Book a 30-minute call