I created this Google Apps Script to solve a calendar management challenge with my WGU cohort sessions. Gmail has a fantastic feature that can automatically detect events in emails and add them to your calendar - something Microsoft Outlook lacked. Rather than manually adding each cohort session to my calendar, I decided to forward these emails to my Gmail account and leverage Google's powerful Apps Script platform to ensure reliable event detection, regardless of the varying date/time formats and timezone notations in the emails.
I chose Apps Script for several strategic reasons:
- Native integration with Gmail and Google Calendar APIs
- Server-less architecture with zero hosting costs
- Direct access to Google Workspace services
- Streamlined deployment and maintenance
- Built-in OAuth security handling
- Built-in logging and debugging tools
This project demonstrates automated calendar management using Google Apps Script's capabilities. It's provided as-is and was last tested in January 2024. While I built this to solve my specific needs, I'm sharing it for others facing similar challenges. I welcome suggestions and contributions as I continue to learn and improve my development skills.
- Automatically processes emails with cohort schedules
- Handles multiple timezone formats
- Creates calendar events with proper timing
- Manages updates and cancellations
- Adds configurable email and popup reminders
- Supports batch processing
- Comprehensive logging
- Google Workspace account
- Access to Gmail and Google Calendar
- Ability to create and run Google Apps Scripts
- Create a new Google Apps Script project
- Copy all the code from the
cohort-sync.js
file - Create two Gmail labels:
- "School/Cohort" (for new emails)
- "School/Cohort-Processed" (for processed emails)
- Save and run the script
- Grant necessary permissions
- Set up trigger (optional)
The script can be configured by modifying the CONFIG
object at the top of the file:
const CONFIG = {
LABEL_NAME: "School/Cohort",
PROCESSED_LABEL_NAME: "School/Cohort-Processed",
BATCH_SIZE: 10,
EVENT_WINDOW_MINUTES: 30,
DEFAULT_DURATION_MINUTES: 60,
REMINDERS: {
EMAIL: 60, // minutes before
POPUP: 10 // minutes before
},
LOG_LEVEL: 'INFO' // 'DEBUG', 'INFO', or 'ERROR'
};