Skip to main content

Process sales CSVs into invoices with data tables and email notifications

Workflow preview

Workflow preview
100%
Process sales CSVs into invoices with data tables and email notifications preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Smart Sales Invoice Processor (Data tables Edition) Transform uploaded sales CSV files into validated, enriched invoices, all handled natively inside n8n using Data tables , validation logic, en...

Best for

  • Invoice Processing automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.webhook, n8n-nodes-base.if, n8n-nodes-base.extractfromfile, n8n-nodes-base.code, n8n-nodes-base.respondtowebhook, n8n-nodes-base.datatable, n8n-nodes-base.aggregate

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Patrick Siewert.

Original n8n.io source

1.1 Workflow description

Title
Process sales CSVs into invoices with data tables and email notifications
Workflow name
Process sales CSVs into invoices with data tables and email notifications

🧾 Smart Sales Invoice Processor (Data tables Edition)

Transform uploaded sales CSV files into validated, enriched invoices, all handled natively inside n8n using Data tables, validation logic, enrichment, duplicate detection, and automated email notifications.

This workflow demonstrates a full ETL + business automation pattern, turning raw CSV data into structured, auditable records ready for storage and customer notifications.


✨ Features

  • ✅ Multi-format CSV input (file upload or raw text)
  • ✅ Validation for email, quantity, date, and required fields
  • ✅ Automatic error handling with 400 Bad Request JSON response for invalid CSVs
  • ✅ Product enrichment from Products Datatable
  • ✅ Invoice creation and storage in Invoices Datatable
  • ✅ Automated subtotal, tax, and total calculation
  • ✅ Duplicate order detection with 409 Conflict response
  • ✅ Ready-to-send email confirmations (simulated in this version)
  • ✅ Fully native, no external integrations required

🧩 Use Cases

  • E-commerce order and invoice automation
  • Internal accounting or ERP data ingestion
  • Migrating CSV-based legacy systems into n8n
  • Automated business logic for B2B integrations

⚙️ Setup Instructions

1️⃣ Create two n8n Data tables

Products

Stores your product catalog with SKU-based pricing and tax details.

Column Type Example
sku String PROD-001
name String Premium Widget
price Number 49.99
tax_rate Number 0.10


Invoices

Stores validated, calculated invoices created by this workflow.

Column Type Example
invoice_id String INV-20251103-001
customer_email String [email protected]
order_date Date 2025-01-15
subtotal Number 99.98
total_tax Number 10.00
grand_total Number 109.98
created_at DateTime 2025-11-03T08:00:00Z


2️⃣ Import Workflow

Import the provided workflow JSON file into your n8n instance.

3️⃣ Test the Workflow

Use cURL or Postman to send a test CSV to your endpoint.

curl -X POST \
  -H "Content-Type: text/csv" \
  --data-binary $'sku,quantity,customer_email,order_date\nPROD-001,2,[email protected],2025-01-15\nPROD-002,1,[email protected],2025-01-15' \
  https://<your-n8n-url>/webhook/process-sales
📦 Example Responses
✅ Success (HTTP 200)
{
  "success": true,
  "processed_at": "2025-11-04T15:36:52.899Z",
  "invoice_count": 1,
  "invoices": {
    "to": "[email protected]",
    "subject": "Invoice INV-1762270612772-1 - Order Confirmation",
    "body": "Dear Customer,\n\nThank you for your order!\n\nInvoice ID: INV-1762270612772-1\nOrder Date: 1/14/2025\n\nSubtotal: $99.98\nTax: $10.00\nGrand Total: $109.98\n\nThank you for your business!\n\nBest regards,\nSales Team"
  },
  "email_notifications": [
    {
      "to": "[email protected]",
      "subject": "Invoice INV-1762270612772-2 - Order Confirmation",
      "body": "Dear Customer,\n\nThank you for your order!\n\nInvoice ID: INV-1762270612772-2\nOrder Date: 1/14/2025\n\nSubtotal: $89.99\nTax: $9.00\nGrand Total: $98.99\n\nThank you for your business!\n\nBest regards,\nSales Team"
    }
  ],
  "message": "All invoices processed and customers notified"
}
❌ Validation Error (HTTP 400)

Occurs when the CSV file is missing required columns or contains invalid data.

{
  "success": false,
  "message": "CSV validation failed",
  "error": "Validation failed: [ { \"row\": 2, \"errors\": [\"Valid email is required\"] } ]"
}

🧠 How It Works

  1. Webhook receives uploaded CSV or raw text
  2. Code node parses and validates data
  3. Data table node loads product info (price, tax rate)
  4. Calculation node generates invoice totals per customer
  5. Duplicate check prevents reprocessing
  6. Data table insert saves invoices
  7. Email preparation creates personalized confirmations
  8. Webhook response returns structured JSON (200 / 400 / 409)

🔐 Requirements

  • n8n version ≥ 1.41.0
  • Data tables feature enabled
  • Publicly accessible webhook URL (for testing)
  • (Optional) Connect a real email node (Gmail or SMTP) to send messages

🏁 Result Highlights

  • Full CSV → Validation → Data tables → Email → JSON Response pipeline
  • Includes built-in structured error handling (400 / 409)
  • 100% native n8n functionality
  • Perfect example of Data tables + logic-based automation for business use cases

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Documentation

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Receive Sales CSV

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 3 - Check Upload Type

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 4 - Extract CSV Text

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 5 - Parse & Validate CSV

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Enrich with Product Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - Calculate Invoice Totals

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 8 - Check for Duplicates

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - Has Valid Invoices?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 10 - Prepare Email Notifications

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 11 - Email Info

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Merge Results

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 13 - Return Success Response

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 14 - Return Duplicate Error

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 15 - Load Product Catalog

Type / Role
n8n-nodes-base.dataTable - dataTable
Config choices
Version 1

Block 16 - Insert row

Type / Role
n8n-nodes-base.dataTable - dataTable
Config choices
Version 1

Block 17 - Aggregate

Type / Role
n8n-nodes-base.aggregate - aggregate
Config choices
Version 1

Block 18 - Email Output Preview

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Extract from File

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 20 - Return Validation Error

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 21 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Process sales CSVs into invoices with data tables and email notifications
Complexity advanced
Nodes 21
Categories Invoice Processing
Author Patrick Siewert
Published 29 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/10274/10274.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Process sales CSVs into invoices with data tables and email notifications do?

Smart Sales Invoice Processor (Data tables Edition) Transform uploaded sales CSV files into validated, enriched invoices, all handled natively inside n8n using Data tables , validation logic, en...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Invoice Processing use case.