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!

  • vikram

    how to send sms through Google Spreadsheet?

  • TrustServe

    hey joel, wow… very very interesting!!! i needed exactly this. i found your post while searching for a google spreadsheet script that would allow me to initiate twiml requests to convert a google spreadsheet into something that will initiate sms broadcasts, voice broadcasts and maybe even eventually become a real basic power dialer. the cool thing about google docs is that there are a lot of scripts to pull data in from CRM’s and other stuff so it is a natural place to run these scripts out of. there is a script that has a lot of functionality that could probably be partially modified for something like this called Another Mail Merge Script. It takes a gmail draft and merges in spreadsheet data using mail merge codes and then sends out. I would love to modify that to have the draft hold some twiml that is then merged with spreadsheet data to blast out SMS messages or voice broadcasts or possibly make calls out and connect to an OPENVBX flow etc. do you have any interest in helping with that?

  • Nick Wakan

    Able to send SMS from google doc via Twilio instantly when a cell is updated?

  • Gavin

    Hi Joel

    This has worked perfectly for me for the last few months, using it as a health and safety capture – time on and off site.

    Recently last week it has started to fail for certain numbers and Twilio has reported a high number of HTTP errors and recommend speaking ‘to your hosting provider to ensure that this url is available and responds in a timely manner.’

    Afraid my coding knowledge is pretty poor but any insight into getting this working again would be much appreciated.
    If it’s a lengthy process compensation towards yourself is only fair.

    Best Regards

    • Twilio

      Hey Gavin,
      We’d love to help out with this issue. Can you ping

  • JP Carlin

    We have also developed a Google Spreadsheet add-on named Text gBlaster that will handle the heavy lifting for you if you don’t want to write code. Here is the install link: Hope you like it!

  • blank


    I’m trying to install the code in google form but I really don’t know much about python and this is what I get. Can you help?

    Best Regards