Rules of the mail case, for your team and your coding agent
On this page
- Six principles to align your team around
- Names
- Every workflow carries a note
- Contracts between the pieces
- How n8n calls a Langflow flow
- What each part may do
- Who decides: a rule, the model, or a person
- The five checks (Yanbo's trust components)
- Four things to know about n8n
- Measure before you believe
- Three checks before you build on
- Your team's spec: the six principles, for your own system
For your coding agent: this button copies the whole page as plain text (Markdown). Paste it at the start
of a chat, or save it in your team's folder as AGENTS.md. Fill in your team's spec at the end of this
page first: then the copy carries it too.
This page is a template for your own rules. The rules hold for every system you build with Langflow and n8n. The examples come from the mail case of Workshop II: they show what each rule looks like when it is built, and they are marked as examples everywhere. Your own names, tables and flows take their place: the form at the end writes them in the same words.
Six principles to align your team around
| Principle | Example: the mail case | |
|---|---|---|
| 1 | One task per piece. Each Langflow flow does one job: sort, write, or check. A small piece is easy to test and easy to swap. | The Langflow flow Triage sorts. Draft Reply writes. Check Draft checks. The n8n workflow WS2.3 passes the mail along. |
| 2 | Make a contract about what goes in, what comes out. Each Langflow flow takes a fixed input and gives a fixed answer: which fields, which values. Write it down before you build. | Triage returns action and checks_ok. WS2.3 reads exactly these. |
| 3 | One place for the data. The mails, the search and what was done already live in one database. Every tool reads it. Nothing is copied, nothing runs twice. | PostgresDB holds the mails, the search (chunks) and the table processed. The mail service writes the mails, n8n writes the search entries and processed, Langflow reads. |
| 4 | What a rule decides, what the model decides. The model proposes. A fixed, testable rule decides what happens, the same every time. Anything unknown goes to a person. | A confidential mail (a tag on the mail in the database, not the model's opinion) gets a label, never a draft. An unknown action goes to a person. |
| 5 | What each part may do. Each part gets only what its job needs. The database enforces it, not a prompt. | The agent cannot send. Draft Reply's login never sees a confidential mail. Only approve() moves a reply on. |
| 6 | Where a person decides. Nothing leaves without an OK. The system waits. | In WS2.4 the draft waits on a form until you approve. |
Names
The pattern first, then an example from the mail case; your team's name takes the place of WS2.<step>.
- A workflow:
<prefix> - <what it does>. Example:WS2.3 - Triage New Mail, where the number says where the workflow comes in the course. For a team:Blue - Intake by Mail. - A test (a workflow that checks something):
<prefix> - TEST - <what it tests>. Example:WS2.1 - TEST - Triage. TEST in capitals, so tests stand out in the list. - The test's data tables: the test's name, then what one row is:
… - Cases(one test case per row: the input and the expected answer) and… - Runs(one run per row: when, what changed, and the score). Example:WS2.1 - TEST - Triage - Cases. - Files: the same name in small letters with
_. Example:ws2_1_test_triage.json,ws2_1_test_triage_cases.csv. -
Nodes: small letters with
_, starting with what the node does:What it does Start with Examples gets data get_,fetch_,load_get_newest_mails,fetch_triagechanges data set_,transform_,format_set_answer,format_mail_as_textsends data send_,submit_,post_post_result,submit_to_reply_with_approvalstarts the workflow trigger_,schedule_,webhook_trigger_manual,schedule_every_15_minutesdecides or checks if_,switch_,loop_,check_if_confidential,check_triage -
Tags on every workflow: the course or your team, the part, when. Example:
WS2,mail case,9 Nov. A sticky note in every workflow: see Every workflow carries a note.
Every workflow carries a note
A sticky note at the top of the canvas, so that a teammate, your coding agent, or you in three weeks can read the workflow without opening a node. The pattern first, then the mail case:
- Title: the workflow's name.
- Owned by and last updated: a name and a date.
- What it does: two or three sentences, the rule that decides included.
- Flow: the nodes in order, one line each, named as in the table above.
- Dependencies: the credentials, tables and flows it needs; which workflow calls it, which it calls.
- Part of: the course, or your team and project.
Example: the note of WS2.3 - Triage New Mail starts with Created by: Frank Huettner · Date: 31 Oct 2026 · Part of:
Workshop II, step 3: 9 Nov · Tags: WS2, mail case, 9 Nov, then says in four sentences what the workflow does, the
fixed rule included: a confidential mail gets no draft, only the label.
Contracts between the pieces
- A Langflow flow that n8n calls takes its input as text (one or more Text Input components, filled from outside)
and returns one JSON object in a Text Output. Its fields and their values are written down before the flow
is built. Example: the course's contracts are in
flows.openapi.yaml(OpenAPI with JSON Schemas); Triage, Draft Reply and Judge each have one, Ask Mailbox has none, because it is a chat and a person reads the answer. - The flow checks its own answer. The object carries
checks_ok(true or false) andproblems(a list of short sentences, empty whenchecks_okis true). Example: in the course, a component Check Triage, Check Draft or Check Grade does this as the last step of the flow. - n8n acts only on an answer that passed. It reads only the fields of the contract. Example: WS2.3 acts on a known
actionwhose check did not say no; achecks_okof false, or no valid answer at all, sends the mail to a person, with the problems as the reason. (The course's workflows also take an answer withoutchecks_ok, from an older flow, and mark it unchecked.) WS2.4 shows every draft to a person, with the verdict of Check Draft on the form: the person decides. - Change a contract on both sides at once, and run the test (
WS2.<step> - TEST - …) before you go on.
Example: two answers of Triage, as its contract allows them:
{"action": "calendar", "events": ["Request_Meeting"], "deadline": "Friday at 2 pm",
"why": "Lara asks for a meeting.", "checks_ok": true, "problems": []}
{"action": null, "events": [], "deadline": "", "why": "", "checks_ok": false,
"problems": ["not one JSON object: I think this is a reply."]}
How n8n calls a Langflow flow
This holds for every Langflow flow; the names are the mail case's.
- One HTTP Request node per call:
POST http://langflow:7860/api/v1/run/<flow>?stream=false. Inside kingo-pod, n8n reaches Langflow by its namelangflow, not bylocalhost. - The key goes in the header
x-api-key, from the n8n credential Langflow (Run API). Never in the workflow, never in a file. - A flow with one input gets it as
input_value: Langflow hands it to that input. For Triage:{"input_value": "…the mail…", "input_type": "text", "output_type": "text"}. Ask Mailbox is a chat:{"input_value": "…the question…", "input_type": "chat", "output_type": "chat", "session_id": "…"}. - A flow with several inputs gets one tweak per input. A tweak fills one component of the flow from outside, named by its id. Draft Reply wants the mail and its date, so that Mail Search reads only earlier mails.
- The ids in your Langflow are not the ids in the flow files. Langflow gives every component a new id when you
upload a flow through its page. So n8n reads them first:
GET /api/v1/flows/gives each flow'sendpoint_nameandid,GET /api/v1/flows/<id>the flow itself, and in itsedgeseach Text Input shows the field it feeds. WS2.4 does it in the nodesfetch_flow_list,fetch_draft_reply_flowandset_draft_reply_ids. A component that occurs only once in its flow may also be named by its display name:{"Mail Search": {"search_mode": "keyword"}}. - To see what a flow expects: in Langflow, open the flow, click Share, then API access. It shows the request as code, with the ids of your flow.
- The answer:
outputs[0].outputshas one entry per output of the flow. A flow with one Text Output: its text is atoutputs[0].outputs[0].results.text.text. A flow with several outputs (Draft Reply has three): take the entry whosecomponent_idis the output you want, found the same way. Draft Reply's contract is in the Text Output that Check Draft feeds. A chat answer sits inresults.message.text. The text is JSON: parse it, then check it. - Example: the flows of the course are
enron-triage,enron-draft-reply,enron-judge,enron-ask-mailbox.
What each part may do
The database has one login per part. Each login may do only what that part needs. This is principle 5, enforced by PostgresDB, not by a prompt. The table is the mail case's; your system has its own parts and logins.
| Part (example: the mail case) | Login | May |
|---|---|---|
| The mail service (kingo-pod's part called Mail) | n8n_workshop_mail_container |
write the mails into messages; send what is in outbox once it is approved; do in Gmail what changes asks |
| n8n | n8n_workshop_mail_n8n |
read mails; insert into outbox (a proposal, never a sent mail) and changes (a label, an archive); claim mails in processed; keep the search up to date (chunks); keep test cases and results; run approve() and reject() |
| Langflow, when it answers a question (Ask Mailbox) | n8n_workshop_mail_agent |
read mails, processed, the search and the calendar; write nothing |
| Langflow, when it drafts a reply (Draft Reply) | n8n_workshop_mail_reply |
read the search and the calendar only, no mailbox rows; the database hides every confidential entry from it. The date limit is Mail Search's own: it reads only mails up to the date of the mail it answers |
Also, in the mail case:
- The agent cannot send. No Langflow flow has a tool that sends mail. A reply becomes a row in
outbox, statusproposed.approve()needs the name of the person (a reason is optional) and setsapproved; the mail service then sends it:approved→sending→sent. - Keys live in the credential manager: in n8n under Credentials, in Langflow under Global Variables. Never in a workflow, a flow, or a file you share.
- Course mode: Kaminski's contacts have real addresses (in Gmail they end in
.example). A mail to one of them lands in your own test Gmail account instead. A mail to any other address is not sent: its row ends asfailed. Nothing deletes a mail.
Who decides: a rule, the model, or a person
- A rule decides what must be the same every time. A rule is a node you can test. Example: a confidential mail
gets no draft; only a known
actionpasses; nothing goes out unapproved (if_confidential,check_triage). - The model decides what needs judgement: which action, what the reply says. It proposes data in the contract's form. It never acts on its own, and free text never decides.
- A person decides what leaves the house, and anything unclear. Example: the approval form, the label Check.
The five checks (Yanbo's trust components)
Ask these about your own system. The mail case's answers are the examples in the second column.
| Check | Example: the mail case |
|---|---|
| Input validation: what reaches the model, and what is masked or kept out? | WS2.3 masks personal numbers; a mail that tries to instruct the assistant goes to a person. WS2.4 masks again before Draft Reply. |
| Process guardrails: what may each part do, and who enforces it? | Langflow may only read. The database decides which entries each login sees. Only approve() moves a reply on. |
| Output filter: is every answer checked before anything acts on it? | Check Triage (a known action), Check Draft (no placeholder, the right greeting, addresses and numbers only from the mail or its sources, at least one source). n8n acts on a triage only if its check did not say no; a draft goes to the form with its verdict. |
| Error handling: what happens when a call fails or an answer is bad? | n8n calls Langflow up to twice. A triage that is not valid, or failed its check: the mail goes to a person. A draft that failed its check: the problems are shown on the form. A call that fails both times stops the run with an error; the Error Workflow of 16 November gives such mails back. |
| Audit trail: can you show every run and every decision later? | n8n's Executions: every run that decides something, node by node. The approvals page only shows, so it keeps only its failed runs. outbox: proposed → approved → sent, with who approved, when, and why. |
Four things to know about n8n
They hold for n8n 2.41, the version in kingo-pod, and each one has cost someone in this course an hour.
- Saving is not publishing. n8n runs the published version of a workflow. After a change, click Publish and check that the dot on the button is green; until then the old version keeps running.
- A workflow that another workflow calls accepts all data. Set its trigger to Accept all data. When you pick the called workflow again, for example after an import, n8n empties the inputs you had mapped; with Accept all data, the fields still arrive by their names.
- Credentials are found by name and type. When a workflow is imported or saved, n8n puts in the credential with the same name and type. So the names matter, and a key never goes into the workflow itself.
- A shared export is readable by everyone in the class. Every kingo-pod has the same encryption key. Never put a real API key into a workflow you export or share.
Measure before you believe
- A test is a workflow with cases: one row per case in a Cases table (the input and the expected answer), one row per run in a Runs table (when, what changed, and the score). A test never changes its Cases: results go into Runs, so you can compare one run with the next.
- Change one thing, then measure again. Run three times: a model does not answer the same way twice. A change is better only when it beats the spread of those runs.
- A failure you find becomes a test case. An attack you find becomes a test case too.
Three checks before you build on
From n8n's own course In Practice: AI, Testing & Best Practices; they match what breaks most often in this room.
- Name everything clearly. Workflows, nodes, tables, credentials, as in Names above. A name is the first test of a design: if you cannot name a node by what it does, it does two things.
- Add error handling before you go live, not after something breaks. Every call to a model or an API gets a retry and a path for the answer that is wrong or missing. Example: n8n calls Langflow up to twice; a triage that is not valid goes to a person.
- Use built-in nodes before Code. An IF, a Switch, a Set or a Filter is visible and testable; a Code node hides its logic. Code only where no node does the job.
Your team's spec: the six principles, for your own system
Fill this in before you build on. Then Copy as Markdown and give it to your coding agent, together with the rules
above, or Download it as team_spec.md into your team's folder. The form keeps your text in this browser.