LA24AI

Automation & productivity

n8n: map the data before connecting nodes

Build an n8n AI extraction workflow that checks field types and the current item before any external action, with a visible review branch.

n8n: map the data before connecting nodes

Connected nodes still need a data contract

A connected n8n workflow can still pass invalid data. A field may arrive as text, a number or nothing. Define its expected shape and validate before invoking an external action. Inspect node output, not just successful execution indicators.

Keep zero distinct from missing

Use Manual Trigger and Edit Fields to create amount and currency, followed by an IF condition for a present, numeric, non-negative amount. Test zero, twelve, null and empty text. Zero can be valid; it must not disappear under a truthiness check. Route incomplete input to a visible review branch.

Worked examplecsv
amount,currency,expected
0,USD,accept
12,USD,accept
null,USD,review
-4,USD,review

Suggested validation cases, not an importable workflow.

Download example text ↓

Separate validation failures from execution errors

Rejected input differs from a network or node failure. Use error handling to record the failure and execution identifier instead of returning empty success. Add duplicate protection before sending mail or modifying files: restarting a workflow does not prove its earlier external action never happened.

Inspect the actual item at each node

For invoice extraction, pass one synthetic text item and ask the AI node for amount, currency and status. Inspect the node’s output data: is it an actual JSON object or a string requiring parsing? Do not use {{$json.amount}} until that field exists on the current item. Multiple items or a changed upstream structure can make an expression refer to something different from the sample you inspected.

Include zero, the string “12” and null as separate cases. Make numeric conversion an explicit policy and reject non-finite or negative values where the contract requires it. Before connecting email or a database, replace the final action with a preview of its proposed payload. Replay the same event and verify that its invoice identifier prevents a second insert. This tests the workflow’s behavior, not merely a plausible model response.

Sources & further reading

Sources support concepts and features; proposed trials are educational examples.

Prepared with AI assistance. Educational examples are not product tests; actual measurements identify their method and scope. Editorial approach ↗

NEXT

One idea leads to another

2 min read

A six-case invoice exercise separating syntactic JSON, schema conformance and factual agreement with the source document.

2 min read

Prevent repeated AI-automation side effects with stable event identifiers and retained outcomes, including the failure window between execution and acknowledgement.

2 min read

Turn uncertain AI outputs into a review queue with specific reasons, evidence and next actions, protecting decisions against concurrent or obsolete edits.