Workbook, 9 November

On this page

First, three checks:

  1. kingo-pod runs. In the terminal, in your kingo-pod folder, run ./kingo up. Then open n8n in your browser: http://localhost:5678.
  2. Your test Gmail account is open in another browser tab.
  3. You downloaded ws2_s1.zip and unzipped it (double-click it). In the folder ws2_s1:
    • ws2_s1_workbook.html: this page
    • today's slides, as HTML and as PDF
    • two CSV files for the data tables
    • the folder n8n with 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

  1. In n8n, click Overview at the top left, then the tab Data tables in the middle of the page.

  2. Click Create data table.

  3. Data table name: paste this name.

    THE NAMES ARE IMPORTANT BECAUSE YOUR SOLUTION FILES LOOK FOR EXACTLY THESE NAMES.

    WS2.1 - TEST - Triage - Cases
    
  4. Pick Import CSV. Drop the file ws2_1_test_triage_cases.csv from your folder ws2_s1 into the box, or click the box and pick it.

  5. Turn on My CSV file contains a header row: the first line of the file holds the names of the columns.

  6. n8n shows the columns it found, with their types. Leave them as they are. Click Create.

  7. 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.

  1. Click Create workflow. Click its name at the top and give it this name:

    WS2.1 - TEST - Triage
    
  2. 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.

  3. 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 - Cases
    

    Turn Return All on.

    Click Execute step: on the right, five items.

  4. 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=false
    

    For 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, Value text. The third: Name output_type, Value text.

    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_value is the mail, from the column mail of 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.

  5. 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 answer with Triage's fields: action, why, checks_ok and more.

    What it does

    Langflow answers with one object. outputs[0].outputs[0] is the flow's first output, and results.text.text its 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.

  6. 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 column id, Equals, and paste this value:

    {{ $('get_cases').item.json.id }}
    
    What it does

    $('get_cases') is the node get_cases. .item is its item that belongs to this one: the same test mail. .json.id is that mail's column id. So each action goes into the row of its own test mail.

    n8n writes the same when you drag the field id of get_cases from the left into the box.

    Under Values to update, fill the column action: on the left, open answer and drag its field action into the box. n8n writes this:

    {{ $json.answer.action }}
    
  7. Click Execute workflow.

  8. 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.

  9. Tidy up:

    • Give the workflow the tags WS2, mail case and 9 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:

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:

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.

  1. Import these three workflows from the folder n8n:

    • ws2_4_reply_with_approval.json
    • ws2_4_approvals_page.json
    • ws2_3_triage_new_mail.json
  2. Check the credentials in WS2.4. n8n should pick them by their name, but check:

    1. Open WS2.4 - Reply with Approval.
    2. Double-click the node fetch_flow_list. Under Header Auth, it should say Langflow (Run API). Another one, or none? Pick Langflow (Run API). Close the node with the ✕ at the top right.
    3. Do the same in the nodes fetch_draft_reply_flow and fetch_draft_reply.
    4. 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.

  3. Check the credential in WS2.3:

    1. Open WS2.3 - Triage New Mail.
    2. Double-click the node fetch_triage. Under Header Auth, it should say Langflow (Run API). If not, pick it. Close the node.
  4. Connect WS2.3 to WS2.4:

    1. Still in WS2.3, double-click the node submit_to_reply_with_approval.
    2. In the field Workflow, pick WS2.4 - Reply with Approval.
    3. Save.
  5. 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 ✕.

    1. WS2.4 - Reply with Approval
    2. WS2.4 - Approvals Page
    3. WS2.3 - Triage New Mail
  6. Open the approvals page in a new browser tab, at this address. It says "No draft waits".

    http://localhost:5678/webhook/approvals
    

    The address is in WS2.4 - Approvals Page too: double-click its node webhook_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.

  7. From your SKKU account, send this mail to your test Gmail account:

    The subject:

    Steve's address
    

    The text:

    Dear Vince, what is Steve Leppard's email address? I need to reach him.
    
  8. 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.

  9. 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.

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
  1. Import n8n/ws2_1_test_triage_improved.json from the folder n8n. It gives WS2.1 - TEST - Triage - Improved.

  2. Check its credential: double-click the node fetch_flow. Under Header Auth, it should say Langflow (Run API). If not, pick it. Close the node, then save.

  3. Before you run it, look at its nodes. Double-click each one:

    Node What it does
    trigger_manual starts it when you click Execute workflow
    webhook_open_runs starts it from its page in your browser: opening the page shows the dashboard, its button runs the test
    set_test_settings the 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_requested what the page's form sent, over the settings; a test runs only after a click on Run the test, or Execute workflow
    get_cases the five test mails from Cases, as in your WS2.1
    transform_into_rounds each test mail once per round: 15 items
    fetch_flow the 15 mails to your Triage flow, five at a time
    set_answer Triage's answer as fields, as in your WS2.1
    set_score each action next to the expected one: the score of each round, the seconds, every answer
    post_run_to_runs one line into Runs
    get_runs, transform_runs_into_dashboard every line of Runs as a dashboard
    format_dashboard_as_html, send_dashboard_page the 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.

  4. Run it once here, in n8n:

    1. Click the small arrow next to Execute workflow and pick trigger_manual.
    2. Click Execute workflow.
    3. 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.

  5. Open the dashboard as a page, to keep next to Langflow:

    1. Click Publish at the top, then Publish again in the window. The page works only while the workflow is published.

    2. Open this address in a new browser tab:

      http://localhost:5678/webhook/triage-runs
      
    3. 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.

  6. 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.
  7. In Cases, read the mails it got wrong, in the column mail. Why would the model choose that?

  8. In Langflow, open Triage (Enron), then the node Prompt Template. Change how the actions are described. Only the prompt. Save.

  9. 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.

  1. Write your test cases. Open ws2_1_test_triage_cases.csv in 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 case
    • subject: a short title
    • mail: what your flow gets, the text you would type into its Playground
    • expected: what it should answer
    • action: leave it empty

    Save it as CSV, with a new name.

  2. 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 file
    • Blue - TEST - Intake - Runs, from ws2_1_test_triage_runs.csv
  3. 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 example Blue - TEST - Intake.

  4. In the copy, pick your tables: double-click get_cases and pick your Cases table in the field Data table. Do the same in post_run_to_runs and get_runs, with your Runs table.

  5. Give the page an address of its own: double-click webhook_open_runs and change Path, for example to blue-intake-runs. Two published workflows cannot share a path.

  6. Double-click set_test_settings and 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 with expected, for example action. Does it answer with text? Then leave it empty: a case counts as right when the answer contains expected.
    • rounds: how often each case goes to the flow.

    The page's form can change all three for one run.

  7. Click Publish. Open your page, for example http://localhost:5678/webhook/blue-intake-runs, and click Run the test.

Block 5 · Let's look inside WS2.3, and make it ours

Look inside WS2.3

  1. Open WS2.3 - Triage New Mail, then the tab Executions at the top: one line per run.

  2. 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_notify PostgresDB tells n8n at once: a new mail is here
    schedule_every_15_minutes looks every 15 minutes too, in case that message got lost
    Take it once fetch_and_claim_new_mails notes each new mail as taken, in the table processed; a mail already there is skipped, so no mail gets two answers
    Protect format_mail_as_text the mail as one text: sender, date, subject, body
    transform_mask_personal_numbers masks card and bank numbers before any model sees the mail
    check_injection a model asks: does the mail try to give the assistant orders? If so, a person looks at it
    Ask Triage fetch_triage sends the mail to your Langflow flow Triage and gets its answer
    check_triage n8n goes on only with an answer in order: checks_ok is true, and the action is one of the four. Anything else: a person looks at it
    Act post_result writes Triage's answer into processed, next to the mail
    if_confidential the fixed rule: a mail marked confidential only gets its label, whatever Triage proposed
    switch_by_action one 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_notify listens 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_minutes takes the mail a little later. Either way, fetch_and_claim_new_mails takes each mail only once.

Your own rule: an urgent mail gets a star

A mail whose subject says "urgent" gets a star in Gmail.

  1. Go back to the tab Editor.

  2. 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 it if_urgent. Set it like this:

    Paste this as the value on the left:

    {{ $json.subject }}
    

    Choose String, then contains, and type urgent on the right. Under Options, turn Ignore Case on.

  3. 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_star writes one row into the table changes. 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. NULL means: no label.

    In place of 'star', NULL What Gmail shows
    'star', NULL a star
    'unstar', NULL the star taken off
    'read', NULL the mail as read
    'unread', NULL the mail as unread, in bold
    'label', 'Urgent' the label Assistant/Urgent
    'unlabel', 'Urgent' that label taken off
    'archive', NULL the mail out of the inbox; it stays in All Mail
    'inbox', NULL the 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 status failed and the reason in the column error.

  4. Click Publish again: n8n runs only the published version.

  5. 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.

  1. Open WS2.4 - Reply with Approval, then the tab Executions.

  2. Click the run of your mail from block 3.

  3. Double-click the nodes, one after the other:

    Node What it does
    get_mail, if_draft_given the mail from the database; a workflow that calls WS2.4 may bring its own draft
    format_mail_as_text, transform_mask_personal_numbers the mail as text, personal numbers masked
    fetch_flow_list, fetch_draft_reply_flow, set_draft_reply_ids Langflow 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_reply the 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_fine a draft, and someone to send it to; Draft Reply's verdict goes onto the approval form
    post_proposal_to_outbox a row in outbox, status proposed
    wait_for_approval the form, with the draft in a field to edit; the run waits for you
    post_approve, post_reject your 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.

  1. Keep the approvals page's list of runs short:

    1. Open WS2.4 - Approvals Page.
    2. Open the menu … at the top, next to its name, then Settings.
    3. 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 node webhook_open_approvals, Webhook URLs, then Test URL. n8n keeps the runs you start by hand.

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.
Agentic AI in Business · Workshop II · Frank Huettner · SKK GSB.