單鍵操作

「單鍵操作」可讓使用者直接在收件匣中執行各項操作,不必離開 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 的說明文件。