Workbook, 9 November
On this page
- Block 2 · You must add two data tables before you build your first workflow
- Make the two data tables
- Block 2 · WS2.1: You build an n8n workflow to test your Langflow Triage flow
- Extra, if you are fast: build WS2.2 - Ask Mailbox
- Extra, if you are fast: let an AI chat write the SQL
- Block 3 · Your mail AI assistant answers your mail: WS2.3 and WS2.4
- Block 4 · Challenge: all five test mails right
- Test your project's Langflow flows from n8n, too
- Block 5 · Let's look inside WS2.3, and make it ours
- Look inside WS2.3
- Your own rule: an urgent mail gets a star
- Block 6 · Why we put the human in the loop in WS2.4
- If something goes wrong
- Go deeper, in your own time
- Only if you use a coding agent to write the contracts
First, three checks:
- kingo-pod runs. In the terminal, in your kingo-pod folder, run
./kingo up. Then open n8n in your browser: http://localhost:5678. - Your test Gmail account is open in another browser tab.
- You downloaded
ws2_s1.zipand unzipped it (double-click it). In the folderws2_s1:ws2_s1_workbook.html: this page- today's slides, as HTML and as PDF
- two CSV files for the data tables
- the folder
n8nwith today's workflows
Block 2 · You must add two data tables before you build your first workflow
What is a data table? A table that lives in n8n, like a small spreadsheet.
Why do I need to add it? Your first workflow, WS2.1 - TEST - Triage, will test the Langflow flow that sorts
mails. To this end, it needs test mails. Those test mails are in the first data table. Then, it needs to write down
the test results. Those go into the second data table.
Make the two data tables
-
In n8n, click Overview at the top left, then the tab Data tables in the middle of the page.
-
Click Create data table.
-
Data table name: paste this name.
THE NAMES ARE IMPORTANT BECAUSE YOUR SOLUTION FILES LOOK FOR EXACTLY THESE NAMES.
WS2.1 - TEST - Triage - Cases -
Pick Import CSV. Drop the file
ws2_1_test_triage_cases.csvfrom your folderws2_s1into the box, or click the box and pick it. -
Turn on My CSV file contains a header row: the first line of the file holds the names of the columns.
-
n8n shows the columns it found, with their types. Leave them as they are. Click Create.
-
The same again for the second table, with this name and the file
ws2_1_test_triage_runs.csv:WS2.1 - TEST - Triage - Runs
Done: your two data tables are ready. Cases holds the five test mails. Runs is still empty: in block 4 it gets one line per run.
Block 2 · WS2.1: You build an n8n workflow to test your Langflow Triage flow
What the workflow does
It takes the five test mails from the data table Cases. Each goes to your Langflow flow Triage, by HTTP. The action in Triage's answer goes back into Cases, next to the expected one. In block 4, a second workflow gives it a score.
-
Click Create workflow. Click its name at the top and give it this name:
WS2.1 - TEST - Triage -
Add a first node: a Manual Trigger (in the list: Trigger manually). It starts the workflow when you click Execute workflow. Rename it
trigger_manual. -
Add a Data table node and name it
get_cases. It reads the five test mails. Set it like this:Pick Get row(s). Under Data table, choose From list and pick this table:
WS2.1 - TEST - Triage - CasesTurn Return All on.
Click Execute step: on the right, five items.
-
Add an HTTP Request node and name it
fetch_triage. It sends each mail to your Triage flow in Langflow. Set it like this:Choose method POST and paste the URL:
http://langflow:7860/api/v1/run/enron-triage?stream=falseFor Authentication, choose Generic Credential Type, then Header Auth, then
Langflow (Run API). Turn Send Body on. Body Content Type: JSON. Specify Body: Using Fields Below.Under Body Parameters, add three. The first: Name
input_value, and as Value paste this:{{ $json.mail }}The second: Name
input_type, Valuetext. The third: Nameoutput_type, Valuetext.What it does
n8n sends one request per test mail, five in all. Each is one JSON object with three fields:
{ "input_value": "From: Jason Sokolov ... (the whole mail)", "input_type": "text", "output_type": "text" }input_valueis the mail, from the columnmailof Cases. Langflow puts it into the flow's one Text Input, the box you pasted a mail into in homework step 8. Text goes in, text comes out.What Langflow expects, in its own words: in Langflow, open the flow Triage (Enron), then Share at the top right, then API access.
-
Add an Edit Fields node and name it
set_answer. It turns Triage's answer into fields n8n can read. Set it like this:Click Add Field and name it
answer. Next to the name, change its type from String to Object. Then paste this as its value:{{ $json.outputs[0].outputs[0].results.text.text }}Click Execute step. On the right, each item now has
answerwith Triage's fields:action,why,checks_okand more.What it does
Langflow answers with one object.
outputs[0].outputs[0]is the flow's first output, andresults.text.textits text: Triage's answer, as JSON text.The type Object makes n8n read that text as JSON, so each of its fields becomes a field of its own. That works because Triage keeps its contract: its answer is always JSON, with these fields.
-
Add a Data table node and name it
post_action_to_cases. It writes the action into the table Cases. Set it like this:Pick Update row(s) and, from the list as in
get_cases, the table Cases. Add a condition: the columnid, Equals, and paste this value:{{ $('get_cases').item.json.id }}What it does
$('get_cases')is the nodeget_cases..itemis its item that belongs to this one: the same test mail..json.idis that mail's columnid. So each action goes into the row of its own test mail.n8n writes the same when you drag the field
idofget_casesfrom the left into the box.Under Values to update, fill the column
action: on the left, openanswerand drag its fieldactioninto the box. n8n writes this:{{ $json.answer.action }} -
Click Execute workflow.
-
Open the table: click Overview, then the tab Data tables, then
WS2.1 - TEST - Triage - Cases. Triage's answer now stands next to the expected one. -
Tidy up:
-
Give the workflow the tags
WS2,mail caseand9 Nov: click the three dots … at the top, next to its name, then Edit description and tags. -
Add a sticky note (Shift+S).
Paste this into the sticky note, and put your name in place of Your Name:
## WS2.1 - TEST - Triage **Created by:** Your Name · **Date:** 9 Nov 2026 Tests the Langflow flow Triage: the five test mails from the table Cases go to Triage, one by one. Triage's action goes back into Cases, next to the expected one.
-
Done: your first n8n workflow tests your Triage flow.
Stuck? Import n8n/ws2_1_test_triage_solution.json. It gives the finished workflow WS2.1 - TEST - Triage - SOLUTION. Help for block 2
Extra, if you are fast: build WS2.2 - Ask Mailbox
This becomes a chat that allows you to search your mail. It's like the playground from your homework step 13, just in n8n. It contains:
- a Chat Trigger
trigger_chat - an HTTP Request
fetch_ask_mailbox - an Edit Fields node
set_answer
Make an n8n workflow with the name:
WS2.2 - Ask Mailbox
Add a Chat Trigger node and name it trigger_chat.
Open the chat at the bottom and send this question. Now trigger_chat has an item, and the next node shows it on its left:
Who is sharing homemade Korean food?
Add an HTTP Request node, name it fetch_ask_mailbox, choose method POST, and paste the URL:
http://langflow:7860/api/v1/run/enron-ask-mailbox?stream=false
For Authentication, choose Generic Credential Type, then Header Auth, then Langflow (Run API). Turn Send Body on, choose JSON and Using JSON, and paste the body:
{{ JSON.stringify({ input_value: $json.chatInput, input_type: 'chat', output_type: 'chat', session_id: $json.sessionId }) }}
Add an Edit Fields node and name it set_answer. Click Add Field, name it output, and paste this as its value:
{{ $json.outputs[0].outputs[0].results.message.text }}
Then open the chat at the bottom, and ask:
What is Steve Leppard's email address?
Who arranges tours of the Enron trading floor?
Between two questions, you may need to reset the chat: click the curved arrow at the top of the chat.
Stuck? Import n8n/ws2_2_ask_mailbox_solution.json. It gives the finished workflow WS2.2 - Ask Mailbox - SOLUTION.
Extra, if you are fast: let an AI chat write the SQL
This becomes a workflow that answers one question: who wrote to Kaminski most often? It contains:
- a Manual Trigger
trigger_manual - a Postgres node
get_top_senders
The credential may only read and write what n8n needs: a wrong query cannot break the mailbox.
Make an n8n workflow with the name:
WS2.2 - Top Senders
Add a Manual Trigger node (in the list: Trigger manually) and name it trigger_manual.
Give this to an AI chat like ChatGPT:
Write a PostgreSQL query for me.
The table: n8n_workshop_mail.messages, one mail per row. Its columns:
- message_id
- sent_at
- from_name
- from_addr
- to_addrs (text[])
- cc_addrs (text[])
- subject
- body_text
- folders (text[]: INBOX, Sent, ...)
- deleted_at
The question: who sent the most mails?
Leave out:
- the mails in the folder Sent
- the deleted mails
The result:
- one row per sender (from_addr), with the number of mails
- the ten largest first
Add a Postgres node, name it get_top_senders, pick the credential Mail (n8n_workshop_mail_n8n) and Execute Query, and paste the AI chat's answer as the query. Then click Execute workflow: the ten senders appear on the right.
A solution, just in case
SELECT from_addr, count(*) AS mails
FROM n8n_workshop_mail.messages
WHERE deleted_at IS NULL AND NOT 'Sent' = ANY(folders)
GROUP BY from_addr
ORDER BY mails DESC
LIMIT 10;
Stuck? Import n8n/ws2_2_top_senders_solution.json. It gives the finished workflow WS2.2 - Top Senders - SOLUTION: Execute workflow, then open get_top_senders.
Block 3 · Your mail AI assistant answers your mail: WS2.3 and WS2.4
You import three ready workflows and turn them on. Then you send a mail from your SKKU account: your mail AI assistant sorts it, drafts an answer, waits for your OK, and sends it.
-
Import these three workflows from the folder
n8n:ws2_4_reply_with_approval.jsonws2_4_approvals_page.jsonws2_3_triage_new_mail.json
-
Check the credentials in WS2.4. n8n should pick them by their name, but check:
- Open
WS2.4 - Reply with Approval. - Double-click the node
fetch_flow_list. Under Header Auth, it should sayLangflow (Run API). Another one, or none? PickLangflow (Run API). Close the node with the ✕ at the top right. - Do the same in the nodes
fetch_draft_reply_flowandfetch_draft_reply. - Save.
A node whose name starts with
fetch_calls another service, so it needs that service's credential. Any other node with a warning: pick the credential with the same name. - Open
-
Check the credential in WS2.3:
- Open
WS2.3 - Triage New Mail. - Double-click the node
fetch_triage. Under Header Auth, it should sayLangflow (Run API). If not, pick it. Close the node.
- Open
-
Connect WS2.3 to WS2.4:
- Still in WS2.3, double-click the node
submit_to_reply_with_approval. - In the field Workflow, pick
WS2.4 - Reply with Approval. - Save.
- Still in WS2.3, double-click the node
-
Turn them on, in this order. Open each one, click Publish at the top, then Publish again in the window:
A Production Checklist may open, also after a reload: close it with ✕.
WS2.4 - Reply with ApprovalWS2.4 - Approvals PageWS2.3 - Triage New Mail
-
Open the approvals page in a new browser tab, at this address. It says "No draft waits".
http://localhost:5678/webhook/approvalsThe address is in
WS2.4 - Approvals Pagetoo: double-click its nodewebhook_open_approvals, click Webhook URLs at the top, then Production URL.Test URL or Production URL?
Production URL, with
/webhook/: it works while the workflow is published. Every call starts a run, and you find the run under Executions. Publishing is what puts a workflow into production, so the approvals page needs nothing else.Test URL, with
/webhook-test/: it works only while you build. Click Execute workflow, then open the Test URL once. n8n shows that one run right on the canvas. -
From your SKKU account, send this mail to your test Gmail account:
The subject:
Steve's addressThe text:
Dear Vince, what is Steve Leppard's email address? I need to reach him. -
A little later, the draft appears on the approvals page. Open its approval form. The draft stands in the field Text to send: change it if you like. Then choose approve and give your name.
-
Kaminski's answer arrives in your SKKU inbox.
Done: your mail AI assistant answers mail, and you stay in control.
What happens on the way
kingo-pod's part called Mail copies your mail from Gmail into PostgresDB. The new row wakes WS2.3: it takes the
mail, masks personal numbers, asks the Langflow flow Triage and checks the answer. For reply it calls WS2.4: the
Langflow flow Draft Reply drafts from Kaminski's earlier mails, n8n checks the draft, writes it into the table
outbox and waits for you. The mail service sends only what you approved.
Stuck? Help for block 3
Block 4 · Challenge: all five test mails right
Your Triage flow sorts some of the five test mails wrong. A ready workflow gives it a score, three rounds per click. Then you improve the prompt until all five are right.
| Test mail | Subject | Expected |
|---|---|---|
| 8 | Papers | reply |
| 30 | (no subject) | forward |
| 46 | Market Forecasting Conference | reply |
| 67 | RE: Jump | archive |
| 126 | Contact Info for Conference Call Tomorrow at 10 am EDT | calendar |
-
Import
n8n/ws2_1_test_triage_improved.jsonfrom the foldern8n. It givesWS2.1 - TEST - Triage - Improved. -
Check its credential: double-click the node
fetch_flow. Under Header Auth, it should sayLangflow (Run API). If not, pick it. Close the node, then save. -
Before you run it, look at its nodes. Double-click each one:
Node What it does trigger_manualstarts it when you click Execute workflow webhook_open_runsstarts it from its page in your browser: opening the page shows the dashboard, its button runs the test set_test_settingsthe settings: rounds(3), the flow (enron-triage, your Triage flow), and the field of its answer to compare (action)set_settings_from_page,if_run_requestedwhat the page's form sent, over the settings; a test runs only after a click on Run the test, or Execute workflow get_casesthe five test mails from Cases, as in your WS2.1 transform_into_roundseach test mail once per round: 15 items fetch_flowthe 15 mails to your Triage flow, five at a time set_answerTriage's answer as fields, as in your WS2.1 set_scoreeach action next to the expected one: the score of each round, the seconds, every answer post_run_to_runsone line into Runs get_runs,transform_runs_into_dashboardevery line of Runs as a dashboard format_dashboard_as_html,send_dashboard_pagethe dashboard in n8n, and as a page in your browser Check yourself: your WS2.1 writes each action into Cases. Does this workflow do that too?
The answer
No. The one node that writes,
post_run_to_runs, writes into Runs. Cases holds the test: the five mails and what is expected. A test should not change its test set. The results go into Runs, one line per click, so you can compare one prompt with the next.And: why does it send each mail several times?
The answer
The model does not always give the same answer to the same mail. One round can be lucky, or unlucky. Three rounds show whether a prompt holds. Want more? Set more rounds: a clearer picture, a longer wait.
-
Run it once here, in n8n:
- Click the small arrow next to Execute workflow and pick
trigger_manual. - Click Execute workflow.
- When all nodes are green, double-click the node
format_dashboard_as_html. On the right: your dashboard.
Why pick a trigger? With two triggers, n8n starts from the webhook unless you pick another. The webhook would wait for a call of its page, and nothing happens. n8n picks the webhook again after each reload.
- Click the small arrow next to Execute workflow and pick
-
Open the dashboard as a page, to keep next to Langflow:
-
Click Publish at the top, then Publish again in the window. The page works only while the workflow is published.
-
Open this address in a new browser tab:
http://localhost:5678/webhook/triage-runs -
At the top, the form: what you changed, the rounds, the flow, the field. Its button Run the test runs the test. The page comes back when all rounds are done, with the new run.
-
-
Read the dashboard:
- The most recent run: right answers per round, on average. Is it better than the run before, and than your start? Only beyond the spread counts: every round better than every round before.
- Every run: one row per run, one dot per round. The spread of the dots is the model's luck.
- Every test mail, run by run: in how many rounds each mail was right. ▲ or ▼: better or worse than the run before. The mails that work worst come first.
- Wrong in the most recent run: what the model answered.
- Each run in detail: click a run, and see every answer of every round.
-
In Cases, read the mails it got wrong, in the column
mail. Why would the model choose that? -
In Langflow, open Triage (Enron), then the node Prompt Template. Change how the actions are described. Only the prompt. Save.
-
On the page, write what you changed, and click Run the test. Did your fix for one mail break another? The table of test mails shows it.
Done: you test your Triage flow the right way: three rounds per click, one line per run, the test set untouched, and a dashboard that shows what each change did.
Our prompt, for after the challenge: 5 of 5, ten times in a row
In Langflow, open Triage (Enron), then the node Prompt Template. Click into Template, select all of it, and paste this in its place. Save the flow, then run WS2.1 - TEST - Triage - Improved again.
You sort the incoming mail of Vince J Kaminski, head of the research group at Enron in Houston, in 2001.
Read the mail below and answer with one JSON object and nothing else: no explanation, no code fence.
The object has four keys:
"events" a list of strings: the names of every MailEx event in the mail's own text that is addressed to
Kaminski or to all recipients, for example ["Request_Data", "Deliver_Data"]; [] if none. The names:
Request_Data asks for information
Request_Action asks someone to do something
Request_Meeting asks for a meeting or call
Request_Action_Data asks about an action (has it been done, when will it be)
Request_Meeting_Data asks about a meeting (time, place, who comes)
Deliver_Data gives information
Deliver_Action_Data says an action is done, will be done, or will not be
Deliver_Meeting_Data gives a meeting's time, place, agenda or outcome
Amend_Data, Amend_Action_Data, Amend_Meeting_Data corrects or changes something given before
"action" what his assistant does with the mail, one of:
"calendar" a meeting, call, visit or interview is asked for or set, or how it will take place
(time, place, who calls whom): to Shirley Crenshaw (his assistant) or into the calendar
"reply" someone wants information, an answer or a decision from Kaminski himself: draft a reply in
his name
"forward" someone wants work done that his assistant or his team can do: send documents or slides,
make copies, fill in a form, book, register; forward it to whoever does it, or note it as
a task
"archive" it only delivers, informs or announces (reports, newsletters, FYI, thanks, spam): file it
Pick the one that matters most if several apply. Work to be done by a date matters more than a
request to confirm receipt.
"deadline" a date or time by which something is wanted, as written in the mail; "" if none
"why" one short sentence
The mail:
{mail}
What changed: reply only for what Kaminski himself must answer; forward for work his assistant or his team can do; calendar also for how a call will take place; and work to be done by a date matters more than a request to confirm receipt.
Five mails are not enough to know it is better overall. On all 140 test mails of the case, it got about as many right as the prompt as it comes.
Test your project's Langflow flows from n8n, too
The same works for every Langflow flow of your team's project: a copy of WS2.1 - TEST - Triage - Improved, with
your test cases and your flow. You see every answer, and you can run the test again after each change.
It also avoids the Langflow 1.8 memory bug (what it is). In the Playground, chats with the same name share one memory across flows, so a test can see another flow's chat. A call from n8n never does: each call of the workflow has its own session id, so a flow with memory starts fresh for every case.
-
Write your test cases. Open
ws2_1_test_triage_cases.csvin Excel or Numbers and keep its first line, the names of the columns. Below it, one test case per line:test_mail: a number for the casesubject: a short titlemail: what your flow gets, the text you would type into its Playgroundexpected: what it should answeraction: leave it empty
Save it as CSV, with a new name.
-
Make two data tables, as in block 2, with your team's name and what you test, for example:
Blue - TEST - Intake - Cases, from your new fileBlue - TEST - Intake - Runs, fromws2_1_test_triage_runs.csv
-
Open
WS2.1 - TEST - Triage - Improved. Open the menu … at the top, next to its name, then Duplicate. Name the copy after your test, for exampleBlue - TEST - Intake. -
In the copy, pick your tables: double-click
get_casesand pick your Cases table in the field Data table. Do the same inpost_run_to_runsandget_runs, with your Runs table. -
Give the page an address of its own: double-click
webhook_open_runsand change Path, for example toblue-intake-runs. Two published workflows cannot share a path. -
Double-click
set_test_settingsand change the values:flow_endpoint: your flow. In Langflow, open it, click Share at the top right, then API access. Copy what comes after/run/in the address, up to?if there is one.answer_field: does your flow answer with JSON, as Triage does? Then the field to compare withexpected, for exampleaction. Does it answer with text? Then leave it empty: a case counts as right when the answer containsexpected.rounds: how often each case goes to the flow.
The page's form can change all three for one run.
-
Click Publish. Open your page, for example
http://localhost:5678/webhook/blue-intake-runs, and click Run the test.
Stuck? Help for block 4
Block 5 · Let's look inside WS2.3, and make it ours
Look inside WS2.3
-
Open
WS2.3 - Triage New Mail, then the tab Executions at the top: one line per run. -
Click the run of your mail. Double-click a node: on the left what came in, on the right what went out.
Step Node What it does Wake up trigger_new_mail_notifyPostgresDB tells n8n at once: a new mail is here schedule_every_15_minuteslooks every 15 minutes too, in case that message got lost Take it once fetch_and_claim_new_mailsnotes each new mail as taken, in the table processed; a mail already there is skipped, so no mail gets two answersProtect format_mail_as_textthe mail as one text: sender, date, subject, body transform_mask_personal_numbersmasks card and bank numbers before any model sees the mail check_injectiona model asks: does the mail try to give the assistant orders? If so, a person looks at it Ask Triage fetch_triagesends the mail to your Langflow flow Triage and gets its answer check_triagen8n goes on only with an answer in order: checks_okis true, and the action is one of the four. Anything else: a person looks at itAct post_resultwrites Triage's answer into processed, next to the mailif_confidentialthe fixed rule: a mail marked confidential only gets its label, whatever Triage proposed switch_by_actionone way out per action: a label, the archive, or WS2.4 for a draft. A person looks at anything else: label Assistant/Check How the wake-up call works
When kingo-pod's part called Mail writes a new mail into PostgresDB, the database itself sends a short message on a channel named
n8n_workshop_mail_new.trigger_new_mail_notifylistens on that channel: double-click it, and you see Listen For set to Advanced and the Channel Name. So WS2.3 starts within seconds, and nobody has to ask every minute whether something is new.It listens only while WS2.3 is published. When you click Execute workflow, it waits only 30 seconds for a new mail. If a message gets lost, for example while n8n restarts,
schedule_every_15_minutestakes the mail a little later. Either way,fetch_and_claim_new_mailstakes each mail only once.
Your own rule: an urgent mail gets a star
A mail whose subject says "urgent" gets a star in Gmail.
-
Go back to the tab Editor.
-
From the small dot on the right of the node
check_triage, drag a line to an empty spot: n8n opens the list of nodes. Pick an If node and name itif_urgent. Set it like this:Paste this as the value on the left:
{{ $json.subject }}Choose String, then contains, and type
urgenton the right. Under Options, turn Ignore Case on. -
From its true output, add a Postgres node and name it
post_star. Set it like this:Pick the credential
Mail (n8n_workshop_mail_n8n)and Execute Query, and paste the query:INSERT INTO n8n_workshop_mail.changes (message_id, action, label) VALUES ($1, 'star', NULL);Under Options, add Query Parameters and paste this:
{{ $json.message_id }}What else your rule can do in Gmail
post_starwrites one row into the tablechanges. kingo-pod's part called Mail reads it, makes the change in your mailbox, and Gmail shows it seconds later. The row says what to do in two words: the action, then a label.NULLmeans: no label.In place of 'star', NULLWhat Gmail shows 'star', NULLa star 'unstar', NULLthe star taken off 'read', NULLthe mail as read 'unread', NULLthe mail as unread, in bold 'label', 'Urgent'the label Assistant/Urgent 'unlabel', 'Urgent'that label taken off 'archive', NULLthe mail out of the inbox; it stays in All Mail 'inbox', NULLthe mail back in the inbox For example, the label Assistant/Urgent in place of the star:
INSERT INTO n8n_workshop_mail.changes (message_id, action, label) VALUES ($1, 'label', 'Urgent');The label is a word of your own: letters, digits, spaces,
-and_, up to 40 characters. Gmail shows it under Assistant, next to the labels WS2.3 gives.No change deletes a mail or sends one. A change that failed keeps its row in
changes, with the statusfailedand the reason in the columnerror. -
Click Publish again: n8n runs only the published version.
-
From your SKKU account, send a mail with this subject. A little later it has a star in Gmail.
Urgent: call me back
Done: your own rule runs in a real system. A rule decides here, not the model: the same every time.
Stuck? Import n8n/ws2_3_triage_new_mail_solution.json. It gives the finished workflow WS2.3 - Triage New Mail - SOLUTION, with the rule. In its node fetch_triage, check that Langflow (Run API) is picked; in its node submit_to_reply_with_approval, pick WS2.4 - Reply with Approval. Unpublish your WS2.3, then publish the solution: never both, or each new mail goes to only one of them. Help for block 5
Block 6 · Why we put the human in the loop in WS2.4
Nothing to build. You look at what happened to your mail from block 3, and keep one list short.
-
Open
WS2.4 - Reply with Approval, then the tab Executions. -
Click the run of your mail from block 3.
-
Double-click the nodes, one after the other:
Node What it does get_mail,if_draft_giventhe mail from the database; a workflow that calls WS2.4 may bring its own draft format_mail_as_text,transform_mask_personal_numbersthe mail as text, personal numbers masked fetch_flow_list,fetch_draft_reply_flow,set_draft_reply_idsLangflow gave each part of your flow a new id when you uploaded it, so n8n reads the ids here, from the flow itself: which Text Input takes the mail, which the date fetch_draft_replythe Langflow flow Draft Reply: Kaminski's earlier mails up to the mail's date, never a confidential one; it checks its own draft (Check Draft) check_draft,if_draft_finea draft, and someone to send it to; Draft Reply's verdict goes onto the approval form post_proposal_to_outboxa row in outbox, statusproposedwait_for_approvalthe form, with the draft in a field to edit; the run waits for you post_approve,post_rejectyour decision into the database; the mail service sends what is approved
The agent cannot send. No Langflow flow has a tool for that. Fixed rules check the draft, a person approves, and the database allows only that order.
-
Keep the approvals page's list of runs short:
- Open
WS2.4 - Approvals Page. - Open the menu … at the top, next to its name, then Settings.
- Set Save successful production executions to Do not save, then click Save.
The approvals page is a workflow of its own, so its runs stay out of WS2.4's list. It reloads every 15 seconds, and each reload is a run: 240 an hour. Does that break the rule that you can show every run and every decision later? No: the page only shows, it decides nothing. The decisions stay in WS2.4's runs and in
outbox, with who approved, when, and why. And n8n still keeps the page's failed runs.Want to see one run of the page? In
WS2.4 - Approvals Page, click Execute workflow. Then open its Test URL once: in the nodewebhook_open_approvals, Webhook URLs, then Test URL. n8n keeps the runs you start by hand. - Open
If something goes wrong
Find your block. Still stuck? Ask Frank.
After any import: a node with a credential warning, or with none? Double-click it and pick the credential with the
same name. A node whose name starts with fetch_ needs Langflow (Run API).
Block 2
| What you see | What to do |
|---|---|
fetch_triage gives an error 403 |
The credential Langflow (Run API) holds the wrong key. In Langflow, open Settings, then Langflow API Keys, and make a new one. Put it into the credential. |
fetch_triage gives no answer, or a timeout |
WS2.0 may still be embedding, or Langflow is busy. Wait a minute, then click Execute step again. The URL must say langflow, not localhost: inside kingo-pod, n8n reaches Langflow by its name. |
get_cases gives no items |
The table's name must be exactly WS2.1 - TEST - Triage - Cases. Check it: click Overview, then the tab Data tables. |
set_answer gives an error, or the column action stays empty |
Is the type of the field answer Object? Then open fetch_triage's output: under text you should see Triage's answer as JSON, with "checks_ok": true. An empty mail in its why? Then fetch_triage sends no input_value: check its three Body Parameters. |
| You are behind | Import n8n/ws2_1_test_triage_solution.json. It gives the finished workflow WS2.1 - TEST - Triage - SOLUTION. Go on in it. |
Block 3
| What you see | What to do |
|---|---|
| No draft appears on the approvals page | Open WS2.3, tab Executions: which action did Triage choose? A mail that only informs is archived. Ask a clearer question, or run WS2.4 by hand: open WS2.4 and click Execute workflow. It drafts for the newest mail that WS2.3 sorted as reply. For another mail, put its message_id (WS2.3's run, node post_result) into the node set_mail_to_try, in place of newest. |
| WS2.3's run failed, you fixed it, and still nothing comes | WS2.3 takes each mail only once, also when its run failed. Send your mail again: a new mail is a new row. |
| In WS2.3, Execute workflow stops with "Aborted, no data received within 30secs" | The button started trigger_new_mail_notify: by hand, it waits only 30 seconds for a new mail. You need not run WS2.3 by hand: published, it runs by itself. To run it now anyway, click the small arrow next to Execute workflow, pick schedule_every_15_minutes, then click Execute workflow: it takes every new mail at once. |
| WS2.3 shows no run at all | WS2.3 must be published, and the mail must come from the address you allowed in homework step 6, to your test Gmail account's main address. ./kingo mail status shows whether the mail arrived in the database. Not there? In your test Gmail account, look in Spam: Spam is not synced. Click Not spam, and the mail comes in. |
submit_to_reply_with_approval gives an error |
Pick the called workflow again: double-click the node and choose WS2.4 - Reply with Approval in the field Workflow. |
In WS2.4, get_mail gives an error about a parameter |
set_mail_to_try needs newest or a message_id. |
In WS2.4, a fetch_ node gives an error 403 |
Its credential: it must be Langflow (Run API) (step 2). |
In WS2.4, fetch_draft_reply_flow gives an error |
Langflow has no flow with the endpoint enron-draft-reply. In Langflow, open your project WS2 - Mail Assistant (Enron): is Draft Reply (Enron) there? If not, upload it again (homework step 8.3). |
| No answer in your SKKU inbox | Look in its spam folder first. Then on the approvals page: did you approve? In n8n, WS2.4's run: did post_approve run? |
Block 4
| What you see | What to do |
|---|---|
fetch_flow gives an error 403 |
Its credential: it must be Langflow (Run API) (step 2). |
fetch_flow gives a timeout |
Langflow is busy: 15 mails, five at a time. Wait a minute, then click Execute workflow again. |
fetch_flow gives an error 404 |
Langflow has no flow by the name in flow_endpoint, in set_test_settings. For Triage: enron-triage. |
| The page says that the webhook is not registered | Publish WS2.1 - TEST - Triage - Improved (step 5). Its page works only while it is published. |
| After Run the test, the page seems to hang | It waits until all rounds are done. Do not click again: each click is a run of its own. |
| Your project's copy will not publish | Give webhook_open_runs in the copy a path of its own. |
| In your project's test, every case counts as wrong | Look at set_answer's output. JSON with your field? Then answer_field must name it exactly. Plain text? Then leave answer_field empty. |
get_cases gives no items |
As in block 2: the table's name must be exactly WS2.1 - TEST - Triage - Cases. |
| Execute workflow says "Waiting for trigger event" | It started from webhook_open_runs. Click the stop button, then the small arrow next to Execute workflow, and pick trigger_manual (step 4). |
post_run_to_runs gives an error |
Your table Runs needs the columns of ws2_1_test_triage_runs.csv: ran_at, note, flow, score, rounds, seconds, wrong, detail. Make it again from that file, as in block 2. |
| Your change in Langflow does nothing | Save the flow (the flow must say it is saved). Then click Execute workflow in n8n again. |
Block 5
| What you see | What to do |
|---|---|
| No star in Gmail | In if_urgent: Ignore Case on, and the line comes from check_triage. In post_star: the parameter under Options, then Query Parameters. Did you publish WS2.3 again after the change? |
| The mail is not in WS2.3's runs | See block 3: the allowed address, the main address of your test account. |
| You are behind | Import n8n/ws2_3_triage_new_mail_solution.json. It gives the finished workflow WS2.3 - Triage New Mail - SOLUTION, with the rule. Check its credential in fetch_triage and pick WS2.4 in its node submit_to_reply_with_approval (block 3, steps 3 and 4). Unpublish your WS2.3 - Triage New Mail, then publish the solution. Never both: each new mail goes to only one of them. |
Block 6
| What you see | What to do |
|---|---|
| The approvals page shows "No draft waits" although WS2.4 waits | The page shows drafts with the status proposed. Open WS2.4, tab Executions: did the run reach wait_for_approval? |
Go deeper, in your own time
n8n's own courses are free and go further. Two that fit this morning, with a free account on learn.n8n.io:
- n8n Quickstart, part Working with data: how data
moves between nodes, expressions such as
$('get_mail').item.json.subject, and the three ways to handle an error. - In Practice: AI, Testing & Best Practices, section Testing & Debugging: Common Error Types and Pinning Data for Testing. The best tip there: pin the output of the last node that works, then Execute step.
Only if you use a coding agent to write the contracts
Not needed today. For your AI: this prompt, your exported flows and workflows, and our example contracts/flows.openapi.yaml:
We are building a mail AI assistant: n8n workflows call our Langflow flows over HTTP
(POST http://langflow:7860/api/v1/run/<endpoint>). I attach our flow files (Langflow export), our workflow files
(n8n export), and the contract of our course's flows as an example (flows.openapi.yaml).
Please write the contract between n8n and Langflow, the standard way:
1. One OpenAPI 3.1 file: for each flow endpoint, what n8n sends (the tweaks, by node id) and what comes back.
Write the JSON our flows return as a JSON Schema (required fields, types, allowed values).
2. A test in Python (pytest, jsonschema) that calls each endpoint with one example and checks the answer against
the schema.
3. A test that checks that our n8n workflows send what the file says.
Explain each step in simple words. Never write an API key into a file.