Parse order-confirmation emails into PostgreSQL
Reads order-confirmation email over IMAP, extracts the order reference, total, currency and line items from the HTML body by CSS selector, casts the types, and upserts the row into PostgreSQL on the o.
An IMAP trigger reads unseen mail. A Filter demands both a confirmation-shaped subject and an HTML body, so plain-text notifications never reach the parser. The HTML node extracts the order reference, total, currency and line-item names by CSS selector, and a Set node strips currency symbols, casts the total to a number and counts the items. An IF checks that a reference exists and the total is above zero; anything failing is inserted into an order_parse_failures table with its subject so selector drift is discoverable by SQL. Valid orders go through a parameterised INSERT … ON CONFLICT keyed on the order reference, so a re-sent confirmation updates the existing row rather than double-counting revenue. Both Postgres calls retry and route failures to an error rail that posts to Slack.
Key benefits
- ✓An orders table you can query, built from confirmations that arrive before any API is available
- ✓ON CONFLICT on the order reference means a forwarded or re-sent confirmation cannot double-count revenue
- ✓Types are cast before the write, so the schema never accepts a string where a number belongs
- ✓Parser drift surfaces as rows in a failures table rather than as a quietly shrinking revenue chart
- ✓All SQL uses bound parameters — email bodies never reach the query text
Use cases
- →Sellers on marketplaces that email confirmations but expose no order API
- →Finance teams re-keying order totals from email into a spreadsheet
- →Analytics teams that need an orders table before the ecommerce integration is built
- →Anyone reconciling payouts against orders and finding the counts disagree
Integrations
Workflow preview (9 nodes)
The template's actual node layout and connections. Node parameters and credential slots unlock with the download.
What's inside (9 nodes)
A look at the node types this workflow uses. No purchase required — full parameters and credentials are yours after you buy.
From download to running in 3 steps
- 1Import. In n8n, open Workflows → menu → “Import from File” and pick the downloaded JSON.
- 2Connect. Add your own credentials on the app nodes - n8n highlights exactly which ones need them.
- 3Activate. Run it once to test, then toggle Active. The automation is live.
What you'll learn
Production levelProduction-grade: idempotency, dead-letter handling, and reconciliation included.
- •Moving data between IMAP email, PostgreSQL and Slack in a single run
- •Adding retries and an explicit error path to external calls
- •Testing against pinned sample data before connecting anything real
Every node carries its own documentation on the canvas, plus notes explaining why the architecture was built this way, a credential setup guide, troubleshooting, and three practice exercises. Sample data comes pinned to the trigger, so you can hit Execute and watch data flow before connecting a single account.
Common questions
What exactly do I get?
The complete, ready-to-import n8n workflow as a JSON file, delivered instantly after payment. Import it into your own n8n (cloud or self-hosted), add your credentials, and it runs.
How do I import it into n8n?
In n8n, open Workflows, click the three-dot menu, choose “Import from File”, and select the downloaded JSON. Then connect your own app credentials on the highlighted nodes.
Do I need anything else for it to work?
You need your own n8n instance and accounts/credentials for the apps this workflow connects to (IMAP Email, PostgreSQL, Slack). No coding is required.
What if it doesn't work for me?
If the file is faulty, won't import, or isn't as described, contact us within 7 days and we'll fix it or refund you - see our refund policy.
Can I modify or resell it?
You can freely adapt and use it in your own or your clients' projects. Reselling or redistributing the template file itself is not permitted.
Related templates
Replicate records between tools for migration
Migration on n8n: runs on a schedule across Google Sheets, Slack, HubSpot, PostgreSQL and Telegram, starting at "Fetch Changes Since Watermark". 23 documented nodes.
Archive the database with Slack
Migration on n8n: runs on a schedule across Slack, Google Sheets, Google Drive, Notion, PostgreSQL and Discord, starting at "Export All Rows (Google Sheets)". 31 documented nodes.
Snapshot the database: Slack
Backups on n8n: runs on a schedule across Slack, PostgreSQL, Google Sheets and Google Drive, starting at "Fetch Changes (Google Drive)". Runs the custom logic in a Code node. 14 documented nodes.
Capture API callbacks for migration
Migration on n8n: runs when a webhook arrives across Slack and PostgreSQL, starting at "Map to Canonical Schema". Routes each kind of record down its own branch. 14 documented nodes.