You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

开发可独立显示的Gmail Add-on:功能实现及清单配置问询

Feasibility Breakdown

Absolutely, every part of your request is completely achievable with Gmail Add-ons and the Gmail API:

  • Reading multiple emails: You can use the Gmail API's Users.Messages.list or Users.Threads.list methods to fetch batches of emails (with filters like label, date range, etc.) directly from the user's inbox—no need to open individual messages first.
  • Creating labels & filters: The Gmail API provides dedicated endpoints (Users.Labels.create for labels, Users.Settings.Filters.create for filters) that your add-on can call to create these items programmatically.
  • Always visible (no need to open emails): You can configure your add-on to load directly in Gmail's right-hand sidebar when the user is on the inbox, label views, or other main Gmail screens—no need to open a single email first.
Key Manifest File (appsscript.json) Configurations

Your manifest file needs specific entries to enable these features. Here's what you'll need to define:

1. OAuth Scopes

You'll need to request the necessary permissions for your add-on to interact with Gmail data and settings. Add these to the oauthScopes array:

"oauthScopes": [
  "https://www.googleapis.com/auth/gmail.readonly",
  "https://www.googleapis.com/auth/gmail.modify",
  "https://www.googleapis.com/auth/gmail.settings.basic"
]
  • gmail.readonly: Lets your add-on read email metadata and content.
  • gmail.modify: Permits creating/modifying labels and updating email properties.
  • gmail.settings.basic: Required for creating email filters.

2. Homepage Trigger (For "Always Visible" Behavior)

This trigger makes your add-on load in the sidebar whenever the user is on a main Gmail screen (inbox, label pages, etc.). Add this to your manifest:

"homepageTrigger": {
  "runFunction": "renderAddonHomepage",
  "enabled": true
}
  • renderAddonHomepage is the name of a server-side Apps Script function you'll write to generate the add-on's UI (using CardService) for the homepage view.

3. Universal Action (Optional, for Quick Access)

If you want to add a prominent button in Gmail's top bar to open your add-on, include a universalActions entry:

"universalActions": [
  {
    "label": "Open Email Manager",
    "runFunction": "renderAddonHomepage"
  }
]

4. Gmail Add-on Core Configuration

Define basic details for your add-on under the gmail field:

"gmail": {
  "name": "My Email Manager Add-on",
  "logoUrl": "https://your-domain.com/addon-logo.png",
  "primaryColor": "#4285F4",
  "secondaryColor": "#34A853",
  "contextualTriggers": []
}
  • Leave contextualTriggers empty since you don't need the add-on to trigger only when opening individual emails.

5. Advanced Services Dependency

Since you'll be using the Gmail API directly, declare it as an enabled advanced service:

"dependencies": {
  "enabledAdvancedServices": [
    {
      "userSymbol": "Gmail",
      "serviceId": "gmail",
      "version": "v1"
    }
  ]
}
Quick Notes
  • Permission Minimization: Make sure you only request the scopes you actually need—Google's add-on review process will scrutinize unnecessary permissions.
  • Pagination for Emails: When fetching multiple emails, handle the nextPageToken from the Gmail API to load more results if the user's inbox has a large number of messages.
  • UI Building: Use Google's CardService to create interactive components (like email lists, label creation forms, filter setup inputs) for your add-on's sidebar.

内容的提问来源于stack exchange,提问作者user1410569

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:55:38