Wednesday, March 13, 2013

Use Twitter as a Gmail notifier and get SMS for new mail

Before starting I have to state that this project is created by the genius Mr.Amit Agarwal, I'm just creating this tutorial to demonstrate and explain the process.

So, as Mr. Argawal mentions this idea will let  can turn your Twitter Timeline into a Gmail Notifier and get notified (via tweets) as soon as new email messages arrive in your mailbox.And since you can link Twitter to your phone number, you can even get SMS text alerts for new Gmail messages.

This three steps process should take you 5 minutes and it is really easy to follow. Let's start: 

1- Creating a new Twitter app Gmail:

First I'm going to create a brand new twitter account and I'm gonna call it h20platform. Then, we'll have to go to the twitter settings and check the option “Protect My Tweets” and uncheck the option “Let others find me by my email address.” 




Now to create the application, go to https://dev.twitter.com/apps/new, sign in with your new twitter account and fill the fields as the picture below shows:





Now, you have to make sure that there is no space in the URL fields.
The website field is where you put the URL that contains info about the app and since the app is created by Mr. Argawal it would be the best to fill this field by the link to his website, where you can find some great info about the app and also give credit for his work.

After creating the app go to settings and change the access mode from read only to read and write.

Now after you update this setting, switch to the OAuth tab and note the consumer key and consumer secret:


2-Link Google Docs to Twitter

Now, log in to your Gmail account, then visit this link, and make a copy of the spreadsheet.
After you make the copy, this spreadsheet page should appear:
 From Tools – > Script Editor, replace the values of TWITTER_CONSUMER_KEY and TWITTER_CONSUMER_SECRET with their actual values. 

Then we click on resources -> Current script's triggers and then click on add new to create a time-driven trigger as shown below.


When you click on save and then authorize the app to read your Gmail box, then after granting access from Google, come back to your script page save the trigger, the go to Run – > SendTweet and it should display another “Authorization Required” message from Twitter. Click Authorize – > Authorize App to allow Google Apps Script publish tweets to your Twitter Gmail account.


Now we're almost done. All you have to do to receive these notifications is to follow your new twitter account that you just created with your current one.

3-Follow Gmail on Twitter


Testing

Ok, so now it's time for testing.
I'm gonna send an email to the linked email and we'll see if it's gonna work.
So this is the tweet as seen on my timeline.

I hoped this was a fun , easy and useful tutorial and if you were working along with me, I hope that everything worked great for you too.

Finally, to link your Gmail notification to your phone in order to receive SMS, all you have to do is to turn your mobile notifications on twitter on.

The original tutorial can be found here.

6 comments:

  1. Hello Sir, thank you for your this excellent tutorial, it helped me to set up sms notification for gmail.

    My only problem is that after migrating to the new API 1.1, the app needs reauthorization from time to time.... It looks like it doesn't save the authorization process..... I updated the script to match the new API 1.1, but the problem persists. I don't know what to do next, tried everything, uninstall and delete the script+clean save a new copy of the 1.1compatible API script, new twitter account and app linked to gmail by the script, different follower account on twitter with different mobile number attached, sms command to follow the newly created twitter account, tried different browsers with no adbockers, nothing seems to work more than a day and for 10 sms or so....

    Does this have to do with changing the gmail inbox and grouping the emails by primary/social/forums/ etc?

    Could you please tell me if this solution works as smooth as before migrating to API 1.1? Any idea about what can I do next, in order to make it run again? Thanks a lot.

    ReplyDelete
    Replies
    1. Hi, thank you for your interest and actually your problem is caused by the new API released on the end of June.
      Check this article on dev.twitter.com : https://dev.twitter.com/blog/changes-coming-to-twitter-api
      and make sure to read carefully these two paragraphs:
      -Authentication required
      -Per-endpoint rate limiting

      Again, thank you for visiting the blog and commenting.

      Delete
    2. Dear Sir,

      I am not a technology expert so I didn't understand much of what is said in the link you provided (https://dev.twitter.com/blog/changes-coming-to-twitter-api), but this notifier is very helpful and I need it. So is there a way to make it work again or is it over?!

      Thanks in advance.

      Delete
    3. Hi, I'll make it simple.
      The changes include:
      -required authentication on every API endpoint

      And these are some key points:
      1-In version 1.1, we will require every request to the API to be authenticated.

      2-Most individual API endpoints will be rate limited at 60 calls per hour per-endpoint. Based on analysis of current use of our API, this rate limit will be well above the needs of most applications built against the Twitter API, while protecting our systems from abusive applications.

      Anyway, if you don't figure something out please email me some screenshots (about your problem) on h20platform@gmail.com and I will personally check it.

      Delete
    4. I'm sorry I forgot to ask you, is this the error you're getting:
      {"errors":[{"code":93,"message":"This application is not allowed to access or delete your direct messages"}]}

      Delete
  2. It's new to me that we can able to get gmail notification via twitter! Thanks for the snapshot instructions.

    ReplyDelete