一键式操作
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助一键操作,用户可以直接在收件箱中执行操作,而无需离开 Gmail。通过声明包含服务网址的 HttpActionHandler
来执行一键式操作。如需了解详情,请参阅处理操作请求。
Gmail 中的一键操作。
使用场景
Gmail 目前支持的一键操作包括:
确认操作
您可以向需要用户批准、确认和确认收到的电子邮件添加一键确认按钮。用户点击该按钮后,Google 会向您的服务发出 HTTP 请求,记录确认信息。ConfirmAction
只能互动一次。
以下声明向有关费用报告的电子邮件添加了一个 ConfirmAction
按钮:
JSON-LD
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ConfirmAction",
"name": "Approve Expense",
"handler": {
"@type": "HttpActionHandler",
"url": "https://myexpenses.com/approve?expenseId=abc123"
}
},
"description": "Approval request for John's $10.13 expense for office supplies"
}
</script>
微数据
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Approve Expense"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://myexpenses.com/approve?expenseId=abc123"/>
</div>
</div>
<meta itemprop="description" content="Approval request for John's $10.13 expense for office supplies"/>
</div>
保存操作
SaveAction
可用于描述保存优惠券或将歌曲添加到收听队列等互动。SaveAction
只能互动一次。
以下声明会向有关优惠的电子邮件添加 SaveAction
按钮:
JSON-LD
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "SaveAction",
"name": "Save Offer",
"handler": {
"@type": "HttpActionHandler",
"url": "https://offers-everywhere.com/save?offerId=xyz789"
}
},
"description": "$5 meal at Joe's Diner"
}
</script>
微数据
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/SaveAction">
<meta itemprop="name" content="Save Offer"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://offers-everywhere.com/save?offerId=xyz789"/>
</div>
</div>
<meta itemprop="description" content="$5 meal at Joe's Diner"/>
</div>
测试您的标记
您可以使用电子邮件标记测试工具验证标记。粘贴您的标记代码,然后点击验证按钮扫描内容,并接收有关是否存在任何错误的报告。
规范
如需了解这些操作可用的属性,请参阅有关特定类型 ConfirmAction 和 SaveAction 的文档。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# One Click Actions\n\nOne-click actions allow users to perform operations directly from the inbox without having to leave Gmail. One-click actions are performed by declaring an `HttpActionHandler` with your service URL. For more details, refer to [Handling Action Requests](../actions/handling-action-requests).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nOne-click actions in Gmail.\n\n\u003cbr /\u003e\n\nUse Cases\n---------\n\nOne Click actions currently supported in Gmail are:\n\n- [ConfirmAction](#confirm_action)\n- [SaveAction](#save_action)\n\n| **Note:** Before you start, make sure you understand how to [embed schemas in emails](/workspace/gmail/markup/embedding-schemas-in-emails) and you are familiar with [testing schemas](/workspace/gmail/markup/testing-your-schema).\n\nConfirm Action\n--------------\n\nYou may add a one-click confirm button to emails requiring users to approve, confirm and acknowledge something. Once the user clicks on the button, an http request will be issued from Google to your service, recording the confirmation. `ConfirmAction` can only be interacted with **once**.\n\nThe following declaration adds a `ConfirmAction` button to an email about an expense report: \n\n### JSON-LD\n\n \u003cscript type=\"application/ld+json\"\u003e\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"EmailMessage\",\n \"potentialAction\": {\n \"@type\": \"ConfirmAction\",\n \"name\": \"Approve Expense\",\n \"handler\": {\n \"@type\": \"HttpActionHandler\",\n \"url\": \"https://myexpenses.com/approve?expenseId=abc123\"\n }\n },\n \"description\": \"Approval request for John's $10.13 expense for office supplies\"\n }\n \u003c/script\u003e\n\n### Microdata\n\n \u003cdiv itemscope itemtype=\"http://schema.org/EmailMessage\"\u003e\n \u003cdiv itemprop=\"potentialAction\" itemscope itemtype=\"http://schema.org/ConfirmAction\"\u003e\n \u003cmeta itemprop=\"name\" content=\"Approve Expense\"/\u003e\n \u003cdiv itemprop=\"handler\" itemscope itemtype=\"http://schema.org/HttpActionHandler\"\u003e\n \u003clink itemprop=\"url\" href=\"https://myexpenses.com/approve?expenseId=abc123\"/\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003cmeta itemprop=\"description\" content=\"Approval request for John's $10.13 expense for office supplies\"/\u003e\n \u003c/div\u003e\n\nSave Action\n-----------\n\n`SaveAction` can be used to describe interactions like saving a coupon or adding songs to the listen queue. `SaveAction` can only be interacted with **once**.\n\nThe following declaration adds a `SaveAction` button to an email about an offer: \n\n### JSON-LD\n\n \u003cscript type=\"application/ld+json\"\u003e\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"EmailMessage\",\n \"potentialAction\": {\n \"@type\": \"SaveAction\",\n \"name\": \"Save Offer\",\n \"handler\": {\n \"@type\": \"HttpActionHandler\",\n \"url\": \"https://offers-everywhere.com/save?offerId=xyz789\"\n }\n },\n \"description\": \"$5 meal at Joe's Diner\"\n }\n \u003c/script\u003e\n\n### Microdata\n\n \u003cdiv itemscope itemtype=\"http://schema.org/EmailMessage\"\u003e\n \u003cdiv itemprop=\"potentialAction\" itemscope itemtype=\"http://schema.org/SaveAction\"\u003e\n \u003cmeta itemprop=\"name\" content=\"Save Offer\"/\u003e\n \u003cdiv itemprop=\"handler\" itemscope itemtype=\"http://schema.org/HttpActionHandler\"\u003e\n \u003clink itemprop=\"url\" href=\"https://offers-everywhere.com/save?offerId=xyz789\"/\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003cmeta itemprop=\"description\" content=\"$5 meal at Joe's Diner\"/\u003e\n \u003c/div\u003e\n\nTest your markup\n----------------\n\nYou can validate your markup using the [Email Markup Tester Tool](https://www.google.com/webmasters/markup-tester/). Paste in your markup code and click the **Validate** button to scan the content and receive a report on any errors present.\n\nSpecification\n-------------\n\nFor properties available to these actions, refer to the documentation for the\nspecific types [ConfirmAction](/workspace/gmail/markup/reference/types/ConfirmAction) and\n[SaveAction](/workspace/gmail/markup/reference/types/SaveAction).\n| **Note:** Some of the schemas used by Google are still going through the standardization process of [schema.org](http://schema.org), and therefore, may change in the future. [Learn More](/workspace/gmail/markup/reference/schema-org-proposals)."]]