Skip to main content

Playing around with Gmail API

After recently being elevated to the post of Chief Innovation Officer at Ozonetel, the pressure was on me to come up with something innovative soon :)

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.

1. Authorize
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.
Gmail Caption


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.

Ideas
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 chaitanya@ozonetel.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 voice mail feature. All mails to your email account become your voice mail :)

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.

Popular posts from this blog

Integrating Arborjs with Angular to create a live calls dashboard

Arborjs  is a cool graph visualization library. Angular  is one of the best JavaScript frameworks and we have been using Angular in a lot of our front end development. When you handle millions of calls, proper visualization becomes very important. Without proper visualization, you can get lost in the mountains of data. So we spend a lot of time to come up with good visualizations to represent the data. Since we loved the cool way in which Arbor represented graph data, we could not wait to hook it up with Angular. Because of Angular's two way data binding, when you hook up Angularjs with Arbor.js you can get a dynamically updated visualization of graph data with cool animations. To give back to the community, we have put up the code online at Github . Basically we have created an Angularjs directive for Arborjs. Please feel free to fork the code and add extensions and use it for your own visualizations. The code is self explanatory with comments inline. Best way to get s

First Post

In this blog, I will be talking about my experiences in trying to build a cloud telephony platform , KooKoo . Along the way I will also be talking about different design choices I made, good programming practices and the IVR domain in general. For technoratti: NNFJW8EW86C3

KooKoo Contact Center integration with WhatsApp

WhatsApp announced the launch of their business API yesterday. This is a big deal. A lot of businesses have been asking for WhatsApp integration and now its a possibility. Twilio has already launched an integration . Won't be long before we see a lot more integrations pop up. The most obvious use case is for support chat bots, alerts and reminders. But we at Ozonetel believe one other use case will become the dominant use case, WhatsApp as a support channel with human agents. We believe WhatsApp will become a dominant channel in contact centers world wide. There are multiple reasons for this: WhatsApp is ubiquitous. Everyone has the app. WhatsApp interface is well known to all customers. It is feature rich. You can share audio, video, location etc in the app itself. You can integrate bots for repetitive tasks. Being the leaders in cloud contact center solutions, we at Ozonetel knew that we had to integrate with the WhatsApp channel as early as possible.