使用 Google Workspace 插件扩展 Gmail 的功能
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
许多电子邮件的目的是让收件人完成特定任务或实现特定目标,例如添加日历活动、填写表单、进行预订或使用其他应用。不过,收件人随后必须在没有任何进一步提示的情况下完成任务,这通常需要执行许多手动步骤。
您可以使用 Google Workspace 插件自动执行这些任务,从而为用户节省时间和精力。当用户在 Gmail 中阅读或撰写邮件时,Google Workspace 加载项可以显示交互式自定义界面,让用户以各种方式处理邮件,例如:
- 在 Gmail 界面中显示用户的其他信息。
- 连接到非 Google 服务,以检索信息或执行其他操作。
- 提供控制插件行为或向其他服务发送信息的方法。
Google Workspace 插件可在 Gmail 中定义以下类型的扩展程序:
此外,可扩展 Gmail 的 Google Workspace 插件可在桌面设备和移动设备客户端上运行。
Gmail 首页
Gmail 支持显示 Google Workspace 插件的首页。
如需在 Gmail 中显示插件的通用首页,只需确保插件的清单中包含 addOns.gmail
字段即可。
或者,您也可以向插件清单添加 gmail.homepageTrigger
,以提供特定于 Gmail 的首页。
无论哪种情况,您都必须在插件的脚本项目中提供首页触发函数的名称。此函数会在需要时自动调用,以构建 Gmail 首页。您必须实现此函数,以构建并返回构成首页的单个 Card
或 Card
对象数组。首页触发函数会收到一个事件对象作为参数,其中包含一些常规信息,例如客户端的平台。您可以使用事件对象数据来定制首页的构建。
了解您可以制作的内容
Google Workspace 插件是使用 Apps 脚本构建的,其界面是使用 Apps 脚本的 Card 服务定义的。如需了解概览,请参阅构建 Google Workspace 加购项。Google Workspace 加购项的行为通过清单进行配置,其中包括特定于 Gmail 的部分。
在配置 Google Workspace 插件以扩展 Gmail 时,您必须确定要为插件创建哪些界面以及插件可以执行哪些操作。如需了解详情,请参阅以下指南:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):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)"]]