How to Make a Twitter Bot with Google Scripts

You can easily write a Twitter bot with the help of Google Apps Script. It fetches tweets addressed (@mentions) to the bot through the Twitter API, computes the answer with Wolfraph Alpha and replies with a tweet. The steps are:

  • Create a Twitter App at apps.twitter.com (screenshot) and note the Twitter Consumers Keys and Access Tokens
  • Go to developer.wolfram.com, create an account screenshot and then choose “Get an App ID” to create your new app. We will need this App ID in the Google Script. Your free Wolfram Alpha App can only be used for a non-commercial purpose.
  • Edit the values of TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_SECRET, TWITTER_HANDLE (your Twitter account) and WOLFRAM_API_ID
  • Go to Run -> Start to initialize the Twitter bot. Say yes if the script requires you to authorize access to certain Google services.

The code is ready to though you’ll need to create a Wolfram App and also include the Twitter library in your Google Scripts project (key is MKvHYYdYA4G5JJHj7hxIcoh8V4oX7X1M_) with the identifier set to Twitter.

If you are looking to automate your business processes with Google Apps or need one-on-one technical support for Google Scripts, please book a meeting. The fee is $50 per half hour time slot.