An intelligent Gmail add-on that uses Google's Vertex AI (Gemini) to help you compose emails, generate replies, summarize messages, and extract calendar events automatically.
I owned the end-to-end implementation of the calendar integration module:
- Built text-based event parsing logic to extract dates and times from AI-generated email content
- Implemented one-click Google Calendar event creation using OAuth-scoped Calendar API access
- Tested and validated the feature in a deployed Gmail sidebar add-on
Google Apps Script • Vertex AI (Gemini) • Gmail API • Google Calendar API • OAuth
- AI Reply Generation: Automatically generate professional replies to emails
- Smart Email Composition: Create well-structured emails from simple prompts
- Email Summarization: Get concise summaries of long emails
- Calendar Event Extraction: Automatically detect and add events to Google Calendar
- Regenerate Options: Refine AI-generated content with one click
- Context-Aware: Understands email threads and maintains conversation context
- Google Account
- Google Cloud Project with Vertex AI API enabled
- Apps Script project
-
Clone or copy the code files:
Code.gs- Entry point and action handlersCards.gs- UI card buildersVertex.gs- Vertex AI integration
-
Set up Google Cloud Project:
- Create a new project at console.cloud.google.com - Enable Vertex AI API - Note your PROJECT_ID -
Configure Script Properties:
In Apps Script Editor → ⚙️ Project Settings → Script Properties, add:
PROJECT_ID: your-gcp-project-id VERTEX_AI_LOCATION: us-central1 -
Update Vertex.gs: Replace the constants at the top of
Vertex.gs:const PROJECT_ID = "your-project-id"; const VERTEX_AI_LOCATION = "us-central1"; const MODEL_ID = "gemini-2.5-flash";
-
Configure OAuth Consent Screen:
- Go to GCP Console → APIs & Services → OAuth consent screen
- Add your email as a test user
- Leave Authorized domains blank
-
Deploy as Add-on:
- In Apps Script Editor: Deploy → Test deployments
- Select type: "Editor Add-on"
- Install in Gmail
Add these to your appsscript.json:
{
"timeZone": "America/Los_Angeles",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.readonly",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/calendar"
],
"gmail": {
"name": "Compose X",
"logoUrl": "https://www.gstatic.com/images/branding/product/1x/gmail_48dp.png",
"contextualTriggers": [
{
"unconditional": {},
"onTriggerFunction": "buildAddOn"
}
],
"composeTrigger": {
"selectActions": [
{
"text": "Compose with AI",
"runFunction": "buildAddOn"
}
],
"draftAccess": "NONE"
},
"universalActions": [
{
"text": "Open Compose X",
"runFunction": "buildAddOn"
}
]
}
}- Click "Compose" in Gmail
- Open Compose X from the add-on sidebar
- Enter recipient and what you want to say
- Click "✨ Generate Draft"
- Use "Regenerate" to refine or "Back" to start over
- Open any email in Gmail
- Open Compose X from the sidebar
- Click "Generate AI Reply"
- Review and regenerate if needed
- Open an email
- Click "Summarize Email"
- View summary and extracted calendar events
- Add events to calendar with one click
├── Main.gs # Entry point, action handlers, calendar functions
├── Cards.gs # UI card builders for different states
└── Vertex.gs # Vertex AI API integration
Main.gs:
buildAddOn(e)- Main entry pointgenerateCompose(e)- Handle compose generationgenerateReply(e)- Handle reply generationhandleSummarizeEmail(e)- Summarize and extract eventscreateCalendarEvent(e)- Add event to calendar
Cards.gs:
buildComposeCard()- Initial compose formbuildReplyCard(e)- Email preview cardbuildGeneratedDraftCard()- Show generated draftbuildGeneratedReplyCard()- Show generated replybuildErrorCard()- Error display
Vertex.gs:
processEmail()- Generate reply to emailprocessComposeEmail()- Generate new email draftsummarizeEmail()- Summarize email contentextractCalendarEvents()- Extract event info with structured output
Modify these in Vertex.gs:
const PROJECT_ID = "your-project-id";
const VERTEX_AI_LOCATION = "us-central1"; // or "asia-northeast3" for Seoul
const MODEL_ID = "gemini-2.5-flash"; // or "gemini-1.5-pro"Adjust in API payloads:
generationConfig: {
temperature: 0.7, // 0.0-1.0 (higher = more creative)
maxOutputTokens: 2048 // Max response length
}Run test functions in Apps Script Editor:
// Test reply generation
testProcessEmail()
// Test compose generation
testComposeEmail()
// Test summarization
testSummarizeEmail()
// Test calendar extraction
testExtractCalendar()
// Test calendar event creation
testCreateCalendarEvent()- Add your email to test users in GCP Console OAuth consent screen
- Wait 5-10 minutes for changes to propagate
- Verify Vertex AI API is enabled in GCP
- Check PROJECT_ID matches your GCP project
- Ensure OAuth token has cloud-platform scope
- Check appsscript.json is properly formatted
- Verify all required scopes are listed
- Redeploy the add-on
- Verify Calendar API scope is included
- Check date format in extracted events (ISO 8601)
- Ensure start time is before end time
- Vertex AI Gemini Flash: ~60 requests/minute
- Calendar API: 1M requests/day per project
- Consider rate limiting for production use
Note: This add-on requires a Google Cloud Project with Vertex AI enabled. Vertex AI usage incurs costs based on token consumption. Check Google Cloud Pricing for details.