Making a Twitter bot has been on my coding bucket list for a long time. I always figured it was overly complex and would take forever, but last night I checked out what steps it actually took. I was pleasantly surprised to find several options promising to get a bot up and tweeting in under an hour.
Ultimately, I chose Zach Whalen’s method to load and implement a Twitter bot using a Google Sheets-laced with scripts. After rereading the directions a few times and skimming the comments section for some clues about some missing steps I got it sorted out, but in the end it wouldn’t work. I managed to get the Twitter API side up and running and the initial part of the Google Sheets, but when it came time for it to start making scripts happen, it never could make it through Google’s authentication process. It might be due to Google depreciating some sort of script ID so it couldn’t communicate with the Twitter API, but I can only speculate because this is unknown territory for me.
Feeling a little discouraged, I scoured the comments section of Whalen’s tutorial again and saw several mentions of Cheap Bots, Done Quick as an alternative. This method was the winner! Created by George Buckenham, Cheap Bots, Done Quick! uses JSON and Tracery by Kate Compton to turn a collection of words and phrases (also SVGs if you are so inclined) into randomized tweets.
This morning, I plugged away for a couple hours before work and my bot went live as Auspicious Items on Twitter. It tweets out an hourly horoscope suggesting good and bad luck items to keep your day harmonious.
In less than a day, I realized I needed to revise my code. I made some fixes like creating more top-level variables and fixing a couple grammar issues for smoother subject-verb agreement. I suspect as I continue to watch Auspicious Items tweet more fortunes, I will need to make more changes, but it’s not discouraging. This was a fun exercise and I may build other bots in the future.
Leave a Reply