Karte 04 · Kapitel getting-started
AI that routes and transforms
🟢 USE — Run first
0 - 15 min
Send text — watch it get routed and transformed
This workflow reads your message, detects whether you want a summary or key-fact extraction, and routes it to the right AI pipeline. Two different AI agents, one decision node.
- Go to Downloads (curriculum.32dots.de/share) and download 'Session 4 — AI that routes and transforms'.
- In n8n: ⋯ → Import from file. Open the chat panel.
- Type: 'Summarize this: The gut microbiome plays a crucial role in immune system regulation through multiple mechanisms including...' (paste any abstract).
- Note the response format: 3-5 sentences.
- Now type: 'Extract key facts from: [same text]'.
- Note the response format: numbered list.
- Try with 'bullet points' or 'list' in your message — these also trigger the extract route.
Done-Signal: You see two clearly different response formats from the same underlying text, triggered by keywords in your message.
🔵 UNDERSTAND — Look inside
15 - 60 min
Routing with Code node and IF node
Open the workflow canvas. The routing decision is made by a Code node, then enforced by an IF node — not an AI. This is intentional: routing is too important to delegate to a model.
💬 When chat message received
Chat Trigger
Opens the chat. Passes chatInput (your message) and sessionId to downstream nodes.
🔀 Router
Code node — keyword detection
Pure JavaScript. Checks if the message contains 'extract', 'key fact', 'bullet', or 'list'. Sets route = 'extract' or 'summarize'. No AI involved — this is deliberate. Routing must be predictable.
❓ Summarize or Extract?
IF node
Checks if route === 'summarize'. True branch runs the summarize AI; false branch runs the extract AI. Clean binary split.
📝 Build Summarize Prompt / Build Extract Prompt
Set nodes
Construct the full prompt for each branch. The summarize prompt asks for 3-5 sentences; the extract prompt asks for a numbered list. Same input, different instructions.
🧠 AI Summarize / AI Extract
AI Agents (typeVersion 1.7)
Separate agents with separate memory and model nodes. Each agent has its own session context — conversation history on the summarize branch does not cross into the extract branch.
Use deterministic code for routing decisions. If you let an AI decide the route, you lose predictability — models change, prompts drift, and users get inconsistent results. Keyword detection in a Code node never has an off day.
Probe-Fragen
- What happens if someone types 'extract a summary'? Which branch fires? Why?
- Why does each branch have its own Memory node? What would break if they shared one?
- How would you add a third branch: 'translate this to German'?
🟠 BUILD — Make it yours
60 - 90 min
Add a third route
Extend the router with a new keyword and a new AI transformation.
Aufgabe: Add a 'translate' route: if the message contains 'translate' or 'auf Deutsch', route to a third AI agent that translates the text to German.
- In the Router Code node, add a new condition: if lower.includes('translate') or lower.includes('auf deutsch'), set route = 'translate'.
- The IF node only handles summarize/extract. Change it: true = summarize, false continues to a second IF node that checks route === 'extract'. False from that = translate.
- Add a Build Translate Prompt node: 'Translate the following text to German: ' + userMessage.
- Add an AI Translate agent with its own Groq and Memory nodes.
- Test all three routes with the same input text.
Deliverable: Export the extended workflow JSON and share with a screenshot showing three different outputs from the same input text on three different routes.
✓ SELF-CHECK
Hast du das verstanden?
- I understand why routing is done in Code, not AI.
- I can explain the difference between the IF node's true and false outputs.
- I added a third route and tested it correctly.
Keyword routing is brittle — 'please give me a summary in bullet form' would route to extract (because of 'bullet'). How would you make this more robust without introducing an AI classifier?
💬 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.