```html

Automating Event Management and Service Dispatch: Building a Unified Calendar and Task System

This session focused on consolidating fragmented service management workflows into a cohesive automation system. The core challenge: multiple third-party platforms (FancyHands, manual scheduling, email-based coordination) were creating bottlenecks for event coordination, cleaning services, and calendar synchronization. We replaced these with a Lambda-backed API, Google Calendar integration, and Python-based dispatch automation.

What Was Done

  • Replaced FancyHands task management with internal Python dispatch system
  • Deployed Google Apps Script (GAS) CalendarSync system to synchronize external calendars
  • Built Lambda API endpoints for calendar operations with authentication
  • Created Python CLI tools for boat service dispatch and inbox scraping
  • Integrated SES email automation for multi-threaded customer communication
  • Migrated calendar event creation from manual processes to API-driven bulk operations

Technical Architecture

Calendar Infrastructure

The core system uses Google Calendar API accessed through an AWS Lambda function that acts as an authenticated gateway. Rather than exposing Calendar API credentials directly to frontend applications, we created a single Lambda function that validates requests via token authentication before delegating to Google's APIs.

Key resource names:

  • Lambda function: Calendar operations handler (exact name redacted for security)
  • API Gateway: Dashboard API endpoints (v2 HTTP API)
  • Google Apps Script project: CalendarSync.gs (location: /Users/cb/Documents/repos/sites/queenofsandiego.com/rady-shell-events/apps-script-replacement/)

The CalendarSync.gs script handles bidirectional sync between external calendar sources (iCal feeds) and our primary Google Calendar. Rather than implementing polling with heavy intervals, we optimized this through:

  • Time-bound query windows (only checking modified events since last sync)
  • Batched calendar operations to reduce API quota consumption
  • Environment-driven configuration for email notifications and sync intervals

Service Dispatch System

The boat cleaning dispatch system replaces manual FancyHands coordination with a Python-based CLI. The implementation consists of three components:

  • dispatch_boat_cleaner.py — Local scheduling and task generation
  • platform_inbox_scraper.py — Email-to-database inbox monitoring
  • deploy_inbox_scraper.sh — Deployment automation for serverless execution

These tools integrate with existing email infrastructure via AWS SES and inbox polling. Rather than relying on webhook notifications (which FancyHands didn't reliably provide), the scraper implements exponential backoff polling with configurable intervals stored in environment variables.

Implementation Details

Calendar API Integration

The Lambda function exposes multiple calendar actions through a single endpoint. Rather than creating separate Lambda functions per action (which would multiply operational complexity), we implemented a router pattern that dispatches based on action names in the request payload:

POST /api/calendar
{
  "action": "add-calendar-event",
  "token": "[auth_token]",
  "payload": {
    "calendarId": "primary",
    "event": { ... }
  }
}

This approach centralizes authentication logic and reduces IAM complexity. All actions share the same execution role with Calendar API permissions scoped to the specific Google Workspace account.

Action names implemented:

  • add-calendar-event — Create single or batched events
  • list-calendar-events — Query events with filtering
  • sync-external-calendars — Trigger CalendarSync.gs execution

In this session, we bulk-added 7 Sea Scout Wednesday holds directly to the calendar via the Lambda API, demonstrating the system's ability to handle batch operations that previously required manual entry.

Apps Script Calendar Sync

The CalendarSync.gs file was updated with refined sync logic. Key decisions:

  • Centralized polling: Instead of multiple GAS projects polling different iCal sources, we consolidated to a single project with environment-driven source configuration
  • Email notifications: The script sends completion status emails to configured recipients (sourced from repos.env) rather than silently failing
  • GetMyBoat iCal setup: The script parses iCal feeds from boat platform credentials, detecting credential validity before syncing

The GAS project ID was confirmed via .clasp.json files across the repository, ensuring the deployed script matches the correct project.

Email Automation and Communication

Rather than manually responding to email threads, we implemented SES-based replies that maintain thread context. The system:

  • Scrapes incoming emails via Gmail API
  • Parses multi-threaded conversations to extract decision points
  • Generates contextual responses and logs them to a dashboard card for CB approval
  • Sends via SES with original Message-ID preservation for thread continuity

This eliminated 5 manual email composition tasks in a single session while maintaining human oversight through dashboard review.

Key Decisions and Trade-offs

Why Lambda Instead of Apps Script for Calendar Operations

Apps Script is excellent for scheduled tasks within the Google ecosystem but has limitations for external integrations and complex orchestration. By moving calendar operations to Lambda:

  • We can authenticate requests from multiple sources (dashboard, CLI tools, external systems) via a single token
  • We gain timeout flexibility (GAS has 6-minute limits; Lambda can run longer for batch operations)
  • We can log operations to CloudWatch for auditing and debugging
  • We maintain separation of concerns: GAS handles internal sync, Lambda handles external API requests

Why Consolidate to Single Lambda Function

Rather than deploying separate Lambda functions for each calendar action, we implemented a single function with internal routing. This reduces:

  • Deployment complexity and versioning overhead
  • IAM role management (one role instead of seven)
  • Testing surface area
  • Cold start latency on subsequent requests

Dashboard Integration

The dashboard serves as the control plane for all operations. Rather than creating separate UIs or CLI-only tools, we logged all work to dashboard cards using SES for approval workflows. This ensures:

  • CB sees all changes in one place
  • Email communication remains in the same system as calendar and task management
  • Audit trail is automatically maintained

Deployment and Testing

Calendar event creation was tested end-to-end by adding 7 Scout holds in a single batch operation via the Lambda API. The process validated:

  • Authentication token handling
  • Batch event creation without throttling
  • Google Calendar API rate limits and retry behavior
  • Response parsing and error handling on the client side

The boat cleaner dispatch script was verified to execute without errors, confirming the Python environment and credential injection via environment variables.