How anagh070/gmail-to-calendar-automation works
Project type and purpose
• This is a Google Apps Script “automation tool” that runs inside the Google Cloud/Apps Script environment.
• It scans your Gmail inbox for natural‐language date/time mentions and then uses the Calendar API to create events automatically.
File structure
• Top level contains only two files:
• autoAddToCalendar.gs (the single Apps Script source)
• README.md (project description and usage)
• No external modules, no frontend, no database—pure server‐side script triggered on a schedule.
Extract architectural insights from the README
• Uses Gmail Service: scans emails from the last 3 days
• Parsing engine: a set of regex patterns in pure JavaScript
• Calendar Service: creates new events
• Trigger configuration: time-driven trigger (hourly or daily)
Main components
a. Google Apps Script Host
• The runtime environment where your script lives.
b. Time-Driven Trigger
• The scheduler that invokes autoAddToCalendar() on a set interval.
c. Gmail Service
• Reads threads, searches for date/time strings via regex.
d. Parsing Engine
• A pure-JavaScript module inside the script that applies multiple patterns.
e. Calendar Service
• Receives parsed date/time + metadata, creates events on the default calendar.
f. Label Manager
• Applies the “AutoScheduled” label to prevent reprocessing.
Relationships and interactions
• Trigger → Apps Script Host → autoAddToCalendar()
• Within function:
1. Call Gmail Service → fetch recent threads
2. Pass email bodies to Parsing Engine → extract date/time
3. Invoke Calendar Service → create event if valid
4. Invoke Gmail Service → apply “AutoScheduled” label
Architectural patterns and design principles
• Event-driven: uses time triggers instead of manual invocation
• Single responsibility: each step (scan, parse, write, label) is a distinct block inside the function
• Idempotency safeguards: skips duplicates and past events
Technologies & frameworks to annotate
• Google Apps Script (JavaScript runtime)
• Gmail Service (Apps Script API)
• Calendar Service (Apps Script API)
• No external libraries