Test email-to-spreadsheet extraction before connecting a real inbox

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

  1. Copy the workflow JSON below into a file named workflow.json and import it into your n8n editor. This example was run end to end on n8n 2.42.6.
  2. Keep it inactive. It starts manually and needs no credentials.
  3. Open Synthetic Emails to inspect the seven test messages. Do not replace them with personal or customer data just to try the example.
  4. Run the workflow with Execute Workflow.
  5. Open Extract and Validate and check the JSON output: two ready rows and five review rows.
  6. Open CSV Spreadsheet and download its binary data output, 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 review row. 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:

Workflow JSON

1 Like

:police_car_light: STOP RE-INVENTING EXPENSIVE PIPELINES. LET’S DEPLOY DETERMINISTIC STABILITY.

I noticed your open requirement for SME automation jobs just 1 minute ago. Most automated setups or email-to-spreadsheet parsers fail under production loads because they lack persistent deduplication, token-refresh handling, or validation gates before mutations occur. If your clients need 100% stable, fault-tolerant n8n architecture, let’s focus on system boundaries.

I am an India-based Senior AI Automation & Backend Infrastructure Architect specializing in transforming probabilistic workflows into crash-proof realities.

Here is my direct Proof of Work (No fluff, just metrics):
:one: High-Throughput Orchestration: I design self-hosted Docker clusters that seamlessly orchestrate and ingest over 1.2M+ daily external webhook payload vectors with ZERO data drops.
:two: Eradicating Database Race Conditions: To secure real-time relational data syncs (PostgreSQL/Supabase) and multi-step CRM mutations (HubSpot/GHL) under peak traffic, I deploy native Redis lock primitives (INCR + TTL gates) as atomic idempotency boundaries directly within the data transit paths.
:three: Pure Execution (No Framework Bloat): Expert in reverse-engineering complex data models, building rigid Pydantic/JSON validation schemas, and automated error-alerting flows straight from first principles.

:laptop: Audit the exact quality and complexity of my live production configurations right now:
:backhand_index_pointing_right: https://github.com

:high_voltage: THE ASYNC CHALLENGE: I function strictly as an async-first contractor. Let’s bypass lengthy scheduling loops and traditional interview panels. Drop an unresolved backlog task or a paid pilot workflow my way today, and I will deliver clean, merge-ready JSON configurations back to your account within 48 hours.

DM me directly via the forum console or shoot your requirements to: katreshital11@gmail.com