Photo: SelectAll

Given how small the company actually is, it’s kind of ridiculous how much power Twitter has come to wield over political discourse. In terms of coverage volume, Hillary Clinton (well, her social media team) telling Donald Trump to delete his account was as big a story as any policy position or primary last week. The humble and unprofitable microblogging service may have trouble competing with Facebook for ad money, but it’s sure established its place in the firmament: The Clinton super-pac Correct the Record set aside a cool $1 million just to combat Bernie bros in 140 characters or fewer.

But it’s fair to say that one candidate dominates Twitter. Trump is Twitter’s first real presidential candidate. The mogul had already built a powerful following on the service before he jumped into the political sewer, but his presidential run has amplified his reach and allowed him to take micro-potshots at his many foes in between press conferences. His posts get hundreds of replies from sycophants and detractors alike.

Trump also signal boosts the nice things his millions of followers say about him — even when those followers happen to be overt white supremacists who spread intense anti-Semitic propaganda. In January, he retweeted an account called @WhiteGenocideTM; he’s retweeted white-nationalist account @NeilTurner_ five times and fellow-traveler @keksec__org “repeatedly,” per a Fortune analysis of Trump’s relationship to the #WhiteGenocide community on Twitter. (Yikes!) Naturally, he’s received a fair share of bad press for these followers of his.

Here’s the thing, though. Some of the awful people Trump is retweeting aren’t even people. They’re robots.

If you spend some time looking at the replies to Trump’s tweets, you’ll see three accounts pop up, over and over: @keksec__org, @NeilTurner_ and @WhiteGenocideTM. Tweet after tweet, they’re the first responders to Trump, no matter what subject or time of day, and he’s retweeted all three of them. Sure: It’s possible to stalk a celeb’s social-media feed 24/7, and whip out a reply or a demand for feet pics quickly. But these accounts do it day in, day out at a speed that can only be described as inhuman.

I extracted three months’ worth of Twitter replies to Trump from their accounts and compared their time stamps to the original tweets. @keksec__org had the fastest, with an average response time of two seconds. @NeilTurner_ was only slightly slower, but still within three seconds on average, as was @WhiteGenocideTM. Considering that the majority of these replies have images attached, you quickly realize that it’s not physically possible to compose a tweet, attach a file, and submit it in that period of time.

Another clue that these replies aren’t written by humans is in the context. Only rarely do they have anything to do with the subject of Trump’s original tweet. Typically they tweet short, positive statements about Trump with image memes attached.

Interestingly enough, the bots do have some semblance of intelligence. When Trump mentions Hillary Clinton in his original post, all three of them reply with a meme about the presumptive Democratic candidate. Before the smoke cleared and the bodies were buried in the Republican primary, Trump’s mentioning “Ted” and “Marco” got replies denigrating Cruz and Rubio.

So how do these bots work? All three accounts are pushing replies through an automated app, which you can see by examining the metadata of the tweets. Bergkamp’s (of @keksec__org) is called “Twitter Helper 3.0.” White Genocide’s is called “Stopping White Genocide.” The Neil Turner account seems to use several programs, most of them titled some variation of “Austrian Painter” (a not-so-subtle Hitler reference).

The Trump-replying is just a fraction of their total activity, which helps mask the automated tweets. All three accounts do healthy business retweeting each other and fellow travelers, like alt-right figureheads Ricky Vaughn and Mike Cernovich. Turner’s account also automatically replies to Hillary Clinton and George Soros.

The only one of the three that has any profile outside of Twitter is Jason Bergkamp, who writes for Vanguard14, a white-nationalist site that runs headlines like “Do you eat Corn Flakes? You eat Negro Piss.”

I spoke with Bergkamp via Twitter direct message. Initially he denied knowledge of any Twitter bots, but eventually fessed up. “I’m someone that flies around the world for work … however, this doesn’t give me the chance to always support Trump and prevent crazed Liberals from getting the top tweets to his post,” he told me. “Hence I automated some of my tweeting. However, the reason why I’m not too open about it, is because it’s a bit of a gray area in Twitter’s rules.”

He’s not wrong. Twitter actually has a set of guidelines barring automated replies and mentions (which is what’s happening here), but they were written to work against spammers, not political trolls. The service prohibits mass-mentioning and mass-replying to large groups of people, but says nothing about automated replies to a single account. Interestingly enough, Bergkamp seemingly disabled his bot shortly after we spoke.

@realDonaldTrump Disgusting reporting from the media the other day! They need to be held accountable! — Neil Turner (@NeilTurner_) June 15, 2016

The value of having the first reply is something the internet has been obsessed with for a while. On Twitter’s desktop platform replies aren’t always displayed in chronological order. The service’s algorithm pops comments with high engagement (replies, retweets , and likes) to the top of the pile and hides others. Being first doesn’t necessarily guarantee being seen.

But on mobile Twitter — where most people use it — replies are sorted only by time. That means that the most-prized real estate under a popular tweet is the first reply. And that’s the brilliance of these bots. With an incredibly low outlay of resources, you can piggyback on a user’s massive reach (Trump has nearly nine million followers) to deliver your own message, whether it be white nationalism or pictures of that one pig with huge balls. In practice, this means that people who read Trump’s tweets on their phones are likely to see him replied to with messages of support. It might be small stakes, but it can also create the distinct impression that Trump has more, and more zealous, support than he actually does.

So how do you push back? Now that we know how these Trump bots work, it’s time to build our own. I asked Bergkamp how his was made and he was gracious enough to reply: “It’s written in Python and converses with a PHP back-end via an API through JSON calls.”

So let’s get cracking. I don’t know Python but I know a little PHP, and that should be good enough.

The first thing I did was use Twitter’s API to get the most recent tweet in Donald Trump’s timeline, filtered to exclude replies and retweets. Every tweet has a unique ID number, so I saved the ID of that most recent tweet in a text file.

I then wrote a script to look at the ID of the most recent tweet and compare it to the text file. If they matched, Trump hadn’t issued a new tweet. If they didn’t match, he had — update the text file with the new ID.

Now that I could monitor precisely when Trump tweeted, I had to compose a response. I decided to have my robot reply to Donald Trump with randomly chosen lyrics from Kid Rock’s 1998 breakthrough hit “Bawitdaba.”

I set up a Twitter account at @bawitdonald to be the robot’s public face and connected it to Twitter’s API. Then I wrote a script to send a tweet with the response ID set to the new ID of Trump’s tweet; the text randomly selected from my database; and an image of Trump’s face photoshopped onto Kid Rock’s body from an archive of them I made.

Finally, it was time to pull the trigger. Twitter limits queries to a user’s timeline to 300 every 15 minutes, so I set it to update every 5 seconds. The downside of this bot, being written entirely in PHP, is that it needs to be in an open web-browser window to function, so I set up an old laptop and devoted it to the cause.

And this is for the questions that don't have an answer pic.twitter.com/xdbcbmv4z8 — Donald Diaper (@bawitdonald) June 13, 2016

It worked brilliantly. My response time was consistently under five seconds, fast enough to put me with the other bots and significantly quicker than any other human. I built a large-enough repository of Kid Rock lyrics that I didn’t have to worry about repeating tweets, even during Trump’s most manic periods.

It took me a little under three hours to write this code, which will run continuously as long as I keep a browser window open. I didn’t need a big check from David Brock to occupy one of the top spots on Trump’s reply timeline — just StackExchange and a few spare hours. It’s obvious that the appearance of mass popular support can influence coverage. But the fact that such an appearance can so easily be skewed by one person with a simple program running in a web browser should make candidates very worried indeed.