what is a twitter bot
It’s not a robot at all but an automated manipulation of Twitter facilitated by the Twitter API, and it’s all about communication. The Twitter API (or any API) is a set of commands so your code and Twitter’s code can interact with predictable results.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
The key is to start small. You have to first register your “application” with Twitter at apps.twitter.com. In the process of registering your application, you will get four crazy looking strings: your consumer_key, consumer_secret, oauth_token and oauth_token_secret. These four strings help Twitter know that you are you and not some other bot with malicious intent.
(Registering your application and getting all the particulars just so can be confusing. I always google for examples to mimic or just to point me in the right direction. This blog post helped me out.)
@newsapps_jobs was written in Ruby and so the above configuration follows the convention specified by the Ruby Twitter Gem. Whichever language you choose for your bot, there is almost assuredly a library that will help you interact with Twitter’s API.
As soon as you verify that your bot can do the basics, you’re on your way.
@newsapps_jobs uses a number of different Ruby libraries to get it’s job done: the bitly gem to shorten links, the google-drive gem to access the google spreadsheet, the twitter gem for tweeting and the whenever gem to manage the Cron job for timely Tweeting. All of these gems have their own respective documentations that can be found online.
why a bot?
I wrote this bot in the summer of 2012. I felt the state of affairs regarding jobs in the newsapps/data j world was unruly at best, chaotic at worst. The best offering up to that point was this embedded google spreadsheet. It was a decent solution, a start, but, obviously, not an endpoint. I thought that the bite-sized information delivery of Twitter was perfect for a jobs board. With a job ad, the information necessary for a reader to assess their level of personal interest easily fits within 140 characters: job title, location, employer is really all a person needs to know if they want to click. Scrolling the tweets on your Twitter client would take seconds even if you checked every day. Easy! So I set to work. (I also knew that writing a Twitter bot was a great exercise! And fun!)
The tally so far: the bot has 170 followers, 252 tweets and I’ve shared the spreadsheet with 16 folks. I’m not sure, though, if the bot has actually connected employer with future employee.
Nevertheless, in the week before NICAR 2014, I did see this Twitter account appear.
I encourage you to write your own bot. It’s fun and great practice. If you have any questions, comments or concerns or are struggling with your bot, hit me up in the comments. I’m helpful.