Search This Blog

Friday, 21 June 2013

Use Your Twitter as a Gmail Notifier

Did you know that you can follow your Gmail account on Twitter and get notified (via tweets) as soon as new email messages arrive in your Gmail mailbox. And these are private tweets that will be only visible to you.
You can also use this trick as a workaround to receive SMS alerts for important Gmail messages on your mobile phone through Twitter. You will only have to turn on mobile notifications for the Twitter account that will be tweeting your Gmail mailbox.
There’s no programming required and you can get started in 5 minutes. I have updated this tutorial for Twitter API 1.1 and it is takes fewer steps to setup.
gmail messages in twitter timeline

Use Twitter as a Gmail Notifier with Google Scripts

Gmail does provide an RSS feed of your inbox but the problem is that if you have to auto-publish the Gmail’s default RSS feed to Twitter, you’ll have to supply your Google account credentials in plain text. That’s risky.
The following solution uses OAuth to connect your Gmail and Twitter accounts so you don’t have to share your passwords with anyone. There’s a Google Apps Script that monitors your Gmail mailbox in the background and as soon as a new message arrives in your account, the script sends out a tweet. That’s the big picture and here’s how you can implement this solution:

Step A: Create a new Twitter App for Gmail

  1. Go to twitter.com/signup and create a new Twitter account for your Gmail Inbox – mine is called myGmailInbox.
  2. Confirm your email address, then open the Twitter settings page and check the option “Protect My Tweets.” This will make your Gmail notifications private and neither search engines nor other Twitter users will be able to see tweets generated through Gmail.
  3. Go to dev.twitter.com, sign-in using your new Twitter account and create a New Twitter App.
  4. You may give your Twitter app any name, description while https://spreadsheets.google.com/macros will be the Callback URL.
  5. Make sure there are no empty spaces in the URL fields else Twitter may give an “Invalid URL format” warning. Accept the terms and conditions, fill in the CAPTCHA and submit the form to create your first Twitter application.
  6. Next go to the Settings Tab of your Twitter Application and change the “Access” mode from “Read only” to “Read and Write” since we want to publish tweets from Google Docs.
  7. Save the Settings, then switch to the tab that says OAuth Tool and make a note of the Consumer Key and the Consumer Secret Key.

Step B: Link Google Docs and Twitter

  1. Click here to make a copy of the Google Script in your Google Drive.
  2. Replace the values of TWITTER_CONSUMER_KEY and TWITTER_CONSUMER_SECRET with the actual values available on dev.twitter.com.
  3. Choose Run –> Initialize and follow the prompts to authorize the script. This is required for the script to watch your Gmail inbox at set intervals for new mails.
  4. Choose Run –> RunProgram and it should display another “Authorization Required” message from Twitter. Click Authorize to allow the Google Script to publish tweets to your Twitter Gmail account.

Step C: Follow Gmail on Twitter

  1. Log in to your old Twitter account and send a follow request to your new Gmail account on Twitter.
  2. Log in to your new Gmail account and approve the new follower. You should now see tweets for new Gmail messages, as they arrive, in your main timeline.

Get SMS Alerts for New Gmail Messages

Should you wish to receive SMS alerts on your mobile phone for new Gmail messages, just open the Twitter profile page of your Gmail bot and turn on Mobile Notifications. This will obviously work only if you have connected (and verified) your mobile phone with your main Twitter account.

One more thing. In the default setup, the Google Script watches your Gmail Inbox for all incoming mails and tweets as soon as it encounters any new messages in the mailbox.
If this generates too many tweets and text messages, you can specify a different Gmail search filter and thus receive notifications for messages only from people you care about. For this to work, you will have to change the value of GMAIL_SEARCH_STRING in the script.


No comments:

Post a Comment