一键式操作

通过一键操作,用户无需离开 Gmail 即可直接在收件箱中执行操作。通过使用服务网址声明 HttpActionHandler 来执行一键式操作。如需了解详情,请参阅处理操作请求

Gmail 中的确认按钮
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>

测试您的标记

您可以使用电子邮件标记测试工具验证您的标记。粘贴您的标记代码,然后点击验证按钮以扫描内容,然后在出现任何错误时接收报告。

规范

如需了解这些操作可用的属性,请参阅特定类型 ConfirmActionSaveAction 的文档。