Skip to main content
OpenBunny processes Gmail messages using the Gmail API with OAuth authentication and Google Cloud Pub/Sub for real-time push notifications.

Prerequisites

  • A Google Cloud project with the Gmail API enabled
  • A Pub/Sub topic configured for Gmail push notifications
  • OAuth 2.0 credentials (client ID and secret)

Setup

1
Create Google Cloud credentials
2
  • Go to the Google Cloud Console
  • Enable the Gmail API
  • Create OAuth 2.0 credentials (Web application type)
  • Add your redirect URI (cloud URL + /api/email/oauth/callback)
  • 3
    Set up Pub/Sub
    4
  • Create a Pub/Sub topic for Gmail notifications
  • Grant the Gmail service account (gmail-api-push@system.gserviceaccount.com) publish access to the topic
  • Create a subscription that pushes to your cloud webhook endpoint
  • 5
    Configure environment
    6
    GOOGLE_CLIENT_ID=your-client-id
    GOOGLE_CLIENT_SECRET=your-client-secret
    GOOGLE_PUBSUB_TOPIC=projects/your-project/topics/gmail-notifications
    
    7
    Authorize Gmail
    8
    In the cloud web UI, go to Settings > Email and click Connect Gmail. This initiates the OAuth flow and stores tokens securely.

    How it works

    1. Gmail sends push notifications to the Pub/Sub topic when new emails arrive
    2. The cloud receives the webhook and queues an event
    3. The service picks up the event via SSE stream
    4. The service fetches the email content via the Gmail API
    5. The email is processed through the standard LLM agent pipeline
    Gmail integration requires the cloud component even in hybrid mode, since OAuth tokens and webhooks are managed through the cloud API.