Connecting Twilio SMS to Google Spreadsheet

TwilioSheet is a little utility that makes it easy for developers to receive SMS messages in a Google Spreadsheet.

I write a lot of simple little SMS applications, but they can be daunting at times. I often wonder if the idea is worth the time it takes to write the code to store, process, and act on the incoming messages. Why not use something a little easier? A spreadsheet perhaps? Well, that’s what TwilioSheet lets you do.

SMS to Google Spreadsheet

Once you’ve set up TwilioSheet, SMS messages sent to your Twilio number will show up in your spreadsheet after a few seconds. You can easily process the SMS messages that are coming into your spreadsheet using built-in spreadsheet functions or you can write your own functions in JavaScript.

Want to get started right now? Head over to the GitHub repository for TwilioSheet. Otherwise, read on.

While I wouldn’t recommend using a Google Spreadsheet as the data store for a production application, using a Google Spreadsheet is a great way to try out an idea. What I particularly like about Google Spreadsheets is how accessible they are: Many people who don’t consider themselves to be “programmers” can do amazing things with a spreadsheet. Additionally, as I hinted above, for the scenarios where you can’t do something with the existing spreadsheet functions, well, you can just use JavaScript.

Example Time

Are you wondering what sort of application you can built with TwilioSheet?

One sample application has to do with the story of how I became inspired to write TwilioSheet.

Several months ago, while I was attending Startup Weekend Chandler, I ran into Jason Laveglia. Jason asked me if he could use Twilio to set up a marketing campaign where people could sign up for updates by texting a phone number a keyword and email address, separated by a space. I told Jason that Twilio would be perfect for that and I could write him an example application in 15 minutes.

As I wrote the application, I found myself wondering what I was going to use to store the text message data. Furthermore, I wanted Jason to be able to start playing with the data as it arrived. Clearly, meeting those criteria wasn’t going to happen in 15 minutes. What was I going to do? Then it hit me, a spreadsheet. I quickly set up a Google Spreadsheet and then turned it into a Google Form. Next, I wrote a simple little program to process the text message data and then submit the data to the Google Spreadsheet (by way of the Google Form).

Here is what I wrote:
Well, it worked! In a little over 15 minutes, I had a demo working for Jason.

Enter TwilioSheet

After I built the sample application for Jason, I realized that with a little more code I could turn my sample application into something that could be used for all sorts of other use cases. Thus, TwilioSheet was born. At it’s core, TwilioSheet is a pretty simple little application. Here are the two key parts of the application:

All the rest of the code is for error handling and validation.

Building a simple keyword marketing campaign with TwilioSheet

Going back to the original inspiration for this code, here is how to build a simple keyword marketing campaign using TwilioSheet:

    1. You’ll need a Twilio account to make this work. Sign up for Twilio if you haven’t already.
    2. Buy a new number on Twilio – or use one you have already.
    3. Follow the instructions on the GitHub repository for TwilioSheet and set up your Twilio number to send SMS data to a Google Spreadsheet.
    4. Send your Twilio number the following text as an SMS:

    5. You should see that SMS message show up in your spreadsheet in about 7 seconds.
    6. If everything worked as planned, here is what you should be seeing:
       
      SMS to Google Spreadsheet
    7. Enter into cell F1:
    8. Enter into cell G1:
    9. Enter into cell H1:
    10. At this point, here is what you should see:
      SMS to Google Spreadsheet

 

There you go, you just made a proof-of-concept keyword marketing campaign.

Just remember what I said before, this is for doing quick little proof-of-concept applications. Please, don’t run your production code off of a Google Spreadsheet.

Tune in next time

You can build all sorts of simple little SMS applications using TwilioSheet. Other use cases that come to my mind are: SMS “contact forms”, expense tracking, time tracking, and polling/voting applications.

Next up: I’ll be showing you how to build a simple little live voting application using TwilioSheet.

In the meantime, please tell me what you think of TwilioSheet. Did you have trouble setting it up? Did you build something cool? Let me know, or email community@twilio.com!