Using Google Spreadsheets for a generated text Twitter bot

11 Nov in bot, tool, twitter

I have been interested in Twitter bots for some time now, but when I’ve talked about bots publicly, I’ve always had to hem and haw when students or other motivated parties ask how they can make bots of their own. It is unfortunately the case that even simple bots pose a significant barrier of access for many would-be botmakers whereby, for many, the basic requirements of some programming skill and a server on which to run bot code stops them right out of the gate.

So I’m trying to do something about that. I’ve put together a way to get a simple random text-generating bot running without the need to write any code or have access to a web server. It’s based on some code from Amit Agarwal’s DearAssistant bot, but instead of a responsive bot that queries Wolfram-Alpha, mine uses a controlled vocabulary that its owner builds in the spreadsheet. Here, it randomly combines text chunks in a manner similar to Darius Kazemi’s GenGen, so producing interesting and legible output requires some careful planning.

Now, this bot does have some limitations. Currently, (due to a Google bug), you can’t use certain characters in your tweets. Also, the bot you make is only as smart or as random as the words you give it. It doesn’t connect to Wordnik, for example (Although that should be relatively easy to add in for a later version.)

Still, I think it’s a useful tool for getting started with botmaking, and I’m glad to say my students are already having some fun with it.

So if you’re interested in producing a simple bot, make a copy of this spreadsheet and follow the steps on its first page. I’ll also describe the basic steps below:

1. Create a Twitter account for your bot and confirm its authenticity.

Make sure you give it a real email address that you can check. I like to use the “+” trick with my GMail address, as in “”.

Customize this Twitter account however you want and stay logged in through that account for the duration of the steps that follow.

2. Create a Twitter app.

Go to (You’ll probably have to re-login; use your bot’s credentials), and hit the “Create a new Application” button. Give it a Name, Description and Website. These aren’t all that important, but the name needs to be unique and the website has to start with http://.

For the Callback URL, enter .

Once that App is created, go to its “Settings” tab and set the “Application Type” to “Read and Write”. Here’s what your App’s Details tab should look like when set up correctly:

3. Setup your Spreadsheet

Make a copy of this spreadsheet and start customizing it. From your Twitter App’s details, copy and paste your Consumer Key and Consumer Secret. Switch to the spreadsheet’s “Vocabulary” tab, and customize the words it uses. From the “Bot” menu, run “Preview Output” to see what it’s generating.

4. Authenticate your Bot and Start Posting!

In your spreadsheet, go to the Tools menu and select “Script Editor…”. In the script editor, go to “Run” and choose “authenticateTwitter.” You’ll need to be logged in to Twitter with your Bot’s account. Back in the main Spreadsheet screen, try “Bot -> Send a test tweet” and check your Twitter bot’s profile page to see if it worked.

If it did, great! If not, you may have gotten an error that explains why. Check the Script Editor’s log (“View -> Logs”) for some more detailed error reporting.

If all is well, set the posting interval you desire, and run “Bot -> Start Posting Tweets” to send it off into the Twitterverse.

Now that it’s running, you can customize the Vocabulary just by changing the values on that page of the spreadsheet. No need to re-authenticate or anything else. You will, however, need to re-run “Bot -> Start Posting Tweets” if you want to change your posting interval.

And that’s it! If you have any usage questions, suggestions for improvement, or if you find any bugs, please let me know.


Anonymous's picture
zach's picture

Did Twitter tell you it was

Did Twitter tell you it was an invalid URL when you created the application? I haven’t seen that. Though I notice now that that URL redirects to the Google Apps Script page. I’m not sure why. Does it prevent your bot from posting?

Pure Logic Edmonton's picture

Reply to comment | Zach Whalen

Thank you so much! That was wonderful :)

Gregg's picture


Any ideas as to how you would change the spreadsheet to randomly select one cell and tweet that? I don’t have any interest in making random sentences but would like to randomly select and tweet one of many pieces of information.

This is great, by the way. Thanks for sharing it.