Quick overview
This workflow runs monthly to turn Google Calendar trip events into a mileage reimbursement Excel, using OpenAI to parse free-text events and OpenStreetMap/OSRM to calculate driving distances, then uploads the file to Dropbox and (in live mode) prepares a Gmail draft for your accountant with validation checks.
How it works
- Runs on the 1st of every month at 07:00 (or manually) and sets the month to process (previous month by default, or a manual override).
- Pulls events for that month from Google Calendar and parses trips from titles like “Departure > Arrival, km, purpose”, while marking multi-day “Trasferta” events as away days.
- Sends remaining in-month free-text events to OpenAI to extract whether they are car trips plus ordered stops, optional km, purpose, and one-way/round-trip.
- For trips missing km (or when verification is enabled), geocodes unique stop names via OpenStreetMap Nominatim and calculates driving distance via the OSRM routing service.
- Builds a per-day reimbursement table with totals, flags issues (km mismatch vs route, duplicate trips, excessive daily km, and AI-parsed trips to review), and generates an XLSX file.
- Uploads the XLSX to Dropbox and, in live mode, records the month in an n8n Data Table to prevent duplicate drafting, creates a Gmail draft to the accountant with the Excel attached, and emails you an HTML summary.
Setup
- Add credentials for Google Calendar OAuth2, OpenAI, Dropbox OAuth2, and Gmail OAuth2.
- In the Settings node, set your Google Calendar ID, reimbursement rate per km, home base (usual departure), Dropbox folder path, recipient emails, and a valid OpenStreetMap-compliant User-Agent string.
- If using live mode, ensure n8n Data Tables are available and set mode to "test" for a first run (optionally set monthOverride like "2026.10"), then switch mode to "live" and clear monthOverride before activating the schedule.
Requirements
- Google Calendar, OpenAI, Dropbox and Gmail accounts, and an n8n version with data tables. No API key for OpenStreetMap: Nominatim and the public OSRM server are free within their usage policies.
Customization
- Set readFreeTextWithAI to false to skip the AI; tune kmTolerancePercent and maxKmPerDay, or turn off checkDeclaredKm; set alwaysUseOpenStreetMap to true to ignore the km written in titles; change countryCodes for trips outside Italy.
Additional info
The AI never invents a departure: without one in the event or in homeBase, the event is listed instead of reimbursed. Labels, Excel columns and emails are in Italian on purpose, as an Italian accountant expects them; translate them in the Compose the reimbursement node. In Italy the rate per km comes from the ACI table for your car. To redo a month already drafted, delete its row in the Rimborsi km data table and run again.