Package google.apps.script.type.gmail
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
DraftAccess
用于定义 Compose 触发器所需数据访问权限级别的枚举。
枚举 |
UNSPECIFIED |
未为 draftAccess 设置任何值时的默认值。 |
NONE |
触发 Compose 插件时,Compose 触发器无法访问草稿的任何数据。 |
METADATA |
向 Compose 触发器授予在触发 Compose 插件时访问草稿元数据的权限。这包括受众群体名单,例如草稿邮件的“收件人”和“抄送”列表。 |
ContextualTrigger
定义在打开的电子邮件符合特定条件时触发的触发器。触发器触发时,它会执行特定端点,通常是为了创建新卡片和更新界面。
字段 |
onTriggerFunction |
string
必需。当消息与触发器匹配时要调用的端点的名称。
|
联合字段 trigger 。触发器类型决定了 Gmail 用于显示该插件的一些条件。trigger 只能是下列其中一项: |
unconditional |
UnconditionalTrigger
在任何邮件被打开时,系统都会执行无条件触发器。
|
GmailAddOnManifest
用于自定义 Gmail 插件外观和执行方式的属性。
字段 |
homepageTrigger |
HomepageExtensionPoint
定义将在与声明的上下文触发器不匹配的上下文中执行的端点。此函数生成的任何卡片始终可供用户使用,但当此插件声明更具针对性的触发器时,这些卡片可能会被内容相关内容所掩盖。 如果存在,则会覆盖 addOns.common.homepageTrigger 中的配置。
|
contextualTriggers[] |
ContextualTrigger
定义触发插件的一组条件。
|
universalActions[] |
UniversalAction
为插件定义一组通用操作。用户从插件工具栏菜单中触发通用操作。
|
composeTrigger |
ComposeTrigger
为构建时间插件定义构建时间触发器。此触发器会在用户撰写电子邮件时导致插件执行操作。所有 Compose 时间插件都必须具有 gmail.addons.current.action.compose 作用域,即使它可能不会修改草稿也是如此。
|
authorizationCheckFunction |
string
端点的名称。该端点会通过探测第三方 API 来验证插件是否拥有所有必要的第三方授权。如果探测失败,该函数应抛出异常以启动授权流程。系统会在每次调用插件之前调用此函数,以确保顺畅的用户体验。
|
UnconditionalTrigger
此类型没有字段。
UniversalAction
无论邮件上下文如何,此操作始终可在插件工具栏菜单中使用。
字段 |
text |
string
必需。用于描述相应操作的用户可见文本,例如“添加新联系人”。
|
联合字段 action_type 。操作的类型决定了用户调用操作时 Gmail 的行为。action_type 只能是下列其中一项: |
openLink |
string
用户触发操作时 Gmail 打开的链接。
|
runFunction |
string
在用户触发操作时调用的端点。如需了解详情,请参阅通用操作指南。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-22。
[null,null,["最后更新时间 (UTC):2025-04-22。"],[[["\u003cp\u003eThis documentation outlines the schema for Gmail add-ons, including triggers and actions.\u003c/p\u003e\n"],["\u003cp\u003eIt covers several trigger types like \u003ccode\u003eComposeTrigger\u003c/code\u003e, \u003ccode\u003eContextualTrigger\u003c/code\u003e, and \u003ccode\u003eUnconditionalTrigger\u003c/code\u003e which define when the add-on activates.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGmailAddOnManifest\u003c/code\u003e describes the add-on's overall configuration, including triggers, homepage behavior, and universal actions.\u003c/p\u003e\n"],["\u003cp\u003eUniversal actions, defined by \u003ccode\u003eUniversalAction\u003c/code\u003e, are always available in the add-on toolbar, allowing users to perform actions like opening links or running functions.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can control data access levels and customize user interface elements through various fields and properties within these schemas.\u003c/p\u003e\n"]]],["The content outlines triggers and actions for Gmail add-ons. `ComposeTrigger` activates during email composition, defining actions and draft data access levels (None, Metadata). `ContextualTrigger` fires based on email criteria, executing an endpoint, with `UnconditionalTrigger` firing on any opened email. `GmailAddOnManifest` customizes the add-on, specifying homepage and contextual triggers, universal actions, and compose triggers. `UniversalAction` provides actions accessible from the add-on's toolbar, either opening a link or running an endpoint.\n"],null,["# Package google.apps.script.type.gmail\n\nIndex\n-----\n\n- [ComposeTrigger](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.ComposeTrigger) (message)\n- [ComposeTrigger.DraftAccess](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.ComposeTrigger.DraftAccess) (enum)\n- [ContextualTrigger](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.ContextualTrigger) (message)\n- [GmailAddOnManifest](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.GmailAddOnManifest) (message)\n- [UnconditionalTrigger](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.UnconditionalTrigger) (message)\n- [UniversalAction](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.UniversalAction) (message)\n\nComposeTrigger\n--------------\n\nA trigger that activates when user is composing an email.\n\n| Fields ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `actions[]` | [MenuItemExtensionPoint](/workspace/add-ons/reference/rpc/google.apps.script.type#google.apps.script.type.MenuItemExtensionPoint) Defines the set of actions for a compose time add-on. These are actions that users can trigger on a compose time add-on. |\n| `draftAccess` | [DraftAccess](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.ComposeTrigger.DraftAccess) Defines the level of data access when a compose time add-on is triggered. |\n\nDraftAccess\n-----------\n\nAn enum that defines the level of data access the compose trigger requires.\n\n| Enums ||\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `UNSPECIFIED` | Default value when nothing is set for draftAccess. |\n| `NONE` | The compose trigger can't access any data of the draft when a compose add-on is triggered. |\n| `METADATA` | Gives the compose trigger the permission to access the metadata of the draft when a compose add-on is triggered. This includes the audience list, such as the To and Cc list of a draft message. |\n\nContextualTrigger\n-----------------\n\nDefines a trigger that fires when the open email meets a specific criteria. When the trigger fires, it executes a specific endpoint, usually in order to create new cards and update the UI.\n\n| Fields ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `onTriggerFunction` | `string` Required. The name of the endpoint to call when a message matches the trigger. |\n| Union field `trigger`. The type of trigger determines the conditions Gmail uses to show the add-on. `trigger` can be only one of the following: ||\n| `unconditional` | [UnconditionalTrigger](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.UnconditionalTrigger) Unconditional triggers are executed when any mail message is opened. |\n\nGmailAddOnManifest\n------------------\n\nProperties customizing the appearance and execution of a Gmail add-on.\n\n| Fields ||\n|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `homepageTrigger` | [HomepageExtensionPoint](/workspace/add-ons/reference/rpc/google.apps.script.type#google.apps.script.type.HomepageExtensionPoint) Defines an endpoint that will be executed in contexts that don't match a declared contextual trigger. Any cards generated by this function will always be available to the user, but may be eclipsed by contextual content when this add-on declares more targeted triggers. If present, this overrides the configuration from `addOns.common.homepageTrigger`. |\n| `contextualTriggers[]` | [ContextualTrigger](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.ContextualTrigger) Defines the set of conditions that trigger the add-on. |\n| `universalActions[]` | [UniversalAction](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.UniversalAction) Defines a set of [universal actions](/gmail/add-ons/how-tos/universal-actions) for the add-on. The user triggers universal actions from the add-on toolbar menu. |\n| `composeTrigger` | [ComposeTrigger](/workspace/add-ons/reference/rpc/google.apps.script.type/gmail#google.apps.script.type.gmail.ComposeTrigger) Defines the compose time trigger for a compose time add-on. This is the trigger that causes an add-on to take action when the user is composing an email. All compose time add-ons must have the `gmail.addons.current.action.compose` scope even though it might not edit the draft. |\n| `authorizationCheckFunction` | `string` The name of an endpoint that verifies that the add-on has all the required third-party authorizations, by probing the third-party APIs. If the probe fails, the function should throw an exception to initiate the authorization flow. This function is called before each invocation of the add-on in order to ensure a smooth user experience. |\n\nUnconditionalTrigger\n--------------------\n\nThis type has no fields.\nA trigger that fires when any email message is opened.\n\nUniversalAction\n---------------\n\nAn action that is always available in the add-on toolbar menu regardless of message context.\n\n| Fields ||\n|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `text` | `string` Required. User-visible text describing the action, for example, \"Add a new contact.\" |\n| Union field `action_type`. The type of the action determines the behavior of Gmail when the user invokes the action. `action_type` can be only one of the following: ||\n| `openLink` | `string` A link that is opened by Gmail when the user triggers the action. |\n| `runFunction` | `string` An endpoint that is called when the user triggers the action. See the [universal actions guide](/gmail/add-ons/how-tos/universal-actions) for details. |"]]