How to Automate Twitter Following


The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

Automated Twitter bots are a popular way to create content for your brand, and some businesses use them as their primary marketing strategy. This video will walk you through how to automate following on twitter so that the bot can do its job consistently.

The “twitter automation bot free” is a tool that allows users to automate their Twitter following. It also has the ability to schedule tweets, and it can be used in conjunction with other tools like Buffer or Hootsuite. The “Twitter automation bot free” provides an easy way for people to manage their social media accounts.

How to Automate Twitter Following

Are you a Twitter user? You’re missing out if you haven’t already. Twitter is the finest social media tool for staying current with technology. However, Twitter has millions of users. What’s the best way to find fascinating people? I’ll teach you how to do precisely that and automate it in this post!

On Twitter, there are several methods to find intriguing individuals. There are hundreds of various tools and services available to assist you, but none of them are ideal. Some are paid services, while others are broken or lack the functionality you want.

Did you know that you may make your own tool instead of hiring a pricey service? If you know a little PowerShell, you can quickly query Twitter’s API and get all the Twitter accounts you want. But how?

Because there are so many methods to find interesting Twitter individuals to follow, this post will try to tackle the issue in three steps:

  1. Obtaining a list of all followers of prominent Twitter accounts that you find “interesting.” What individuals do you already follow that have a lot of followers and who you think would be tweeting the same kind of content?
  2. Filtering prospective followers based on characteristics like terms in their profile, lack of a default profile photograph, lack of a secured Twitter account, and so on.
  3. All detected screen names are listed below.

The greatest aspect is that everything will be done through script, making it completely automated and repeatable at any moment.


This project will be a hands-on example of how to automate Twitter following. You’ll create your own Twitter query script and manage your Twitter friends. If you want to follow along, make sure you have the following items:

  • An account on Twitter
  • An application for Twitter. The instructions to do so may be found on the MyTwitter blog page. To authenticate to your account, you’ll need to acquire certain API keys and Token of Accesss.
  • PowerShell 6+ or Windows PowerShell The examples in this article were ran on a Mac using PowerShell v6.2.
  • PowerShell knowledge that is intermediate
  • A collection of Twitter screen names with the sort of followers you want to follow on Twitter. Using the followers of another Twitter account, this post will “seed” an initial list of users.

How to Set Up an Automated Twitter Following Script

You’ll start by using Marc Kellerman’s PSTwitterAPI PowerShell module to handle the hard lifting, such as authentication and API requests. This is a useful module that encapsulates the Twitter API methods in PowerShell.

PSTwitterAPI Module Installation

Download and install this module from the PowerShell Gallery using the instructions below.

PS62> Install-Module -Name PSTwitterAPI

Obtaining API Tokens and Keys

After that, you’ll need to give four key pieces of information provided by your Twitter application:

  • API Key
  • API Access Key
  • Token of Access
  • Token of Access Secret

As seen below, these crucial features may be found under the Keys and Tokens area of your Twitter application.

Making an application for TwitterMaking an application for Twitter

PSTwitterAPI accepts OAuth keys and tokens.

Once you have access to all four of these objects, use the Set-TwitterOAuthSettings cmdlet to provide them to the PSTwitterAPI module. To do so, run the cmdlet as shown below, supplying each value to the proper argument.

@ ApiKey = ‘xxxxxx’ $OAuthSettings = @ ‘xxxxxx’ as ApiSecret ‘xxxxxx’ as the AccessToken ‘xxxxxx’ as the AccessTokenSecret @OAuthSettings Set-TwitterOAuthSettings

Utility Functions Construction

When using an API to automate following Twitter people, you’ll almost certainly run into rate constraints. You can only fulfill a particular number of requests in a certain length of time. More information about Twitter API rate limitations may be found here.

I wrote two methods named Get-FriendlyApiErrorResponse and Test-ApiRateLimitResponse to help handling rate-limited queries easier. These two PowerShell functions don’t accomplish much (by design), but they do it well. They relieve the user of the burden of worrying about particular mistakes or judgments.

param([Parameter(Mandatory)] [ValidateNotNullOrEmpty()]) Get-FriendlyApiErrorResponse [System.Management.Automation.ErrorRecord] if ($ErrorResponse.Exception.Message -match ‘At this moment, you are unable to follow additional individuals’) else $ErrorResponse.Exception.Message errors.message ($ErrorResponse.ErrorDetails.Message | ConvertFrom-Json). param([Parameter(Mandatory)] [ValidateNotNullOrEmpty()]) Test-ApiRateLimitResponse [string] $ErrorResponse -match ‘(Too many requests)|(Rate limit exceeded)’ $ErrorResponse

It’s also useful to know when the script will try to execute again since you’ll be rate-limited at times. The Show-Countdown function, which accomplishes just that, is seen below.

[CmdletBinding()] function Show-Countdown param([Mandatory Parameter]) [ValidateNotNullOrEmpty()] [int] $timer = [system.diagnostics.stopwatch]::StartNew $maxwaitmin) () $totalMinsWaited = [math]::Round($timer.Elapsed.TotalMinutes, 0) do $totalMinsWaited = [math]::Round($time “$($MaxWaitMin – $totalMinsWaited)…” -NoNewline Write-Host while ($timer.Elapsed) Start-Sleep -Seconds 60 -lt TotalMinutes $timer.Stop() $MaxWaitMin)

Friendships on Twitter to “Seed”

Instead of scouring the whole Twitterverse, create a “seed” list of possible Twitter buddies. One method is to manually designate one or more Twitter people that have similar interests.

  • What kind of Twitter users do you love following?
  • What kind of persons may have followers who would tweet fascinating things?

Identifying the Most Popular Twitter Users

In a PowerShell array, make a list of these persons. You’ll be questioning each of their followers.

Adding dozens or hundreds of Twitter screen identities to this list is not recommended. You’ll be hitting Twitter’s API limit a lot, apart from producing an enormous timeline!

@(‘user1′,’user2′,’user3’) $interestingUsers

Identifying Useful Keywords

Next, specify a list of phrases you’d want to appear in their profiles to further narrow down possible Twitter buddies. Try to think of some basic terms they may use in their bio or interests section of their profile.

Some of my keywords are listed here.

@(‘sccm,’powershell,’engineer,’azure,’cloud,’devops’) $profileDescKeywords

Twitter Followers Query

It’s now time to look up all of the followers of each “interesting” individual. Create a loop as shown below, since you may have more than one person to query followers for.

@() foreach ($user in $interestingUsers) $followers

You’ll then need to put a do/while loop within that foreach loop. Because of how the Twitter API reacts, this is required. If the account has more than 200 followers, you will have to query the API many times. This is taken care of by the do/while loop.

Use the Get-TwitterFollowers List function within the do/while loop. This method will query Twitter’s API and get 200 of their followers or fewer.

Below is an example of how to implement this logic, along with comments where applicable. This code combines the functions you created before to demonstrate how they may be utilized.

$getFollowParams = @ is worth a shot. count = 200 ErrorAction =’Stop’ if (Get-Variable -Name’response’ -ErrorAction ‘Ignore’) $getFollowParams.screen name = $user $ cursor = $getFollowParams.cursor if ($response = @getFollowParams Get-TwitterFollowers List) $response.users -Message “Get-TwitterFollowers: Retrieved $($response.users.Count) followers from user $ScreenName…” $response.users -Message “Get-TwitterFollowers: Retrieved $($response.users. $errResponse = Get-FriendlyApiErrorResponse -ErrorResponse $errResponse = Get-FriendlyApiErrorRespons $ if (Test-ApiRateLimitResponse -ErrorResponse $errResponse) (Test-ApiRateLimitResponse -Er Warning: Write “API rate limit exceeded. $RetryInterval minutes have passed “-MaxWaitMin Show-Countdown while ($ cursor) $RetryInterval else throw $errResponse

All of this code is wrapped up in a method named Get-TwitterFollowers, which you can see below. This is the first function in your Twiter automation module!

Get-TwitterFollowers function [CmdletBinding()] [CmdletBinding()] [CmdletB ([Parameter()]) param [ValidateNotNullOrEmpty()] [string] [Parameter()], $ScreenName] [ValidateNotNullOrEmpty()] [int] $IntervalRetry = 15) $getFollowParams = @ is worth a shot. count = 200 ErrorAction =’Stop’ If ($PSBoundParameters.ContainsKey(‘ScreenName’) is true, $ScreenName = $getFollowParams.screen name If (Get-Variable -Name’response’ -ErrorAction’Ignore’) is true, then $ cursor = $getFollowParams.cursor if ($response = @getFollowParams Get-TwitterFollowers List) Message-Write-Verbose “TwitterFollowers-Get: $($response.users.Count) followers were retrieved from user $ScreenName “users in $response $errResponse = Get-FriendlyApiErrorResponse -ErrorResponse $errResponse = Get-FriendlyApiErrorRespons $ if (Test-ApiRateLimitResponse -ErrorResponse $errResponse) (Test-ApiRateLimitResponse -Er Create-Host “API rate limit exceeded. $RetryInterval minutes have passed “Otherwise, throw $errResponse while ($ cursor) Show-Countdown -MaxWaitMin $RetryInterval

Follow Twitter Accounts Automatically

Following an account is the last step you’ll need to do. You may see an example of a function to account for API rate-limiting to keep the procedure as simple as feasible.

This function, named Follow-TwitterUser, will try to follow an account on Twitter. If the request is rate-limited, it will wait a certain amount of time before retrying up to $MaxRetries.

[CmdletBinding()] function Follow-TwitterUser param ([Mandatory Parameter]) [ValidateNotNullOrEmpty()] [string] [Parameter()], $ScreenName] [ValidateNotNullOrEmpty()] [int] $RetryInterval = 15, ## minutes $RetryInterval [Parameter()] [ValidateNotNullOrEmpty()] [int] 5) $MaxRetries $performedRetries = 0 do $false = $success { try @$followParams = $followParams screen name = $ScreenName ErrorAction = ‘Stop’ Message-Write-Verbose “Trying to follow $ScreenName as a screen name…” @followParams $response = Send-TwitterFriendships Create Message-Write-Verbose ‘User was successfully followed.’ $true = $success catch Get-FriendlyApiErrorResponse -ErrorResponse $errResponse $ if (Test-ApiRateLimitResponse -ErrorResponse) (Test-ApiRateLimitResponse $errResponse) $performedRetries++ if ($maxRetries -le $retriesPerformed) Warning: Write “API rate limit exceeded. $RetryInterval minutes have passed…” Show-Countdown -MaxWaitMin $RetryInterval otherwise throw $errResponse else throw $errResponse else throw $errResponse else throw $errResponse while (-not $success)

Users are filtered based on their profile keywords.

Your seed accounts will very certainly be followed by a slew of “junk” and spammy Twitter accounts. Add another layer of screening to guarantee you don’t follow these accounts.

To filter out these accounts, you may utilize a variety of factors. There are six separate things in this article. For me to follow an account, it must match the following criteria:

  1. You must be following a Twitter account called “seed.”
  2. It is not protected, which means you must get authorization to follow it.
  3. I’m not going to follow them.
  4. Has a profile been established?
  5. Has at least one term in their profile that is intriguing. Remember the $profileDescKeywords array you created earlier? This is where it will be useful.
  6. There is no default profile picture.

Twitter Users to Follow

The Get-TwitterFollowers routines retrieve all followers of a particular account without applying any of the above-mentioned criteria. Below is an example of some of the filtering that was done.

You’ll also see the above-mentioned Follow-TwitterUser feature. This code tries to locate and follow each user’s followers depending on the filtering criteria.

Get-TwitterFollowers -ScreenName $user -Verbose:$VerbosePreference | where { $desc = $_.description; -not $_.protected -and ## is not a protected account -not $_.following -and ## I’m not going to follow them. already -not $_.followed_by -and ## They are not following me $_.description -and ## They have a profile $_.profile_image_url -notmatch ‘default_profile_images’ -and ## They don’t have a default profilate image ($profileDescKeywords | ? { $desc -match $_ }) -and ## They have at least one interesting word in their profile $_.screen_name -notin $NeverFollow } | foreach { Follow-TwitterUser -ScreenName $_.screen_name -Verbose:$VerbosePreference }

You may use Github to obtain and change the script that was written for this project.

Before anybody complains about the efficiency of this code, let me first say that this was merely a fun project. It is by no means a “professional” representation of code, but it sufficed for my needs.


You learnt the guts and bolts of creating your own Twitter discovery tool in this post. What might you do to improve it? An great PowerShell module might be constructed using the code you’ve seen here! Why not create one, improve the code, and publish it on GitHub and the PowerShell Gallery?

The “auto follow twitter” is a Twitter automation tool that automates the process of following new people on Twitter. The bot will automatically follow back any new followers, and unfollow anyone who follows it.

Related Tags

  • auto followers twitter free
  • auto followers twitter 1000 free
  • twitter bot followers
  • automated twitter bot
  • twitter follower

Table of Content