Convert Tweets to Emails with Google AppsScript

Tomas Vitvar, October 1st, 2010

TwitterPeople and organizations start using Twitter today for general public announcements or as a primary communication channel in closed communities. For example, I use Twitter when I want to share a story with my students or announce a newly available studying material. But what do you do if there are some people who do not want to use Twitter and still rely on email communication? By using Twitter API and Google AppsScript you can write and run a simple mashup that sends an email anytime you post a new message on Twitter.

Google AppsScript is a JavaScript cloud scripting language that allows you to automate tasks across Google products and third party services. You can use Google AppsScript to write custom functions and utilize interfaces for Google core services such as email, Calendar, Contacts, or Maps. You can call any RESTful or SOAP Web API, parse JSON and XML data, process that data and populate a spreadsheet with results. You can then use your function directly in a spreadsheet or configure a trigger that runs your function at specified time intervals.

Twitter2Email

To convert tweets to emails using AppsScript I set up a Google spreadsheet and wrote a mashup that fetches tweets from Twitter via Twitter API, checks whether a tweet has not already been emailed, sends the tweet via AppsScript email service and “remembers” the tweet so that it cannot be sent again next time the mashup is run. If you use the mashup on your own, you can control its operation by a number of parameters. You can specify a Twitter account you want to fetch tweets from, a comma separated list of email addresses, emails’ subject, and a creation date of the first tweet you want to start sending emails. In addition, you can control a maximum number of emails that the mashup should send per a single run.

Although you may use third-party services or scripts to convert tweets to email, the solution based on Google AppsScript has several advantages. If you know JavaScript you also know Google AppsScript while having the full control over the functionality you develop. You do not need any server or third-party tools to run your mashup, and you can easily control when and how often it should run.

Want to use the Twitter to email mashup on your own? Just make a copy of the Google spreadsheet, specify your input parameters on the first sheet and configure a trigger in the Google AppsScript editor. Feel free to make any modifications if you have specific requirements.

Both comments and pings are currently closed.

5 Responses to “Convert Tweets to Emails with Google AppsScript”

October 31st, 2010
at 12:59 pm
Comment by: Rosh

Where do we get the code from? I now have the spreadsheet what about the app script? can you please put that up somewhere

November 1st, 2010
at 3:41 am
Comment by: Tomas

When you make a copy of the spreadsheet you find the script under Tools > Scripts > Script Editor.

November 1st, 2010
at 6:30 am
Comment by: Rosh

Thanks Tomas. It works fine.

March 31st, 2011
at 2:31 pm
Comment by: Cloud Computing May Decrease Your API Call Limit

[...] recently wrote an AppsScript that sends an e-mail every time a new tweet is posted on a specified Twitter account and encouraged you to copy it and use it on your own. I run it in Google Spreadsheets every 5 [...]

April 2nd, 2011
at 8:43 am
Comment by: Cloud Computing May Decrease Your API Call Limit | اخبار از سراسر وب

[...] فروردین ۱۳, ۱۳۹۰   سعید قنبری   No comments I recently wrote an AppsScript that sends an e-mail every time a new tweet is posted on a specified Twitter account and encouraged you to copy it and use it on your own. I run it in Google Spreadsheets every 5 [...]

Follow the PW team on Twitter

ProgrammableWeb
APIs, mashups and code. Because the world's your programmable oyster.

John Musser
Founder, ProgrammableWeb

Adam DuVander
Executive Editor, ProgrammableWeb. Author, Map Scripting 101. Lover, APIs.