●SIRI — WWDC 2026 confirms the revamped Siri runs on a Google Gemini model, though it won't ship in the EU at iOS 27 due to the DMA●FLASH3.5 — Gemini 3.5 Flash is now GA, the top Flash model for sustained frontier performance on agentic and coding tasks●IMAGE-GA — Gemini 3.1 Flash Image and 3.1 Pro Image are GA as native visual models; the preview versions shut down Jun 25●MANAGED-AGENTS — Managed Agents launch in public preview in the Gemini API, running autonomous agents in Google-hosted isolated Linux sandboxes●FILE-SEARCH — File Search now supports multimodal search, with native image embedding and retrieval via gemini-embedding-2●DEPRECATION — gemini-3.1-flash-image-preview and gemini-3-pro-image-preview shut down Jun 25 — migrate to the GA models soon●SIRI — WWDC 2026 confirms the revamped Siri runs on a Google Gemini model, though it won't ship in the EU at iOS 27 due to the DMA●FLASH3.5 — Gemini 3.5 Flash is now GA, the top Flash model for sustained frontier performance on agentic and coding tasks●IMAGE-GA — Gemini 3.1 Flash Image and 3.1 Pro Image are GA as native visual models; the preview versions shut down Jun 25●MANAGED-AGENTS — Managed Agents launch in public preview in the Gemini API, running autonomous agents in Google-hosted isolated Linux sandboxes●FILE-SEARCH — File Search now supports multimodal search, with native image embedding and retrieval via gemini-embedding-2●DEPRECATION — gemini-3.1-flash-image-preview and gemini-3-pro-image-preview shut down Jun 25 — migrate to the GA models soon
Gemini × Google Workspace Add-ons Development Guide — From Building Custom AI Side Panels to Marketplace Launch
A comprehensive guide to building custom AI side panels with Google Workspace Add-ons and Gemini API — from implementation to Marketplace publication and monetization.
Setup and context — Why Workspace Add-ons × Gemini?
For organizations that rely on Google Workspace daily, having AI assistance available directly from the side panel in Docs, Sheets, or Gmail represents a massive productivity boost. As of 2026, the Google Workspace Add-ons SDK supports rich UI components through Card Service v2, and when combined with the Gemini API, you can build context-aware intelligent assistants right in the side panel.
This article walks you through the complete journey — from the foundational architecture of Google Workspace Add-ons to building a Gemini API-powered AI side panel, designing OAuth scopes, navigating the security review process, and finally publishing and monetizing your add-on on the Google Workspace Marketplace. We provide production-ready code throughout, so by the time you finish reading, you should be ready to publish your own add-on.
This article assumes familiarity with Apps Script basics and a working knowledge of the Gemini API. For building cross-product workflows with Apps Script, check out "[Building Cross-Product AI Workflows with Gemini API and Apps Script]((/articles/gemini-workspace/gemini-apps-script-cross-product-ai-workflow)."
Understanding Workspace Add-ons Architecture
Google Workspace Add-ons use Apps Script or HTTP endpoints as the backend to display custom UI in the side panel of Google Workspace applications (Gmail, Docs, Sheets, Slides, Calendar).
Host Apps and Triggers
Add-ons define trigger functions for each "host app." For example, when a user opens an email in Gmail or a document in Docs, the corresponding trigger function fires and generates the Card UI for the side panel.
Homepage Trigger: The home screen displayed when the user clicks the add-on icon
Contextual Trigger: Screens that auto-display based on context (opening an email, selecting a document, etc.)
Action Callback: Functions invoked on button clicks or form submissions
The oauthScopes design directly affects whether your add-on passes the security review. Always follow the principle of least privilege — when a currentonly scope is available, prefer it over the full-access equivalent (e.g., documents.currentonly instead of documents).
✦
Thank you for reading this far.
Continue Reading
What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.
WHAT YOU'LL LEARN
✦Master implementation patterns for integrating the Workspace Add-ons SDK with Gemini API
✦Understand the full process from OAuth scope design to security review and Marketplace submission
✦Gain practical know-how for building subscription billing models and optimizing revenue
Secure payment via Stripe · Cancel anytime
Implementing the Gemini-Powered Side Panel
Now let's dive into the actual implementation. We'll build an add-on that analyzes Gmail messages using Gemini, generating summaries and reply drafts.
This utility supports both plain text responses and structured output (JSON mode). For details on structured output, see "[Gemini Structured Output Production Guide]((/articles/gemini-advanced/gemini-structured-output-production-guide)."
Gmail AI Side Panel Implementation
// gmail-addon.gs — Gmail side panelfunction onGmailMessage(e) { const messageId = e.gmail.messageId; const message = GmailApp.getMessageById(messageId); const subject = message.getSubject(); const body = message.getPlainBody().substring(0, 3000); // Save tokens const from = message.getFrom(); const card = CardService.newCardBuilder() .setHeader( CardService.newCardHeader() .setTitle('Gemini AI Assistant') .setSubtitle(subject) .setImageUrl('https://example.com/gemini-icon.png') .setImageStyle(CardService.ImageStyle.CIRCLE) ); // Summary section const summarySection = CardService.newCardSection() .setHeader('📋 Email Summary') .addWidget( CardService.newTextParagraph() .setText('Run AI analysis directly from the side panel') ) .addWidget( CardService.newButtonSet() .addButton( CardService.newTextButton() .setText('Generate Summary') .setOnClickAction( CardService.newAction() .setFunctionName('summarizeEmail') .setParameters({ messageId: messageId, subject: subject, body: body.substring(0, 1500) }) ) ) .addButton( CardService.newTextButton() .setText('Draft Reply') .setOnClickAction( CardService.newAction() .setFunctionName('draftReply') .setParameters({ messageId: messageId, subject: subject, body: body.substring(0, 1500), from: from }) ) ) ); // Custom prompt section const customSection = CardService.newCardSection() .setHeader('💬 Custom Question') .addWidget( CardService.newTextInput() .setFieldName('customPrompt') .setTitle('Ask about this email') .setHint('e.g., List the action items in this email') ) .addWidget( CardService.newTextButton() .setText('Ask AI') .setOnClickAction( CardService.newAction() .setFunctionName('askAboutEmail') .setParameters({ body: body.substring(0, 1500) }) ) ); card.addSection(summarySection); card.addSection(customSection); return card.build();}/** * Email summary callback */function summarizeEmail(e) { const params = e.commonEventObject.parameters; const summary = callGemini( `Summarize the following email in 3 lines. If there are important action items, list them as bullet points.\n\nSubject: ${params.subject}\n\nBody:\n${params.body}`, { systemInstruction: 'You are a business email analysis assistant. Summarize concisely and accurately.', temperature: 0.3, maxTokens: 512 } ); const card = CardService.newCardBuilder() .setHeader( CardService.newCardHeader() .setTitle('Summary') .setSubtitle(params.subject) ) .addSection( CardService.newCardSection() .addWidget( CardService.newTextParagraph().setText(summary) ) .addWidget( CardService.newButtonSet() .addButton( CardService.newTextButton() .setText('← Back') .setOnClickAction( CardService.newAction() .setFunctionName('onGmailMessage') ) ) ) ); return CardService.newActionResponseBuilder() .setNavigation( CardService.newNavigation().pushCard(card.build()) ) .build();}/** * Reply draft generation callback */function draftReply(e) { const params = e.commonEventObject.parameters; const replyDraft = callGemini( `Write a professional reply to the following email. Be polite, concise, and include specific content.\n\nFrom: ${params.from}\nSubject: ${params.subject}\nBody:\n${params.body}`, { systemInstruction: 'You are a professional business email writer.', temperature: 0.5, maxTokens: 1024 } ); // Create draft in Gmail const message = GmailApp.getMessageById(params.messageId); message.getThread().createDraftReply(replyDraft); const card = CardService.newCardBuilder() .setHeader( CardService.newCardHeader().setTitle('Draft Created') ) .addSection( CardService.newCardSection() .addWidget( CardService.newTextParagraph() .setText('✅ Draft saved to your Drafts folder.\n\n' + replyDraft.substring(0, 500) + '...') ) ); return CardService.newActionResponseBuilder() .setNavigation( CardService.newNavigation().pushCard(card.build()) ) .build();}
The Apps Script editor alone limits developer productivity. We strongly recommend using clasp (Command Line Apps Script Projects) to set up a local development environment.
# Install claspnpm install -g @google/clasp# Log in with your Google accountclasp login# Clone an existing Apps Script projectclasp clone <SCRIPT_ID># Push local changesclasp push# Open the Apps Script editor in browserclasp open
Debugging Techniques
Logger.log vs console.log: Logger.log() outputs to the Apps Script editor's execution log, while console.log() goes to Stackdriver (Cloud Logging). For production debugging, use console.log()
Test deployments: After modifying the manifest, use "Deploy" → "Test deployments" in the Apps Script editor to install a test version visible only to you. Always verify functionality through test deployment before production release
Store API keys in Script Properties — never hardcode them. For more on secure API key management, consult the Gemini API documentation.
Publishing to the Google Workspace Marketplace
Pre-Submission Checklist
Before submitting to the Marketplace, verify the following:
The add-on works correctly in all target host apps (Gmail, Docs, Sheets, etc.)
You've received feedback from at least 5 testers via test deployment
Your privacy policy and terms of service pages are published over HTTPS
Screenshots are ready (at least 3, 1280x800px recommended)
Add-on descriptions (English + target languages) are finalized
OAuth scope justification document is complete
Google Cloud Console Configuration
Create a Google Cloud project: Create a GCP project linked to your Apps Script project
Configure OAuth consent screen: Set up the consent screen for external users and register required scopes
Enable Marketplace SDK: Activate "Google Workspace Marketplace SDK" in the GCP Console and fill in your app configuration
Submit for review: Enter the review information and submit for approval
Review Timeline and Response Strategy
Reviews typically take 1–3 weeks. The review team frequently requests additional information, so keeping these points in mind will streamline your response:
Demo video: A 30-second to 2-minute screen recording showcasing your features
Test account: Provide account credentials the review team can use for testing (without production data)
Scope mapping: Explicitly show a 1:1 mapping of "this feature requires this scope"
Building a Subscription Billing Model
For Marketplace monetization, the most common approach in 2026 is integrating your own subscription system.
Freemium model: Offer core features free while gating advanced AI analysis, unlimited usage, and team features behind a paywall
Usage-based limits: Free users get 10 AI analyses per day; premium users get unlimited access
Team plans: Offer admin-managed bulk licensing for Google Workspace organizational accounts
Trial period: Provide a 14-day free trial so users can experience premium features firsthand
For a systematic approach to monetization strategy, see "[Gemini Monetization Masterplan 2026]((/articles/gemini-api/gemini-monetization-masterplan-2026)."
Performance Optimization and Production Operations
Handling Execution Time Limits
Apps Script's execution time limit (6 minutes per invocation) requires special attention when your add-on calls the Gemini API.
// performance.gs — Performance optimization/** * Process large text in chunks (pseudo-parallel) * (Apps Script doesn't support true parallelism, so we batch for efficiency) */function processLargeDocument(fullText, chunkSize) { const chunks = []; for (let i = 0; i < fullText.length; i += chunkSize) { chunks.push(fullText.substring(i, i + chunkSize)); } const results = []; const startTime = Date.now(); const TIME_LIMIT_MS = 300000; // 5 minutes (1-minute buffer) for (const chunk of chunks) { if (Date.now() - startTime > TIME_LIMIT_MS) { results.push({ partial: true, message: 'Processing time limit reached. Remaining portions will be analyzed next time.' }); break; } const analysis = callGemini( `Analyze the following text:\n${chunk}`, { temperature: 0.3, maxTokens: 1024 } ); results.push({ text: analysis }); } return results;}
Monitoring and Alerts
For production operations, combine Cloud Logging with Cloud Monitoring to track your add-on's health:
This article covered the complete journey of building custom AI side panels with Google Workspace Add-ons and the Gemini API — from Card Service v2 UI construction and Gemini API integration patterns to OAuth scope design, security review strategy, and subscription billing implementation.
Workspace Add-ons give you direct access to the enormous user base that uses Google Workspace daily. Combined with Gemini API's natural language processing capabilities, you can build AI tools that dramatically boost user productivity — and turn them into a sustainable business.
Start with a simple add-on that solves a pain point in your own daily workflow, gather user feedback, and gradually expand functionality. The code in this article is designed to work as-is, so feel free to use it as your foundation.
For a comprehensive overview of building revenue streams with the Google AI ecosystem,
Share
Thank You for Reading
Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.