Build monthly mileage reimbursement reports from Google Calendar with OpenAI and Dropbox

Go to Workflow
0 views
Built by Gaetano Castaldo Gaetano Castaldo
Created on October 26, 2026

Description

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.

This workflow was created by Gaetano Castaldo and shared publicly on the n8n community template library. n8nFind indexes it for discovery — the workflow remains the property of its original creator.

Nodes Used (7)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
Dropbox
n8n-nodes-base.dropbox
Gmail
n8n-nodes-base.gmail
HTTP Request
n8n-nodes-base.httpRequest
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured