Routing and grading text
Texts arrive in a workflow all the time — a customer’s message, a supplier’s document, a review, the draft another AI step just wrote — and most of what to do with them depends on what they are: which team, which extraction, which template, whether the draft can go out. Decide with a Model answers that in a fifth of a second for a few thousandths of a credit, and its answers drive the free routing nodes.
Messages
Section titled “Messages”Measured on 30 customer messages across fashion, furniture, electronics, books, hotels, food and flowers, written in English and in Italian: which team was right 30 times out of 30 in both languages, damaged or not 30 out of 30; urgency on three levels was right about three times in four — a subjective scale (see Thresholds and uncertainty).
Describe each team as the person who sorts the inbox would, and keep other for the rest:
value |
description |
|---|---|
refund |
The customer asks for money back |
replacement |
The customer asks for the item to be replaced or exchanged |
shipping |
Delivery, tracking, address or courier |
product_question |
A question about a product before or after buying |
other |
Anything else: account, newsletter, praise, partnership, stores |
Documents
Section titled “Documents”Sorting a document before reading it saves the reading that does not fit. Measured on 16 documents in English and Italian — invoices, quotes, contracts, price lists, and a recipe, a CV, minutes and a letter as other — the kind was right 32 times out of 32, every time with probability 1. Decide with a Model reads text: send it the text of the document (an email body, a text file, the text of a page). For a PDF, Document Analysis reads it directly; sort first when the text is available, then let only the right Document Analysis or Text Generation step run. See X04.
Grading a text against a rubric
Section titled “Grading a text against a rubric”A score with levels that say what each grade means turns a style guide into a check. Measured on product descriptions graded weak (generic, no facts), good (concrete but plain) and excellent (concrete and vivid): 18 out of 18 in English and Italian.
{ "name": "quality", "type": "score", "instructions": "How good is this product description for an online shop?", "levels": [ { "label": "weak", "description": "Generic or empty: no concrete facts about the product" }, { "label": "good", "description": "Concrete and accurate facts (size, material, use) but plain" }, { "label": "excellent", "description": "Concrete facts written vividly, with a reason to buy" } ] }Route on the continuous quality (a Predicate greater_or_equal 1 keeps good and above) or
on quality_level. To check a draft against the facts it must keep, send both in the content with
Text Template and ask “Every claim in the description is supported by the product
facts.” — the step judges only what is in the content.
Three ways to route on the answers
Section titled “Three ways to route on the answers”| Pattern | Nodes | What it gives |
|---|---|---|
| One of several values by the answer | Select by Key, the choice on selector, one case per option, a default |
The reply template, the prompt, the picture of the team chosen — every candidate produced beforehand, one delivered |
| Pay only on the branch that needs it | Predicate equals on the choice, a Filter, the paid step behind it |
A reply draft, an extraction, a translation that runs only for that kind — the other branches are skipped, at no cost |
| Sort or escalate by a score | Predicate greater_or_equal on the score |
urgency ≥ 1.5 escalates; the same number sorts a queue |
Before a paid step, require the model to be sure too: a Combine Conditions
of “is a refund” and all_accepted, so a doubtful case goes to a person instead of getting an automatic answer.
See X02.
The lab
Section titled “The lab”The lab routes one message with the three patterns: Select by Key picks the team’s reply template, a Predicate and a Filter let a reply draft run only for refunds, and a Predicate on the urgency score decides whether to escalate.
| A refund request, in English | A delivery question, in Italian | |
|---|---|---|
| Message | “I cancelled my hotel booking ten days before arrival, within your free cancellation window, but I was still charged. This is unacceptable, please refund the deposit today.” | “Il tracciamento dice consegnato ma davanti alla porta non c’è niente e nemmeno dai vicini. Potete verificare con il corriere?” |
| Team · urgency | refund · high |
shipping · medium |
| Reply template | the refunds template | the delivery template |
| Reply draft (Text Generation) | “I’m sorry you were charged after cancelling within the free cancellation window. Your deposit refund is being processed…” | absent — the step is skipped |
| Escalate | true |
false |
| Credits | 0.013 (decision 0.003, draft 0.01) | 0.003 |
The second message’s inputs are in
run-inputs-shipping.json.
node madoo-install-example.mjs lab-decide-routing --api <your Madoo API URL> --key <key.json> --run