Project Goal
The goal of this project was to create a Google Sheets Add- on, that automatically extracts event details from emails and adds them to Google Calendar. This eliminates the need to manually create calendar events, saving time and improving organization. For me and my spouse this has been very helpful regarding the numerous emails we receive from daycare and school, which usually contain “unstructured” mentions of certain events.
Feel free to use it yourself as well by creating a copy of this sheet.
Instructions HERE
How it was built
This script is designed to process emails, leveraging the Gmail API to fetch unprocessed messages. It then uses the OpenAI API (specifically, the gpt-4o-mini model) to intelligently extract event details like titles, start times, and end times. The script supports multiple calendars, each with its own set of sender filters. The script is triggered by a time-based event, which runs every 8 hours. This ensures that new emails are regularly checked for events. To ensure no event is created twice, the script maintains a list of processed email IDs, and only processes new emails. All configurations are managed through an HTML sidebar within the Google Sheet, which includes the ability to add multiple calendars with custom sender filters.
Key features include:
- Email Fetching: Uses Gmail API to search for emails from specified senders or all senders.
- Event Extraction: Employs OpenAI’s GPT-4o-mini to parse email bodies and extract event details in a structured format.
- Calendar Event Creation: Utilizes the Calendar API to add extracted events to the user’s Google Calendar.
- Configuration: Allows users to configure multiple calendars with distinct sender filters through a sidebar.
- State Management: Persistently stores processed email IDs to avoid duplicate event creation.
- Time-Based Triggers: Automatically runs every 8 hours to check for new emails.
Technologies Used
- Google Apps Script
- Gmail API
- Calendar API
- OpenAI API (gpt-4o-mini model)
- HTML/CSS for the sidebar