單鍵操作

使用者只要按一下,就能直接在收件匣中執行作業,不必離開 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>

測試標記

您可以使用電子郵件標記測試工具驗證標記。貼上標記程式碼,然後按一下「驗證」按鈕掃描內容,並取得錯誤報表。

規格

如要瞭解這些動作可用的屬性,請參閱特定類型「ConfirmAction」ConfirmAction和「SaveAction」SaveAction的說明文件。