2014年1月26日日曜日

Trying out Google Now

I tried using a sample app that Devnook created that enables you to send emails with embedded structured data in gmail. Those embedded structured data are used in Google Now too.

Source code: https://github.com/devnook/google-now
Deployed environment: gmail-actions.appspot.com

Several sample tests:

1. One click action test

<html>
  <head>
    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "EmailMessage",
      "description": "Approval request for John's $10.13 expense for office supplies",
      "action": {
        "@type": "ConfirmAction",
        "name": "Approve Expense",
        "handler": {
          "@type": "HttpActionHandler",
          "url": "http://gmail-actions.appspot.com/success/AHRlWrqkhM0P6ZxW3u-P4nBk1eip-mh650NKMzdMXuUNlLJitOhhrDYTv8zpac5OpEELdjeTht5zBqYD1sVSIOvnl2vEQCLI8ur4wsSThoixnHJrH50a6m5mfuQGmcGsS-U7QMSszwiR"
        }
      }
    }
    </script>
  </head>
  <body>

      This a test for a One-click action in Gmail.

  </body>
</html>

And you get email with one click action.


2. Rate Action test
<html>
  <head>
    <script type="application/ld+json">
      {
        "@context": "http://schema.org",
        "@type": "EmailMessage",
        "description": "We hope you enjoyed your meal at Joe's Diner. Please rate your experience.",
        "action": {
          "@type": "ReviewAction",
          "review": {
            "@type": "Review",
            "itemReviewed": {
              "@type": "FoodEstablishment",
              "name": "Joe's Diner"
            },
            "reviewRating": {
              "@type": "Rating",
              "bestRating": "5",
              "worstRating": "1"
            }
          },
          "handler": {
            "@type": "HttpActionHandler",
            "url": "http://gmail-actions.appspot.com/success/AHRlWrqkhM0P6ZxW3u-P4nBk1eip-mh650NKMzdMXuUNlLJitOhhrDYTv8zpac5OpEELdjeTht5zBqYD1sVSIOvnl2vEQCLI8ur4wsSThoixnHJrH50a6m5mfuQGmcGsS-U7QMSszwiR",
            "requiredProperty": {
              "@type": "Property",
              "name": "review.reviewRating.ratingValue"
            },
            "method": "http://schema.org/HttpRequestMethod/POST"
          }
        }
      }
    </script>
  </head>
  <body>
    <p>
      This a test for a Rate action in Gmail.
    </p>
  </body>
</html>

And you get email with rate action.



3.Restaurant reservation

<html>
  <head>
    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "FoodEstablishmentReservation",
      "reservationNumber": "OT12345",
      "underName": {
        "@type": "Person",
        "name": "John Smith"
      },
      "reservationFor": {
        "@type": "FoodEstablishment",
        "name": "Wagamama",
        "telephone": "044755755755",
        "address": {
          "@type": "PostalAddress",
          "streetAddress": "1 Tavistock Street",
          "addressLocality": "London",
          "addressRegion": "Greater London",
          "postalCode": "WC2E 7PG",
          "addressCountry": "United Kingdom"
        }
      },
      "startTime": "",
      "partySize": "2",
    "reservationStatus": "confirmed",
    "modifiedTime": "2013-11-03T21:00:00+01:00",
    "modifyReservationUrl": "http://gmail-actions.appspot.com/success/AHRlWrqkhM0P6ZxW3u-P4nBk1eip-mh650NKMzdMXuUNlLJitOhhrDYTv8zpac5OpEELdjeTht5zBqYD1sVSIOvnl2vEQCLI8ur4wsSThoixnHJrH50a6m5mfuQGmcGsS-U7QMSszwiR"
    }
    </script>
  </head>
  <body>
    <p>
      This a test for a Restaurant reservation Google Now card in Gmail.
    </p>
  </body>
</html>

And you get email with the action to change your reservation.



Actions you can use: https://developers.google.com/gmail/actions/actions/actions-overview

Google Now Card schemas: https://developers.google.com/schemas/now/cards

Disclaimer: The opinions expressed here are my own, and do not reflect those of my employer. -Fumi Yamazaki

0 件のコメント:

コメントを投稿