tooling

Strava Automation

Every morning I bike to work, upload the ride to Strava, and then manually toggle the “commute” flag. It’s a small thing, but doing it twice a day, every day, gets old. So I built a small server that does it for me.

The setup

Strava’s API supports webhooks — whenever you upload a new activity, it sends a POST request to a URL of your choice. I wrote a Vapor server in Swift that receives these webhooks, checks whether the activity matches my commute criteria, and if so, updates it via the Strava API.

The flow is straightforward:

  1. Webhook arrives — Strava notifies the server about a new activity upload
  2. Fetch details — the server pulls the full activity data from the Strava API
  3. Evaluate — check whether it matches the commute criteria (route, time of day, activity type)
  4. Update — if it’s a commute, flip the flag via the API
  5. Name — generate a descriptive activity name using OpenAI’s GPT-4o mini, based on the route, activity data, and current weather — so rides don’t just show up as “Morning Ride” or “Afternoon Ride”

The stack

The server is built with Vapor, Swift’s most established server-side framework. API types are generated with Swift OpenAPI Generator, which gives you type-safe request and response models straight from the Strava API spec. Fluent handles persistence for keeping track of processed activities.