How To Build a Powerful Twitter Marketing App in 15 Minutes

No coding required!

Love it or hate it, Twitter still remains a powerful marketing tool. And best of all it's free. If utilized correctly it's very realistic to expect leads, traffic and sales at no cost consistently.

But I digress... this article isn't about twitter marketing hacks (I'll write up a separate one for that). Instead, let's talk about automating your Twitter marketing without having to use an expensive SAAS service.

Prerequisites

Part 1: Introduction

What if I told you could build a full Twitter app that would automatically follow a list of users every x minutes, with a random delay of between 10-30 seconds per user straight from a Google Sheet?

Moreover, what if that same sheet could check if a user was following you back, and if not then unfollow them?

That's just the beginning of what is possible using the method in this article. By the end of it, you will also be able to create a function that copies the followers of other Twitter users, save profiles you have already followed, run a direct message campaign and learn how to quickly 'encrypt your Twitter list' to add into your advertising campaigns.

twitter bot

Let's begin.

Setup

To start you'll need to visit blockspring.com and install the Google Sheets / Chrome extension. BlockSpring have come up with arguably one of the easiest to use plugins for Sheets which lets you connect your sheet to a variety of third party services. Including, but not limited to Twitter, Facebook, Amazon, and even NASA.

This allows you to call on the APIs of other companies without actually knowing how to write a single piece of code. Pretty handy eh?

Once you have opened a new Sheet and have the Blockspring console open by going to add ons > blockspring > open, complete the following steps.

Note: If there is any part of this tutorial you don't understand feel free to refer to the video walkthrough above.

  • Visit blockspring.com/browse
  • Find the Twitter integration
  • Open that and press 'connect' in order to authorize your Twitter account with Blockspring.
  • Go back to the Google Sheet you had open, and select three columns. Put the name of the column in the first row (you can call it whatever). Like so:

List of Handles | Follow Status | Delay

  • Open up your Blockspring console within the sheet, and select the Twitter integration. Make sure you are signed in. Once you've done that, choose the option that is called, "Follow a user on Twitter".
  • Put in the name of a Twitter account you want to follow, and select the the first row under 'Follow Status' (or whatever the equivalent you have), then press 'insert into selected cell'

If you have done everything right row B2 should say TRUE. Now go into your formula bar, and remove the username in quotes that you just followed. Click on cell A2, and it should be appear in your formula bar.

build twitter spreadsheet

Now all you have to do is hover over the bottom right side of the cell until a handle appears and then drag out. Typically, I drag it for about 100 rows.

twitter spreadsheet app

This simply applies the formula to every cell, substituting the A2, for the cell number below (i.e. A3,A4,A5,A6...A100)

You've just created a basic follow function using Twitter's API within a Google Sheet. Well done! If you want to test it out copy and paste some Twitter screen names into Col A, when Col B says, 'TRUE' that means you have followed the specified user. You can check this by viewing the following count on your Twitter profile.

But, we're not finished yet.

Setting Delays

Like most third party APIs Twitter has following limits and if you don't want to get your account suspended you should set a delay between each follow (i.e. how long to wait between 0-30 seconds).

To do this we are going to use the RANDBETWEEN() function. This function generates a random number between 2 integers that you set.

Example: =RANDBETWEEN(1,30)

twitter marketing

This formula will go into cell D2 (under a temporary column) and shoul dbe dragged down, so that after the numbers are generated we can paste them into C - Delay column.

Note: When pasting the numbers into Col C, make sure to right click first then > paste > paste values > so that only the numbers are pasted and not the formulas. As per above.

Why do we do it twice instead of just putting the formula in C2? Because when working with Google Sheets functions will regenerate when there is a change on the sheet. In this case, we already have the follow function running so as soon as one user is followed, all the numbers would switch. In the second whilst it is loading there would be no numbers in the column for our follow function to read, and there by it wouldn't delay.

Note: Perhaps this is an overly complicated way of doing it. After all you need is a 100 random numbers between 1,30. Hell, there is probably a million websites which will do that for you in a few seconds. But the reason I like explaining these nitty gritty bits is because in the future I promise that having that minor stack of knowledge (even knowing what RANDBETWEEN does) will come in handy when you least expect it.

Once that is pasted, we are going to add something to our formula in B2. So, go ahead and click on B2, and place a comma after the A2 part in the formula, after the comma add this.

"_sleep" , C2

The full formula should like:

=BLOCKSPRING("follow-twitter-user", "username", A2, "_sleep" , C2)

If you want to get technical you can make so the cell is blank until it Col A has something in it (in order to not clog up your screen). To do that, make the formula like so:

=IF(A2="","",(BLOCKSPRING("follow-twitter-user", "username", A2, "_sleep" , C2)))

This just tells the app if row A is blank, make B blank too)

As per before, now drag B2 down all the way to B100 so that it replaces the previous formula in the cells underneath.

That's the basics complete! You can now use this sheet to automatically follow users that you think are relevant to your profile/business.

Advanced 'Follow' Section.

If you noticed, in the first screenshot I posted at the start of this article - there was another column called, 'Import Handles To Schedule'. This column allows you to paste in a list of twitter screen names, say 500, 1000 or more and every x amount of hours it will follow say, 100. In 6 hours after that it will follow another 100 and so on.

Pretty cool right? If you want to add this feature to your sheet it requires a little bit of Google Apps Script code:

Button code:

This will go at the top of script.

function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var menubuttons = [{name: "Bulk Schedule Import", functionName:"Schedule"}]; ss.addMenu("Twitter Bot", menubuttons);

Function code:

All this code does is move the values in Schedule column into Col A - the column that is wired to work with Col B which executes the follow function.

function Schedule() { var sheet, colE, import, follow, remainder; sheet = SpreadsheetApp.getActive().getSheetByName('Follow Function'); colE = sheet.getRange('E2:E'); import = sheet.getRange('E2:E100'); follow = sheet.getRange('A2:A100'); remainder = sheet.getRange('E101:E').getValues(); import.copyTo(follow); colE.clearContent(); for (var i = 0, len = remainder.length; i < len; i++) if (remainder[i] =='') { remainder.splice(i, len-i); break; } sheet.getRange(2, 5, remainder.length, 1).setValues(remainder); }

Note: It will only work if you put your data and formulas into the same areas as I have. If not, you'll need to either copy examples in the GIFs or define different ranges in the code suitable to your app.

var sheet, colE, import, follow, remainder; in the code defines all the variables we are going to use, ColE sets the Col E as the column/range we will be using. import sets the range of how many users we want to follow every x hours. In this case all values from row E2 to row E100). follow sets where we are going to put those values into all rows from A2:A100 which is in Col A which is wired to work work Col B as per above.

remainder is the remaining amount of values left over after the first 100 (E2:E100). The rest of code just executes a loop that removes the top 100 results that were copied to ColA, and moves the ones below it up. Then repeats.

Setting Up Triggers

Now to automate the process of doing this every x hours we need to use a trigger. If you know your servers, a trigger is similar to a CRON job - a task you tell your server to do on repeat at a specified time.

To setup a trigger click on tools > script editor > resources > triggers > add new trigger > choose the function schedule() as per below:

google apps script twitter triggers

Part 2: Unfollow Function & More

Would you like to learn more? Including how to build out your own custom Twitter Search Panel with your existing sheet and much much more.

If so, please share this post, tell your friends and if there is enough demand I'll write up four more parts to How To Build a Powerful Twitter App in 15 Minutes (for a total of five).