Skip to content

X02 — A support inbox sorted in two languages

A shop’s inbox mixes everything: a refund request next to a delivery question, a compliment next to an angry customer charged three times, in English and in Italian. This workflow sorts every message with one Decide with a Model step — the team, the urgency, whether something arrived damaged — and pays for a written reply only where the answer says one is needed and the model is sure.

A reference run: 8 messages, 8 sorted, 2 reply drafts — 0.052 credits. The run’s outputs.

Eight messages from a week of a home-and-gifts shop: broken headphones with a burnt smell, a parcel stuck in tracking (in Italian), a chair with a cracked leg, a question about a pushchair (in Italian), a triple charge (in Italian), a compliment, a customer hesitating over a pair of trainers, and flowers for a funeral tomorrow morning that have not left (in Italian). The messages are the example’s own, written for it.

  • One step, three answers. Team (a choice of five, at 0.7), urgency (a score on three levels) and damage (a yes/no at 0.8) in one call per message: 0.004 credits each.
  • Two languages, the same questions. The questions are in English; the Italian messages are sorted as well as the English ones — the same was true on the 30 messages of our measurement set.
  • Pay only when it is needed and sure. The reply draft — the one step that writes, and the only one that costs more than a decision — runs only when the team is refunds and all_accepted: a Combine Conditions, then a Filter. The other six messages cost nothing more.
  • A queue, not a pile. Every message comes out in the Work queue with its team and probability, the urgency level and score to sort by, the damage flag, whether the model was sure, and the draft when there is one (null otherwise).

The workflow: the inbox, one message at a time, Triage the message, A refund request, A refund and the model is sure, Only sure refund requests, Draft the refund reply, the work queue

Node Type Why
Inbox input/json_value The messages: [{"id": "…", "text": "…"}]
One message at a time enumerate/json One iteration per message
Triage the message ai/decide team (refunds, replacements, deliveries, product_advice, other), urgency (low, medium, high), damaged
A refund request? utility/predicate equals refunds
A refund, and the model is sure utility/boolean_combine all with all_accepted A doubtful refund gets a person, not an automatic draft
Only sure refund requests utility/filter The draft’s branch runs only for those
Draft the refund reply ai/text_generation Three sentences, the customer’s language, no date or amount promised
Work queue aggregate/json, the draft with whenAbsent: null Every message with its answers
Message Team Probability Urgency (score) Damaged Draft
M-101 headphones burnt, “I want my money back” refunds 1.00 medium (1.07) yes written
M-102 “il tracciamento è fermo da quattro giorni” deliveries 0.99 medium (1.05) no
M-103 chair with a cracked leg, “send me a new chair” replacements 1.00 medium (0.85) yes
M-104 “il passeggino chiuso entra nel bagagliaio?” product_advice 0.99 low (0.19) no
M-105 “mi avete addebitato tre volte” refunds 0.92 high (2.00) no written, in Italian
M-106 a compliment to the staff other 1.00 low (0.00) no
M-107 trainers “maybe half a size small? I might keep them” product_advice 0.75 low (0.01) no
M-108 “i fiori per il funerale di domani alle 9” deliveries 0.99 high (1.98) no

Every answer was sure. The hesitant trainers message (M-107) is the closest call — product advice at 0.75 against a threshold of 0.7; at 0.8 it would have been flagged for a person. Sort the queue by urgency_score and the funeral flowers and the triple charge come first.

M-101 draft: “I’m sorry the headphones stopped working and developed a burnt-plastic smell. I’ve passed your refund request to our refunds team for review. Please stop using them.”

M-105 draft: “Mi dispiace per i tre addebiti sullo stesso ordine. Ho inoltrato la richiesta di rimborso al nostro team rimborsi, che verificherà la situazione.”

Cost: 0.052 credits — eight decisions at 0.004 and two drafts at 0.01. A thousand messages with a refund rate like this one cost about 6–7 credits.

Terminal window
node madoo-install-example.mjs x02-support-inbox --api <your Madoo API URL> --key <key.json> --run
  • Your teams: the options of team, with descriptions in your words; keep other.
  • Your rules: a draft also for replacements (a second Predicate and Filter), or none at all; escalation with a Predicate on urgency_score.
  • Your channel: the messages can come from a form, an email integration or a webhook — anything that gives text.
  • A stricter queue: raise the threshold of team to 0.8 and send model_sure: false to a person.

manifest · workflow · run inputs · the complete graph