使用者只要按一下滑鼠,即可直接在收件匣中執行作業,不必離開 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 的說明文件。