Fields, not free text
The model fills a defined structure. The router never has to search a paragraph for a department name, and a caller receives the same shape every time.
AI and automation / 2026
A shared inbox gets sorted by whoever reads it first. Subject lines rarely say which team should act, so sorting needs the meaning of the message in a form software can use.
The assignment was to classify incoming emails into business departments. The scenario takes the email by webhook and makes one OpenAI call that must return three structured fields. The category is limited to Sales, Customer Service, HR, Finance, Operations or Other, spelled exactly, so a router can compare it directly. Each department has a branch and Other is the fallback. Each branch returns the department, summary and priority as JSON.

Walkthrough
Built from the assignment recording: the scenario, the prompt and its structured fields, the six branches, a test email routed to Sales, and the run log.
My part
Decisions
The model fills a defined structure. The router never has to search a paragraph for a department name, and a caller receives the same shape every time.
The prompt names the six allowed values and asks for exact spelling. The field definition repeats them as examples. That keeps the model's answer inside what the router can match.
The model's output is only an input to the filters. Which branch runs is decided by an exact comparison in the scenario, where it can be read and changed without touching the prompt.
An email that belongs to none of the five departments is classified as Other and takes its own branch, so it is not pushed into the nearest wrong team.
Screens
SYSTEM ARCHITECTURE
A webhook accepts a JSON body with the email's subject, sender and body.
The OpenAI module receives those three values and a prompt that allows exactly one of six categories.
The model's reply is constrained to three fields: category, summary and priority.
A router compares the category with each department name. Other is the fallback route.
The matching branch returns the department, summary, priority and a routing message as JSON.
Built with
Work with me
I build workflows like this one as a fixed-price service: one defined, tested n8n or Make.com workflow, with packages from $149.
More work
Gazelle's KitchenA WhatsApp business gatekeeper that qualifies genuine orders, enforces business and safety rules, contains off-topic or abusive conversations, and only surfaces the small set of cases that genuinely need the owner.PilotSellavie AIAn independent project: multi-tenant conversational-commerce software that connects social messaging with business knowledge, guarded AI, human handoff, orders, billing, analytics and operations.MaintainedAI Automation Control PlaneA runnable multi-tenant control plane for AI-assisted business workflows, combining FastAPI, Next.js, PostgreSQL, Redis, n8n, provider routing, human approval, idempotency, replay, cancellation, audit traces, and deterministic local demonstrations.Maintained