HeadlinesBriefing favicon HeadlinesBriefing.com

Go Gmail Meet Integration Architecture

DEV Community •
×

A developer built a production system where AI agents process emails and schedule meetings in real-time. The architecture uses Gmail Push API with Google Cloud Pub/Sub for notifications and domain-wide delegation to avoid individual OAuth flows. This eliminates polling latency and scales to handle thousands of emails daily.

The system tracks email history via Redis to fetch only new messages, avoiding duplicates. A key gotcha: Gmail's `historyId` is a number, not a string, requiring `json.Number` parsing. Watch subscriptions expire after seven days, so a Cloud Scheduler job renews them every five days to maintain the real-time pipeline.

For scheduling, a single service account impersonates any user via JWT bearer tokens, creating Google Calendar events with automatic Google Meet links. Availability checking merges busy times from calendar and local conflicts. The author's key lesson: always return HTTP 200 for malformed webhooks, as Pub/Sub retries on non-2xx responses.