Commute Alert Calendar via Google Apps Script
Why Do This?
As anyone with an urban commute knows, sports events can make a huge difference in traffic levels, or the number of people on mass transit. I wanted to build an alert system which would give me warning about games which would affect my commute.
I use Google Calendar for all the things, so it made sense to try to implement this commute alert calendar in GCal. Furthermore, Google conveniently has pre-made calendars for most major sports teams to which you can ‘subscribe’. Since I only care about the local teams which will affect my traffic, I picked out the local baseball and football teams which have stadiums along my route.
The Plan
Google Apps Script is basically JavaScript but with some built-in functions specifically for accessing Google Apps. Perfect for this type of project! Since I’m going to be scraping events from some existing sports calendars, looking for events which are home games, and then merging them into a new Commuter Alerts calendar. There’s only a few bits of information needed to do this:
- The (kinda hidden) ID of each of the teams’ schedule calendars
- The key words which denote which games are home games
- The ID of the calendar where we’ll output the events which match the home game criteria
To make storing these settings easy, I decided to just put them in a Google spreadsheet. Additionally I added some other useful bits of information, like the team name and the venue/stadium name.
Note: There are also some additional fields in my spreadsheet for an Icon and a Channel — these are special fields I use in conjunction with a Slack integration I made with Zapier which sends an alert message as ‘CommuteBot’ with the Icon and Channel specified. (I will likely writeup some instructions about that later. Look for a link here when that happens.)
The output calendar will have 2 alerts per event. One alert at noon the day before the event, and a second alert 4 hours before the event actually starts. This should give me plenty of warning to alter my commute plans as needed.
The Spreadsheet
HERE is the spreadsheet. If you have/are signed in with a Google account, you should be able to click that link, open the spreadsheet, and select File > Make a copy… to save your very own copy to Google Drive. Then you can modify your copy as you see fit.
In your copy of the spreadsheet
- You will need to configure both the Input Settings and the Output Settings tabs.
- To view/modify the Apps Script and modify it to suit your needs:
Tools > Script Editor

- There should be 2 script files, one “regular” one and one “Slack” one. You can probably safely ignore the Slack one — at least until I do a writeup about the Slack integration.
- You will need to set the script to run on a schedule. I have mine set to run every Saturday. This causes the script to look 1 week ahead, and populate all the alert events into the output calendar.
Script Editor > Edit > Current project’s triggers > add a new trigger
Here’s mine:
