Karte 06 · Kapitel tools
Pipelines with decisions and error handling
🟢 USE — Run first
0 - 15 min
Watch the pipeline decide — and recover from failure
This workflow checks whether your message contains a PubMed ID, routes accordingly, and handles HTTP errors gracefully. You will trigger all three paths intentionally.
- Go to Downloads (curriculum.32dots.de/share) and download 'Session 6 — Decisions and error handling'.
- In n8n: ⋯ → Import from file. Open the chat panel.
- Type: 'Summarise paper 38167000' (a valid PMID).
- Watch the execution log — which path fired? Which nodes are highlighted green?
- Type: 'What is the latest in cancer immunotherapy?' (no PMID — false path fires).
- Type: 'Summarise 99999999' (non-existent PMID — HTTP error path fires).
- In the execution log, click the 'Fetch Paper' node. Find the error output connector highlighted in red.
Done-Signal: You triggered all three execution paths and can identify which node and branch fired in each case.
🔵 UNDERSTAND — Look inside
15 - 60 min
IF nodes, error outputs, and Continue on error
Open the workflow canvas and trace the three paths. The key insight: validation and error handling are separate concerns — one is about expected variation, the other about unexpected failure.
🔍 Extract PMID
Code node — regex validation
Regex checks for a 7-8 digit number in the message. Returns hasPmid: true/false. JavaScript: msg.match(/\b(\d{7,8})\b/). This is deterministic validation — faster and cheaper than asking an AI.
❓ Has PMID?
IF node
Branches on hasPmid: true → fetch paper, false → guide message. The false branch sends a helpful instruction instead of failing silently.
🌐 Fetch Paper
HTTP Request with Continue on error
Fetches the PubMed abstract. The key setting: 'Continue on error' is enabled, exposing a second output connector. Success goes to AI; error goes to error handler. Without this, a 404 crashes the whole workflow.
📋 Prep for AI / HTTP Error / No PMID Guide
Set nodes — consistent output
All three paths produce a Set node output. This normalises the shape so any downstream processing can assume a predictable structure, regardless of which path executed.
🧠 AI Summarize
AI Agent (typeVersion 1.7)
Only runs on the success path. Receives the abstract and summarises: research question, method, key finding, limitation.
A production workflow never receives only valid inputs. Design for failure first, happy path second. The IF node handles expected variation (has PMID or not). The error output handles unexpected failures (PubMed returns 404). These are different — don't conflate them.
Probe-Fragen
- What is the difference between an IF node and 'Continue on error'? Give one scenario where you'd use each.
- What happens if you disable 'Continue on error' on Fetch Paper and send PMID 99999999?
- How would you log every error to a Postgres database automatically?
🟠 BUILD — Make it yours
60 - 90 min
Add error counting and logging
Extend the workflow to track how many requests succeed and how many fail.
Aufgabe: Add a logging mechanism: after each run, write to an n8n variable or a Set node that counts successes and failures in the session.
- After the AI Summarize node, add a Set node: result = 'success', pmid = $json.pmid.
- After the HTTP Error node, update it to also set: result = 'error'.
- After the No PMID Guide node, update it: result = 'no_pmid'.
- Add a final Set node that merges all paths (use the Merge node or accept that only one path fires per run).
- Test with three different inputs — valid PMID, bad PMID, no PMID. Confirm the result field is set correctly in all three cases.
- Add a Sticky Note documenting: what each path produces and when.
Deliverable: Export the workflow and share a screenshot of the execution log showing all three paths tested in sequence.
✓ SELF-CHECK
Hast du das verstanden?
- I can enable 'Continue on error' and connect both the success and error outputs.
- I understand the difference between IF-based validation and error output handling.
- My workflow produces a consistent output structure across all three paths.
Your workflow now handles three cases explicitly. But what about rate limits (HTTP 429) vs. not-found (HTTP 404)? They both trigger the error path. How would you distinguish them and handle each differently?
💬 KI-TUTOR
Frag den Tutor zu dieser Karte
Sokratisch: der Tutor antwortet mit Leitfragen statt fertigen Antworten — du erarbeitest die Lösung selbst.
Stell eine erste Frage zu dieser Karte unten.