הצהרה על פעולות

ב-schema.org, פעולה מייצגת פעילות שאפשר לבצע על חלק של נתונים מובְנים. ‫Gmail תומך בכמה סוגים של פעולות, ואפשר להגדיר כל אחת מהן באמצעות נתונים מובנים דומים.

פעולות מעבר

אם מוסיפים תגי עיצוב לתוכן עם ישויות של schema.org, אפשר להוסיף להן פעולות מעבר. לדוגמה, כדי לתת לישות EmailMessage קישור ViewAction, מאכלסים את המאפיין potentialAction של האימייל, כמו בדוגמה הבאה:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ViewAction",
    "target": "https://watch-movies.com/watch?movieId=abc123",
    "name": "Watch movie"
  },
  "description": "Watch the 'Avengers' movie online"
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="target" href="https://watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="name" content="Watch movie"/>
  </div>
  <meta itemprop="description" content="Watch the 'Avengers' movie online"/>
</div>

תוכנות אימייל אחרות שלא תומכות בסכימות באימיילים מתעלמות באופן אוטומטי מתגי העיצוב האלה.

קישורי עומק באפליקציות לנייד

פעולות מעבר יכולות גם לקשר ישירות לתוכן באפליקציות לנייד ב-Android וב-iOS. כדי ליצור קישור עומק לאפליקציה, צריך לכלול כתובות URL נוספות של target שמקודדות באמצעות הסכימות android-app:// ו-ios-app://, כמו בדוגמאות הבאות:

JSON-LD

"target": [
  "<web url>",
  "android-app://<android package name>/<scheme>/<host>/<path+query>",
  "ios-app://<App store ID>/<scheme>/<host><path+query>"
]

מיקרו נתונים

<link itemprop="target" href="<web url>"/>
<link itemprop="target" href="android-app://<android package name>/<scheme>/<host>/<path+query>"/>
<link itemprop="target" href="ios-app://<App store ID>/<scheme>/<host>/<path+query>"/>

הנה דוגמה נוספת לשימוש ב-EmailMessage:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "name": "Watch movie",
  ... information about the movie ...
  "potentialAction": {
    "@type": "ViewAction",
    "target": [
      "https://watch-movies.com/watch?movieId=abc123",
      "android-app://com.watchmovies.app/http/watch-movies.com/watch?movieId=abc123",
      "ios-app://12345/movieapp/watch-movies.com/watch?movieId=abc123"
    ]
  }
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <meta itemprop="name" content="Watch movie"/>
  ... information about the movie ...
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
    <meta itemprop="target" content="https://watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="target" content="android-app://com.watchmovies.android/http/watch-movies.com/watch?movieId=abc123"/>
    <meta itemprop="target" content="ios-app://12345/movieapp/watch-movies.com/watch?movieId=abc123"/>
 </div>
</div>

אם האפליקציה לא מותקנת אצל המשתמש, הפעולה תעביר אותו לכתובת ה-URL של האתר שציינתם.

פעולות בתוך האפליקציה

‫Gmail מטפל בפעולות בתוך האפליקציה במקום, בלי להפנות את המשתמש לאתר אחר. מצהירים על פעולות בתוך האפליקציה, כמו פעולות מעבר, אבל כוללים מידע נוסף שעוזר ללקוחות אימייל (כמו Gmail) לטפל בפעולה בתוך השורה.

במקום להצהיר על פעולה עם target, צריך להצהיר על HttpActionHandler לפעולה עם ההגדרה המתאימה.

לדוגמה, אפשר להוסיף כפתור אישור לאימיילים שבהם נדרש מהמשתמשים לאשר, לאמת או לאשר קבלה של משהו. כשהמשתמש לוחץ על הלחצן, 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>

פעולות שתוקפן עומד לפוג

במקרים רבים, פעולות רלוונטיות רק לפרק זמן מוגבל. התוקף של פעולות שמשויכות לישויות עם תאריכים ידועים, כמו הזמנות נסיעה, פג באופן אוטומטי. הפעולה לא מוצגת ב-Gmail אחרי שהנסיעה מסתיימת.

אפשר גם להוסיף תאריכי תפוגה לפעולות באופן מפורש. לדוגמה, פעולה של גזירת שובר או שמירת קוד מבצע עשויה להיות תקפה רק לזמן מוגבל. כדי להגדיר את חלון הזמן שבו תוצג פעולה, מגדירים את המאפיינים startTime ו-endTime של הפעולה:

JSON-LD

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "potentialAction": {
    "@type": "ConfirmAction",
    "name": "Save coupon",
    "handler":  {
       "@type": "HttpActionHandler",
       "url": "https://my-coupons.com/approve?couponId=abc123"
    },
    "startTime": "2015-06-01T12:00:00Z",
    "endTime": "2015-06-05T12:00:00Z"
  }
}
</script>

מיקרו נתונים

<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
    <meta itemprop="name" content="Save coupon"/>
    <div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
      <link itemprop="url" href="https://my-coupons.com/approve?couponId=abc123"/>
    </div>
    <meta itemprop="startTime" content="2015-06-01T12:00:00Z" />
    <meta itemprop="endTime" content="2015-06-05T12:00:00Z" />
  </div>
</div>

קריאה נוספת

פרטים נוספים על פעולות זמינים במאמרים הבאים: