So, it was all too well that Google announced the Gmail API at Google IO around a week back. I quickly scanned through the API and found that it was reasonably well documented and with easy to use endpoints to play around with my emails in Gmail.
To test the functionality of the API, I decided to build a Gmail alternative using the API. I wanted to see how much of a functionality of Gmail I could recreate. I wanted to see if I could build something, using which I could perform my daily email operations without using Gmail directly. Turns out, it is possible to do exactly that using the API. So, in this post, I will give a brief description of how I achieved that. At the end, I will list some innovative ideas that can be built on the Gmail API.
The first step was to get the right authorization tokens to use the Gmail API. I created a new project at the Google developer console and enabled the Gmail API and got the required credentials.
The next step was to develop a simple program which would authorize my requests to Google services using OAuth2. A simple Google search directed me to https://code.google.com/p/google-oauth-java-client/wiki/OAuth2 and using the code samples it was pretty easy to set up a simple authorization servlet to get the credentials(access token and refresh token)
2. Querying Gmail Service
Armed with the credentials, it was pretty straight forward to query the Gmail API to get the email details. Using the code samples provided at https://developers.google.com/gmail/api/overview I created a simple helper class to search,get,send and delete(CRUD) emails. You can find the helper class at github.
3. Creating the front end
Once the backend was done, the front end plumbing had to be done. A Google search for "Bootstrap Gmail Layout" gave the code snippet at http://bootsnipp.com/snippets/featured/gmail-inbox
Using the Bootstrap layout and combining that with Angularjs, I created services in Angularjs to access the CRUD services in the backend helper class.
And we are done. By reusing code samples, I was able to hack together a simple Gmail replacement in a couple of days. This is completely functional and I use it daily as my Gmail client.
While working with the API a couple of ideas sprung to my mind. Just listing them out here in case anyone wants to work on them. In fact, I will go one step further. Since I personally believe that Email is a major communication tool ready for disruption, if any student startup wants to work on any of the below ideas or any other email API idea, we will provide free mentorship at Ozonetel. Please send me a mail at email@example.com
1. Gmail Ticketing System
Making use of labels in Gmail, we can create a simple ticketing system. As soon as an email comes, we can mark the email as Open. Use the Gmail API to list all open emails. On replying to the support email, we can remove the UNREAD label and Open label and add Closed,Pending or Resolved label depending on the context. So basically, we use labels to move the email ticket from one state to another until it reaches a logical conclusion.
Since Gmail allows an email to have any number of labels, we can think of different combinations to achieve our goals. For example, we can add an agent name as a label to assign a ticket to the agent and move the ticket from one agent to another.
By the same logic, we can even build a CRM system on top of Gmail. So then your CRM sits in your inbox.
Checkout the working version of the Gmail Ticketing Protoype(not working right now). Go ahead. I am not storing any credentials and everything will be reset everyday. The code for this will be open sourced in a couple of weeks once I clean up the code(Updated: Code available at https://github.com/nutanc/gmail_tickets). This is very basic right now with almost no error checking. Just built as a proof of concept.
2. Gmail Alerting and response system
Since most monitoring systems send an email on an event, it is trivial to develop a program which queries Gmail for a mail with a particular subject and then take action when such an email exists. For example, you could use KooKoo to make an outbound call and alert you about the event. You can also create a intelligent out of office message system.
3. Email Analytics
Where do you spend most of your time? Who do you mail the most? What do you mail the most? When do you get the most mails?
4.Task Management system on Gmail
Build a task management system like Asana on top of email. Use labels to assign emails to projects and teammates.
5. Call and listen to your mail
Mashup KooKoo with Gmail to have a simple voicemail feature. All mails to your email account become your voicemail :)
Email is the lowest common denominator for non tech savvy people. Everyone now knows how to send an email. They may not know how to tweet or how to 'like' a page. But they can certainly email. Now, with API based access to email a lot of existing systems can be disrupted to work out of email. Ticketing, CRMs, Social messaging etc.
In case you are concerned with getting associated with Google and its APIs(they do have a bad history of removing APIs), you can also check out the new kid on the block, InboxApp, which provides an email platform for you to get your work done.