Wednesday 27 January 2016

How to Write a Twitter Bot in 5 Minutes

Twitter Bots can do interesting things. You can tweet questions like "how many calories are in diet coke" to @DearAssistant and the Twitter bot, likeGoogle Now or Apple Siri, will reply with the answer. The @HundredZeros bot tweets links to eBooks that are free on Amazon. Another Twitter bot @WhatTheFare will tell you the Uber fare between two locations.

How to Create your own Twitter Bot

A bot is a program that is always running in the background and, when it encounters a command, it performs some action. For instance, you can have a grammar bot that looks for tweets containing misspellings and tweets the correct spelling. A bot can automatically favorite or retweet tweets that match certain criteria. It can automatically follow Twitters user who have tweeted a particular phrase. A brand may build an auto-reply bot that automatically responds when the brand gets a @mention on Twitter.

Writing a Twitter bot is easy and you can get one up and running in 5 minutes. We will host our Twitter bot on Google servers and you don't need any coding skills to create your first Twitter bot.

The Twitter bot is available in free and premium editions. The latter includes more features (read manual), it logs everything to a sheet and you can opt for one-on-one support too. Internally, it written using Google Scripts which is much less complicated than languages like PHP or Python.

FeaturesFreePremium
What can the Twitter bot do?Retweet and Favorite TweetsRetweet, Favorite, Auto-reply Tweets, Retweet with Comment, Auto Follow Twitter User
Is the bot's activity logged?NoYes, in a Google Spreadsheet
Installation Manual includedNoYes, PDF Manual included with step-by-step instructions and screenshots
How easy is to setup the Twitter bot?Easy but you need to directly edit the codeVery easy, just use the wizard to setup the bot
How many Twitter bots can be created?OneNo limit
Support optionsNoneEmail

Forever FreePremium







 

Also see: Save Tweets in a Google Sheet

Create a Twitter Bot – Step by Step Guide

Step A: Make a Twitter App for the Bot

  1. Create a new account at Twitter that will become your bot. Then go toapps.twitter.com, sign-in with your new Twitter account and create a Twitter app. Give your app a name, description and put any URL in the website field. Keep the callback URL field blank, agree to the terms and submit the form to create your first Twitter application.
  2. Once the Twitter app has been created, click the Keys and Access Tokens tab and click the Create my Access Token button. Twitter will generate the Consumer Keys and Access tokens that we will need in a later step.

Step B: Initialize the Twitter bot

  1. Click here to create a copy of the Twitter Retweet bot in your Google Drive.
  2. Edit the values of TWITTER_CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN and ACCESS_SECRET – you know them all from the previous steps.
  3. Set the TWITTER_SEARCH_PHRASE and all matching tweets will get processed by the Twitter bot, one at a time.
  4. Go to Run -> StartBot to initialize the Twitter bot. Say yes if the script requires you to authorize access to certain Google services.

That's it. Your Twitter bot is now up and running, ready to take commands. You can always to go the Run menu and choose Stop to disable or deactivate the Twitter Bot. Do however note that Twitter rules discourage bots that automate tweeting so you may want to test the waters with a test account.

No comments:

Post a Comment