Send and Track Email with Google Glass Elmer Thomas November 15, 2013 Product, Technical // SUMMARIES ?> Photo by Giuseppe Costantino Currently, sending an email with Google Glass is trivial, you just say “OK Glass, send a message to [Name]” and dictate your message. Done. If you want a similar experience for your Glassware’s users and also the ability to track those emails (opens, clicks, bounces, etc.), SendGrid is your solution. This post provides the information needed to send and track emails via Glass using the Google Mirror API and SendGrid’s Python library. The methods outlined here should be similar for integrating with other Glassware supported languages. You can find our complete list of official libraries at our documentation. To get started, if you are new to the Google Mirror API, I suggest you take the time to read through the Overview and Quick Start guides before continuing with this post. Then try the Quick Start Project Demo which we will re-create on a Google App Engine instance. Now, we need to create the Glassware. In this case, I chose Python and you can begin with the Python Quick Start guide. Here are a few tips that may help you get through the Quick Start even quicker, particularly when using the new Cloud Console interface: Set authentication under the Application Settings in your Google App Engine console: Authentication Type = Google Accounts API For step 2, if you are using the new Cloud Console interface, instead of clicking Services to enable the Google Mirror API, you will choose APIs under the APIs & Auth section in the menu. For step 3, in the new Cloud Console interface the API Access section is now located at APIs & Auth -> Registered apps. For step 4, these settings are located under APIs & Auth -> Consent screen in the new interface. Steps 5 & 6 are performed on the APIs & Auth -> Registered Apps section within the new interface. Specifically, you’ll click the Register App button to create your Web App as described in step 5, then once created, click on the Web App’s name to edit the client settings as described in step 6. You will also find the Client ID and Client Secret as mentioned in in step 7 here. Before going to the “Configure the project” section, go ahead and clone the mirror-quickstart-python project. Then once you get to the “Deploying the project” step, you should be able to go to your newly created web app and view a screen similar to this one. If not, ping me and I’ll try to help. Using this web interface you can try out many of the key features of the Mirror API directly from your browser, then inspect and modify the corresponding code. Now, lets get to the sending email part. SendGrid makes this process easy by providing you with a open source library. As a quick test you can integrate with the library in the main_handler.py file, inside the render_template function within the MainHandler class. When you hit the URL of your app, an email should have been triggered and received in your inbox. Tracking emails can be done one of three ways. First, you can simply login to SendGrid.com and click on the Statistics, Email Activity or Email Reports tabs. Secondly, you can utilize our Event API and setup a webhook to listen for events such as opens and clicks and we’ll post them to your URL in near real-time. Thirdly, you can use our Web API and pull down the statistics as needed. I suggest you read the 5 Best Practices for Using SendGrid with Google App Engine for more details and more ideas for deep integrating email into your app, including handling incoming emails. The following resources should prove useful as you continue exploring with Glass: Playground (Card Simulator) Glass Downloads Glass GitHub Mirror API tag on StackOverflow Bug Reports Note that when in the Playground, you may come across an authentication error, which is solved here. Now, you have the raw tools using Python and the Google Mirror API to incorporate emails into your hosted Glassware. If you choose to use another language, please see our other libraries. If you have a particular example you would like to see, please let me know in the comments or shoot me an email.