Build weekly mileage claims from your team's calendars

Every Friday afternoon, turn each field employee's calendar into a mileage log with distances, drive times and their reimbursable total.

Agentic Task
GeolocationGoogle CalendarGoogle SheetsSlackFinanceOperationsAI ReportsDaily Digests
PromptCreate

Every Friday at 4pm, build each field employee's weekly mileage claim from their calendar so nobody has to reconstruct their driving from memory on a Sunday night. Run this on a cron schedule.

Keep all of the settings together at the top of the workflow so they are easy to change without touching the logic. I need: the mileage reimbursement rate and its currency and unit (for example 0.67 per mile); the distance unit to report in (miles or kilometres); the roster of field employees, where each entry holds the person's name, their calendar id or email, their base address (home or office, whichever they actually drive from), and their Slack user id or handle for the direct message; a list of our own office and depot addresses that must never be claimed as a destination; and the list of keywords that mark an event as non-claimable (for example lunch, personal, dentist, internal, all hands, 1:1, interview). Also keep the target Google Sheets spreadsheet id and sheet name up there.

For each person on the roster, use Google Calendar List Events to pull their events for the working week that is ending, from Monday 00:00 to Friday 23:59 in their local time zone. Expand recurring events into their individual instances so each occurrence is treated as its own trip, and skip any event the person declined.

Then decide which events are genuine site visits. Keep only events whose location field contains a real street address, meaning something with a street number or street name and ideally a town, postcode or state. Drop anything that is a video call (a Zoom, Google Meet, Microsoft Teams or Webex link, a dial-in number, or a location that is just the word remote or online), drop all-day blocks and multi-day events, drop events located at any of our own office or depot addresses, and drop anything whose title or location matches the non-claimable keywords. Also drop events with an empty location, and events where the location is only an internal room or floor name such as Boardroom or Level 3. Use judgement here rather than a rigid pattern match, because location fields are written by hand and are often half finished.

Use Geolocation Forward Geocode to resolve each remaining address into coordinates and a clean formatted address, and geocode each person's base address too. Geocode each distinct address only once per run and reuse the result, rather than geocoding the same customer site repeatedly. If a geocode comes back with no result, a low confidence or partial match, or a result in an obviously wrong region, treat that stop as ambiguous: leave it out of the claim and record it for the person's summary rather than guessing at a distance.

Now build the legs. For each person and each day, sort that day's surviving stops into chronological order by start time, then chain them: base address to the first stop, each stop to the next stop, and the last stop back to the base address. A day with three visits therefore produces four legs. Use Geolocation Calculate Distance Matrix to get the driving distance and duration for these legs. Important: pass the legs as paired origins and destinations so you only ever request the specific pairs you need. Do not build a full matrix of every stop against every other stop, because this operation is billed per element (origins multiplied by destinations) and a full matrix would cost many times more than the handful of legs actually driven.

Convert each leg's distance into the configured unit and round to one decimal place, and express drive time in whole minutes. Then use Google Sheets Append Values to add one row per leg to the mileage log, with these columns: date, employee name, from address, to address, distance, drive time, and the meeting title as the business purpose. For the leg that returns to base, use the last meeting's title with a note that it is the return journey. After a person's legs are written, append a weekly total row for that person showing their total distance and total reimbursable amount, so the sheet reads as a per person claim rather than a loose pile of trips.

Finally, message each person privately. Use Slack Open a Conversation to get the direct message channel for their user id, then use Slack Send a Message to send them their weekly summary. The message should give their total distance for the week, the reimbursable amount calculated at the configured rate, and a short day by day breakdown of the legs so they can sanity check it. Then list every trip that was skipped or looked ambiguous, with the date, the meeting title, and the specific reason (no address in the location field, only a venue name with no street, address could not be found, treated as an office visit, matched a non-claimable keyword). Ask them to correct those calendar entries or reply with the details before payroll closes, and make it clear which items are genuinely excluded versus which just need an address filled in.

If a person has no claimable trips at all in the week, still send them a short message saying nothing was found and listing anything that was skipped, so silence is never mistaken for a missing run. If a calendar cannot be read or a person's base address is missing from the configuration, note that clearly in the run summary instead of writing partial or misleading rows into the mileage log.

What does this prompt do?

  • Reads each field employee's calendar for the week and keeps only the meetings that were genuine visits to a customer or site address, ignoring video calls, all-day blocks and time at your own offices
  • Works out the driving distance and time for every leg of the week: base address to the first stop, stop to stop, and the last stop back to base
  • Writes one row per trip into a shared mileage log with the date, who drove, where they went, the miles, the drive time and the meeting title as the business purpose, plus a weekly total for each person
  • Sends everyone a direct message with their total miles and what they are owed, listing any trip it had to skip so they can correct it before payroll closes

What do I need to use this?

  • A Google Calendar account for the team whose travel you want to claim, with meeting locations filled in as street addresses
  • A Google Sheets spreadsheet to use as the running mileage log
  • A Slack workspace so each person can be sent their own summary privately
  • Your mileage rate and each person's usual starting address, whether that is home or an office
  • Driving distances are worked out for you, so there is no mapping account or billing setup to arrange

How can I customize it?

  • Update the mileage rate in one place at the top whenever the tax authority changes it, and switch between miles and kilometres
  • Edit each person's base address, or add and remove people as the field team changes
  • Adjust the keywords that mark a meeting as non-claimable and list your own office addresses so internal days never get claimed
  • Move the run from Friday at 4pm to whenever your payroll cutoff actually falls

FAQs

What happens if someone forgets to put an address on a meeting?
That trip is left out of the claim rather than guessed at, and it is listed in the person's Friday message so they can add the address and have it picked up next time. The same applies to half-written locations like a venue name with no street, which get flagged as ambiguous instead of being silently claimed.
Do I need a Google Maps account or API key to use this?
No. Address lookup and driving distances are handled for you, which is the part people normally have to set up themselves with a mapping account and a billing card before they can calculate mileage.
Will it claim mileage for video calls or days in the office?
No. Meetings with a video link in the location field, all-day blocks and anything at an address you have listed as your own office are all excluded, along with any meeting matching your non-claimable keywords.
Can it handle people who drive from home rather than from the office?
Yes. Each person has their own base address, so the first and last legs of the day are measured from wherever they actually start and finish. You can mix home-based and office-based staff in the same run.
Does it work out the return journey at the end of the day?
Yes. Each day is chained from the base address to the first stop, between each stop in time order, and from the last stop back to base, so a full day of visits produces a complete round trip rather than a set of disconnected hops.

Related templates

Prospecting desk that builds account lists from the live web

Stop buying stale lists. Reps run a saved search, work the results like an inbox, and only the accounts they approve ever reach your CRM.

Hyperbrowser
HubSpot
Google Sheets
App
Plan a field sales day around drive time and neglected accounts

Pick a date, a starting point and a radius, then build a sequenced day of customer visits that lands straight on your calendar.

Geolocation
HubSpot
Google Calendar
App
Influencer campaign roster board with AI creator briefs

Drag creators through Sourced to Wrapped on a board grouped by campaign, with audience stats on every card and a one-click brief for each creator.

HypeAuditor
Google Sheets
Notion
App
Browse and shortlist creators without burning audit credits

Search creators for free, shortlist the best with your team, and spend an audit credit only when you decide someone is worth a closer look.

HypeAuditor
Airtable
Slack
App
Morning repricing console for Shopify with margin-safe rules

Pick a repricing rule, send an assistant out to check competitor pages, then approve the new prices that clear your margin floor.

Hyperbrowser
Shopify
Google Sheets
App
Pre-flight bounce check before you launch a cold email sequence

See the projected bounce rate for any outbound send before it goes out, and keep the launch button locked until the list is clean enough to be safe.

Hunter
Google Sheets
App

Stop reconstructing your driving on a Sunday night.

Let the calendar do the paperwork so every mileage claim is logged, costed and in people's hands before payroll closes.