Play Reversi Using SendGrid


Posted on

The following is a guest post by Wataru Sato, a developer who works with SendGrid in Japan. He has a blog at http://awwa500.blogspot.jp/ and you can find his GitHub page here: https://github.com/awwa.

Reversi with emailI’m from Japan and work with SendGrid there. SendGrid is a powerful email service that sends a large number of emails every day. However, SendGrid’s APIs can also be used for fun!

Today, I created a game using SendGrid. It’s called SendGrid-Reversi, and it let’s you play Reversi entirely over email!

It runs on Sinatra, the data is stored in MongoDB, and the functionality is built on top of the various SendGrid APIs.

Launch the Application

Clone the repo, and follow the instructions. On launch, the application begins configuring itself automatically by:

  • Creating templates and versions via Template Engine.
  • Configuring some of Apps via Web API.
  • Configuring the Parse Webhook.
  • Configuring and enabling Event Notifications.
  • Enabling Click Tracking.

Start Reversi With an Email

You start a game by sending an email to the application with the subject set to a friend’s email address. Using SendGrid’s Parse Webhook, the application receives the email, parses the friend’s email address from the subject, and begins the game.

The App Sends Emails to Each Player

Each player receives an email. This email includes the game board (above picture) using the Template Engine. Additionally, some tags are substituted by the SMTP API (Substitution tags).

Click to Play – In the Email!

The player then clicks in the email where they want to place a disc on a cell. It’s that easy! This click event is POSTed to the application from SendGrid. The application processes the event, and sends emails to each player again.

In this way, you can play Reversi entirely over email. Amazing, yes.

Additionally, the BCC App can be used to log game histories. Then you can add in the New Relic and Open Tracking App to analyze a game.

This is just a simple demo application, but these same API elements could be applied in your own application. Have fun, and come visit beautiful Japan!


Have thoughts on this post?
Chat with us about it on Twitter and Google+