Log PDF invoice emails to a CSV ledger with IMAP and local files
Quick overview
Description
Quick overview This workflow reads invoice emails from an IMAP inbox, extracts text from PDF attachments, parses key invoice fields, and appends non-duplicate entries to a local CSV ledger file, with an optional run digest sent to Telegram. How it works Reads emails from an IMAP INBOX, marks them as read, and downloads attachments. Filters the message attachments to PDFs and creates one item per PDF with email metadata. Extracts the text layer from each PDF and parses invoice details such as supplier, invoice number, dates, currency, net/VAT/total amounts, and a totals consistency check. Reads the existing ledger CSV from disk and compares each parsed invoice against it to flag duplicates, possible duplicates, or items that need review. Rebuilds the ledger CSV by appending only non-duplicate invoices and writes the updated file back to the configured path. Generates a summary digest of counts and booked totals, and optionally sends it as a Telegram message. Setup Add an IMAP email credential to the IMAP Inbox node and ensure the mailbox to monitor is correct. Set an absolute writable path for ledgerPath in the Settings node (for example under ~/.n8n-files) and ensure the folder exists on the n8n host. Optionally set dateOrder and defaultCurrency in the Settings node to match your invoice formats. To enable notifications, add Telegram credentials, set chatId in Settings, and enable the Telegram digest node. Requirements Self-hosted n8n (the ledger is a file on your n8n host) One IMAP mailbox that receives PDF invoices PDF invoices with a text layer (scanned images go to review, no OCR) Optional: a Telegram bot for the run digest Customization Set dateOrder (auto, dmy or mdy) and defaultCurrency in the Settings node Change ledgerPath to keep one ledger per company or per year The parser is plain JavaScript in the Code nodes, so you can add or change fields without any AI prompt Additional info What you get when you buy: a pack of 11 templates that share one 22-column CSV ledger: inbox to ledger (this one), review queue, approval requests, approval callback, bank reconciliation, duplicate-payment alert, VAT quarter summary, currency normalisation, accounting export, monthly close pack and a nightly ledger snapshot. No AI model and no API key. Invoice text stays on your server. Three duplicate checks run before a row is written: supplier plus invoice number, a content hash for the same PDF sent again under a new name, and a 21-day same-amount check that only flags. Running the same mail twice leaves the ledger unchanged. What it does not do: no OCR, no write-back into Xero or QuickBooks (you get a CSV export), and no VAT return. An n8n automation workflow template by Invoice Ledger.
Community Metrics
Author
Invoice Ledger
Platform
web
Pricing model
paid
Categories
- Automation
Tags
- n8n
- workflow
- telegram
- code
Capabilities
- 2 nodes