Automate Monthly Financial Reports with Local LLMs and n8n
To automate a monthly financial report with n8n and a local LLM, schedule a workflow on the first of each month that pulls the prior month's transactions from your accounting tool, runs them through deterministic categorisation, asks a local LLM to write the narrative summary against the numbers, renders the result to PDF, and emails it to the recipients. The numbers come from code. The prose comes from the model. The two never mix.
The split that matters
An LLM doing arithmetic is a liability. An LLM doing prose against arithmetic that already happened is a productivity tool. Keep the spreadsheet logic in code and the model in the writing layer. Every report I have ever shipped that crossed this line ended up with a number wrong.
The Sunday I gave up on writing reports by hand
January 2024, a Sunday afternoon. I was on hour three of writing the December report for a tiny consultancy I run on the side. Twelve clients, maybe 90 invoices, nothing complicated. I had the spreadsheet open, the prior month's report open as a template, and a slow growing certainty that I was the wrong person to be doing this. Total active brain time on the actual analysis: maybe twenty minutes. Total clock time: three and a half hours. The rest was reformatting, copy-pasting numbers, and rewriting the same three sentences about which client moved up and which moved down. The workflow described in this article took me a weekend to build. I have not written a monthly report by hand since.
The opinion
Sending financial figures to a cloud LLM is fine for small businesses if your vendor has a no-training data agreement, but a local LLM is cleaner and removes the entire category of "did the vendor change their terms again" risk. The mechanism: the data never moves. The cost of being wrong is the day your accountant finds out the previous month's P&L went through someone else's training pipeline. Hold this loosely if your finance data is already in a public-cloud accounting tool; the local LLM does not save you from the existing footprint.
The workflow, end to end
- Schedule trigger — first day of each month at 06:00.
- Fetch transactions — HTTP Request node hitting your accounting tool's API (Xero, QuickBooks, FreshBooks, or a Postgres query if you self-host).
- Deterministic aggregation — a Code node in plain JavaScript that buckets revenue by client, expenses by category, computes margin, month-over-month delta, and rolling three-month average.
- Local LLM narrative — Ollama with Llama 3.1 8B. Pass the JSON of aggregated numbers and ask for a three-paragraph executive summary. Tight prompt: do not invent numbers, refer to the JSON for every figure.
- PDF render — a Code node using a small HTML template, then a PDF service (Gotenberg self-hosted, or a single Puppeteer call) to convert HTML to PDF.
- Email send — SMTP node or Resend node with the PDF attached and a one-line cover message.
The prompt that does not hallucinate
The single instruction that did the most work: "Refer only to the values in DATA. If a value is not present, do not mention it. Do not perform arithmetic. Quote numbers exactly as provided." Adding those three sentences took the made-up-number rate from roughly once every six runs to zero across the last fourteen months of monthly runs I have data for.
What this saves
My own measurement: three and a half hours of clock time replaced by twelve minutes of review. Across twelve months that is 42 hours back. At any reasonable hourly rate for a person who builds AI pipelines, the build paid for itself in about three weeks. Your numbers will differ; the shape will not.
The review step you cannot skip
The workflow generates the PDF as a draft and emails it to me, not to the clients. I skim it, mostly for tone and for any sentence that smells off. Three months in, I added a second eye: my partner reads it before send. We have caught two awkward phrasings in fourteen months. The model writes the boring 90%. A human still owns the send button.
How this differs from the popular Gemini and GPT-4 templates
The official n8n template gallery has workflow #3617 ("Generate monthly financial reports with Gemini AI, SQL, and Outlook") and the marjaanah-stack repo on GitHub publishes an AI-Powered Financial Report Generator built on GPT-4 with Slack delivery on a 30-day schedule. Both are excellent starting points if you are happy sending raw P&L numbers to a vendor. The version I described above swaps Gemini and GPT-4 for a local Llama 3.1 8B or Qwen 2.5, which keeps the figures inside your network at the price of a slightly more verbose prompt. Same SQL extraction, same HTML email, same scheduling. The trade-off is real: cloud models write tighter narrative prose; local models keep your finance director's blood pressure lower.
Frequently asked questions
Can I do this if I do not run a server?
Yes. n8n Cloud plus a hosted LLM (OpenAI, Anthropic, or Groq) works the same way. You give up the local-only privacy story but gain a setup that takes an evening instead of a weekend.
What if my accounting tool has no API?
Then the first step is a CSV export, dropped into a watched folder, picked up by n8n's local file trigger. Less elegant, still automated.
Will the model get the categorisation wrong?
The categorisation does not go through the model. The deterministic aggregation step uses your existing chart of accounts and your existing rules. The model only writes prose about already-bucketed numbers. This is the whole point of the split.
How do I version control the prompt?
Keep the prompt in a file in a git repo and have n8n read it at run time, either by fetching from a raw GitHub URL or by syncing the file to disk. When the prompt changes, you have a diff. When the report changes, you can blame the commit.
What about year-end reports?
Same workflow, different schedule and a longer JSON. The prompt can stay almost identical; ask for a four-paragraph annual summary instead of three monthly ones. I would still have an accountant review the final document before it leaves the building.
Build it on a weekend. Send the first auto-generated report on the first of the next month. Spend the saved Sunday on something a model cannot do.