運用 Google Workspace 外掛程式擴充 Gmail 功能
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
許多電子郵件的目的是讓收件者執行特定工作或達成目標,例如新增日曆活動、填寫表單、預訂或使用其他應用程式。但收件者必須完成工作,且不會收到任何進一步提示,通常需要手動完成多個步驟。
您可以透過 Google Workspace 外掛程式自動執行這些工作,為使用者節省時間和精力。使用者在 Gmail 中讀取或撰寫郵件時,Google Workspace 外掛程式可以顯示互動式自訂 UI,讓使用者以各種方式處理郵件,例如:
- 在 Gmail 使用者介面中顯示使用者的其他資訊。
- 連線至非 Google 服務,以擷取資訊或採取其他動作。
- 提供控制外掛程式行為或將資訊傳送至其他服務的方法。
Google Workspace 外掛程式可在 Gmail 中定義下列擴充功能:
此外,擴充 Gmail 的 Google Workspace 外掛程式可在電腦和行動裝置用戶端上運作。
Gmail 首頁
Gmail 支援顯示 Google Workspace 外掛程式的首頁。如要在 Gmail 中顯示外掛程式的通用首頁,請務必在外掛程式資訊清單中加入 addOns.gmail
欄位。
或者,您也可以在外掛程式資訊清單中加入 gmail.homepageTrigger
,提供 Gmail 專屬首頁。
無論選擇哪一種做法,您都必須在外掛程式的指令碼專案中提供首頁觸發函式的名稱。系統會在需要時自動呼叫這個函式,以建構 Gmail 首頁。您必須實作這個函式,才能建構並傳回單一 Card
或 Card
物件陣列,組成首頁。首頁觸發函式會將事件物件當做參數傳遞,其中包含用戶端平台等一般資訊。您可以運用事件物件資料,量身打造首頁。
瞭解可製作的內容
Google Workspace 外掛程式是使用 Apps Script 建構而成,介面則使用 Apps Script Card 服務定義。如需概覽,請參閱「建構 Google Workspace 外掛程式」。Google Workspace 外掛程式的行為是透過資訊清單設定,其中包含 Gmail 專屬區段。
設定 Google Workspace 外掛程式以擴充 Gmail 時,您必須決定要為外掛程式建立哪些介面,以及外掛程式可執行的動作。詳情請參閱下列指南:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eGoogle Workspace add-ons automate tasks within Gmail, saving users time and effort by providing interactive UI elements within emails.\u003c/p\u003e\n"],["\u003cp\u003eAdd-ons enhance the Gmail experience by displaying extra information, connecting to external services, and letting users control add-on behavior.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can build custom add-ons with Apps Script and the Card service to extend Gmail's functionality on both desktop and mobile.\u003c/p\u003e\n"],["\u003cp\u003eGmail add-ons can have homepages, contextual interfaces triggered by opening or composing emails, and the ability to create new drafts automatically.\u003c/p\u003e\n"],["\u003cp\u003eTo learn more about building and configuring Gmail add-ons, explore the provided resources on extending UI, composing messages, manifests, and scopes.\u003c/p\u003e\n"]]],["Google Workspace add-ons automate tasks within Gmail, saving users time. They enable interactive UIs when users read or compose messages, allowing actions like displaying information, connecting to external services, and controlling add-on behavior. Add-ons can create contextual interfaces for messages and compose actions, or automatically generate drafts. Developers can define homepages and other interfaces, customize them with event objects, and use Apps Script to build and configure these add-ons through manifests. They support both desktop and mobile Gmail clients.\n"],null,["# Extending Gmail with Google Workspace add-ons\n\nThe purpose of many emails is to get the recipient to do a specific task or\nreach a goal, such as adding a calendar event, filling out a form, making a\nreservation, or using other applications. However, recipients then have to\ncomplete the task without any further prompting, often doing a number of\nmanual steps.\n\nYou can save time and effort for your users by automating these tasks with\nGoogle Workspace add-ons. When a user reads or composes a message in Gmail,\na Google Workspace add-on can present an interactive, customized UI that lets\nthe user act on the message in various ways, such as by:\n\n- Displaying additional information for the user in the Gmail UI.\n- Connecting to non-Google services, to retrieve information or take other actions.\n- Providing the means to control the add-on behavior or send information to another service.\n\n| **Note:** You can also [develop your own chatbots](/hangouts/chat) to enhance the Gmail experience.\n\nGoogle Workspace add-ons can define the following kinds of extensions within\nGmail:\n\n- [Homepages](/workspace/add-ons/concepts/homepages) and other non-contextual cards.\n- Contextual interfaces that appear when users [open Gmail messages](/workspace/add-ons/gmail/extending-message-ui).\n- Contextual interfaces that appear when a user [composes a message or reply](/workspace/add-ons/gmail/extending-compose-ui).\n- Automatically [create new message drafts](/workspace/add-ons/gmail/compose) in response to user interactions.\n\nIn addition, Google Workspace add-ons that extend Gmail do so on both desktop and mobile\nclients.\n\nGmail homepages\n---------------\n\nGmail supports displaying Google Workspace add-on\n[homepages](/workspace/add-ons/concepts/homepages).\nTo show your add-on's common homepage in Gmail simply make sure there\nis a [`addOns.gmail`](/apps-script/manifest/addons#AddOns.FIELDS.gmail)\nfield in the add-on's manifest.\n\nAlternatively, add a\n[`gmail.homepageTrigger`](/apps-script/manifest/gmail-addons#Gmail.FIELDS.homepageTrigger)\nto the add-on manifest to provide a Gmail-specific homepage.\n\nIn either case, you must provide the name of a homepage trigger function in your\nadd-on's script project. This function is automatically called to build the\nGmail homepage when it is needed. You must implement this function to build\nand return a single\n[`Card`](/apps-script/reference/card-service/card) or an array of\n[`Card`](/apps-script/reference/card-service/card)\nobjects that make up the homepage. The homepage trigger function is passed an\n[event object](/workspace/add-ons/concepts/event-objects)\nas a parameter that contains some general information such as the client's\nplatform. You can use the event object data to tailor the construction of the\nhomepage.\n\nSee what you can make\n---------------------\n\nGoogle Workspace add-ons are built using [Apps Script](/apps-script), and their\ninterfaces defined using the Apps Script\n[Card service](/apps-script/reference/card-service). See\n[Building Google Workspace add-ons](/workspace/add-ons/how-tos/building-workspace-addons)\nfor an overview. Google Workspace add-on behavior is configured using a\n[manifest](/workspace/add-ons/concepts/workspace-manifests), which includes\nGmail-specific sections.\n\nWhen configuring your Google Workspace add-on to extend Gmail, you must\ndecide what interfaces to create for your add-on and what actions it can take.\nSee the following guides for more information:\n\n- [Extending the message UI](/workspace/add-ons/gmail/extending-message-ui)\n- [Extending the compose UI with compose actions](/workspace/add-ons/gmail/extending-compose-ui)\n- [Compose draft messages](/workspace/add-ons/gmail/compose)\n- [Manifests](/workspace/add-ons/concepts/workspace-manifests)\n- [Gmail scopes](/workspace/add-ons/concepts/workspace-scopes#gmail_add-on_scopes)\n- Try a sample: [Analyze and label Gmail messages with Gemini and Vertex AI](/workspace/add-ons/samples/gmail-sentiment-analysis-ai)"]]