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
If something goes wrong
Still stuck? Ask Frank.
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. |