Invoices that file themselves: our own invoice flow in n8n
How Kuveco scans paper invoices and lets an n8n flow do the rest: read the text, pick out the supplier and date, rename the file and archive it.
We still get some invoices on paper too. Scanning them takes no time. The annoying part comes after: the file is called something like scan_0047.pdf, and before you know it there's a folder full of scans and nobody remembers which invoice is which.
So we leave that to a small flow in n8n. We scan the invoice, and within half an hour it sits in the right folder, under a name that tells you who it's from and when.
From paper to folder in five steps
- The printer scans the invoice and emails the PDF to our mailbox.
- Every half hour, n8n checks for a new scan.
- Tesseract turns the scan into plain text.
- A language model, Google's Gemini Flash, reads the supplier, the invoice number and the date from that text.
- The file gets a new name and moves to the folder for processed invoices. A Telegram message tells us it worked.
The scan arrives by email
Our Epson printer can email a scan directly. That is all the connection to the printer there is. In n8n, the flow starts with a Gmail Trigger that checks for new mail every thirty minutes, but only from the address the printer sends its scans from. It leaves all other mail alone, and downloads the attachment straight away.
First, the flow checks whether it has seen this scan before. It searches the scans folder in Google Drive for a file with the same name. If there is one, it stops and sends a short message saying the invoice was already processed. If not, it saves the scan to that folder and carries on.
Text first, then the language model
A scan is an image, and a computer can't search an image. Tesseract is a free, open-source program for text recognition (OCR) that runs in n8n through an extra node. It turns the scan into plain text, with all the mess that comes with it: columns that run into each other, a logo that comes back as a string of odd characters.
Only that text goes to the language model. For that we use n8n's Information Extractor node with Gemini Flash. You tell the node in plain words which fields you're looking for, and the model fills them in. We ask for three:
- the supplier, described as the name of the company issuing the invoice, "often at the top, sometimes in capitals";
- the invoice number, recognisable by the word "invoice" or "factuur";
- the invoice date, recognisable by "invoice date" or "datum".
All three are required fields: the model always has to fill them in. A language model is good at this because every invoice looks different. Fixed rules ("the number is always top right") won't get you far; a language model understands that "Factuurnr." and "Invoice no." mean the same thing.
A name you can find again
From the supplier and the date, the flow builds a new file name: the supplier's name, an underscore and the date in digits. Dates on invoices come in every possible format, so a bit of code first turns Dutch and English month names into numbers ("November" becomes 11) and then keeps only the digits.
The flow then makes a copy of the scan under the new name and moves that copy to the folder for processed invoices. The original scan stays in the scans folder, so if something goes wrong with the name, nothing is lost.
As a last step, the flow posts a Telegram message with the new file name and the invoice date. You read a message like that in a few seconds. If the model ever reads a name wrong, we see it straight away on our phone, not weeks later in the books.
What the flow doesn't do
It doesn't book anything and it doesn't pay anything. All it does is make sure every paper invoice ends up in the same place digitally, under a name you can find. Invoices that already arrive in digital form, for example as e-invoices through Peppol, don't go through this flow; they're readable without a scan.
The tools at a glance
| Part | Tool | What it does |
|---|---|---|
| Scanning | Epson printer with scan to email | Emails the PDF to our mailbox. |
| Mailbox | Gmail, with n8n's Gmail Trigger | Supplies new scans every thirty minutes. |
| Text recognition | Tesseract (OCR), as an extra n8n node | Turns the scan into text. |
| Reading | Gemini Flash (Google), in the Information Extractor node | Pulls the supplier, invoice number and date from the text. |
| Archive | Google Drive | Keeps the original scan and the renamed copy. |
| Alerts | Telegram | Confirms each invoice and flags duplicate scans. |
Is this something for your business?
It's a small flow, fourteen nodes, and it uses things a lot of small businesses already have: a printer that can scan, a mailbox and somewhere in the cloud to keep files. If paper invoices still land on your desk regularly, or you spend too much time searching a folder full of files called scan_, this is a good first automation.