This small workflow takes seven synthetic email bodies, extracts four labeled fields, validates them, and creates a CSV you can open in a spreadsheet. It has no inbox connection, credentials, paid API calls, or AI-model dependency.
I prefer to test the failures before connecting company systems. A small parser is enough when the input format is fixed. An AI step would add cost and uncertainty here without fixing the basic validation problem.
What this example does
Manual Trigger → Synthetic Emails → Extract and Validate → CSV Spreadsheet
The messages use this format:
Customer: Demo One
Email: one@example.invalid
Order: ORD-0001
Quantity: 2
All addresses and orders are synthetic. The .invalid domain is deliberately not a real mailbox. The workflow never sends email.
The output has message_id, customer, email, order_id, quantity, status, and reason. Every input gets one row. ready means the row passed this demo’s checks, not that it is approved for a payment, shipment, or any other action. A review row contains its message ID and reason, with the extracted fields left blank.
Import and run
- Copy the workflow JSON below into a file named
workflow.jsonand import it into your n8n editor. This example was run end to end on n8n 2.42.6. - Keep it inactive. It starts manually and needs no credentials.
- Open Synthetic Emails to inspect the seven test messages. Do not replace them with personal or customer data just to try the example.
- Run the workflow with Execute Workflow.
- Open Extract and Validate and check the JSON output: two
readyrows and fivereviewrows. - Open CSV Spreadsheet and download its binary
dataoutput,synthetic-orders.csv. Open it in a spreadsheet and check that it has seven rows plus the header. The Code nodes use Run Once for All Items; keep that mode so the duplicate check sees the whole batch.
For a local n8n installation, the same workflow can be imported and run with the CLI:
n8n import:workflow --input workflow.json
n8n export:workflow --all --output imported-workflows.json
# Read the imported workflow's ID, then:
n8n execute --id YOUR_WORKFLOW_ID --rawOutput
The downloadable export contains no credentials. This is a CSV-file demonstration, not a tested Google Sheets integration or a live email trigger.
Five failure cases, with actual results
| Input | Result | Reason |
|---|---|---|
| Missing Quantity | review | missing_or_repeated_quantity |
Quantity is two |
review | invalid_quantity |
| Order repeats an earlier valid order | review | duplicate_order_in_batch |
| Two Quantity lines | review | missing_or_repeated_quantity |
Customer begins with =1+1 |
review | formula_like_customer |
The two ordinary examples produced the expected customer, email, order and quantity fields. The full n8n run finished successfully and created the CSV. This is a seven-case functional check, not a production benchmark, accuracy claim, or security audit.
Why these checks come before an AI step
The parser requires exactly one nonempty line for each field. Email gets a basic format check. Order must match ORD- plus four digits. Quantity must be an integer from 1 to 999. These are demo rules, not general business rules.
Duplicate detection only covers the current execution. It uses a new Set each run. Rerunning the same export can produce the same rows again. A real append-to-sheet workflow needs persistent deduplication and an idempotency key before writing.
The formula-like customer is held for review instead of copied into the CSV. CSV quoting alone does not stop spreadsheet formulas. This narrow check catches a leading =, +, @, or - after whitespace. It is not a complete spreadsheet-injection defense for arbitrary untrusted text. If you expand the schema, assess each new text field and the destination spreadsheet’s import behavior.
What to change before using it for real
- Review the original message for every
reviewrow. Nothing in this example automatically resolves it. - Keep a person checking outputs until the risks and failure rate are understood.
- Add persistent duplicate checks, retry handling and logging before connecting a live destination.
- Keep free-form message text out of cells until you have a tested policy for handling it.
- Get permission for the data and check who owns failures, access and deletion.
- If you later add an AI extractor, test it separately on messy messages and keep these validation gates after it. This workflow has not tested any model.
Disclosure: I run WithAvi. The linked article explains the small-pilot approach behind this example; the workflow and results above are self-contained. There are no affiliate links in this tutorial.
References:
