For the past 10 years, I’ve been fortunate to be involved in making software that was adopted mostly by teenagers and fell in love with the demographic. Born into the hi-speed wifi era, teenagers are using the digital ecosystem the amplify and empower their relationships and social circles. Sometimes though, this ecosystem, especially around social networks, can bring out feelings of loneliness and being excluded from a community.

What’s all that has to do with bots?

Around 7 months ago I went on a mission to use code to spread positivity and created CheerBot. CheerBot is a bot that lives on Twitter with one goal on its mind: Send positive messages to people that needs them the most. The thought process behind CheerBot is a simple one: Positive messages can come a long way, especially coming for our friends which we often times take for granted. Getting an occasional “you are loved” or “one of your friends wants you to know they have your back” at the right time proved to be transformational and the reactions to CheerBot so far are truly amazing.

Building CheerBot exposed me to the Twitter API for the first time and gathered notes along the way. I went from not knowing what I’m doing and getting blocked by Twitter to going on vacation and keeping CheerBot running on 90% uptime (as long as I have internet, CheerBot is running). Here’s my story.

The early days: Getting blocked by Twitter, a lot (how not to run a Twitter bot)

In the early days, the core flow for CheerBot was:

What a rollercoaster it was. People responded super well to the concept and sending roughly 30 cheers per hour. Their friends got exposed to it, loved it and wanted to cheer other friends. Positivity was spreading!

The problem was I couldn’t keep CheerBot up for more than a couple of hours straight. The “your application was restricted from performing write actions” (basically messaging people) screen happened a lot and users were disappointed when it wasn’t consistently working and I was scrambling for a solution. What’s worse is that as I was trying to figure out the issue the and tweak my code accordingly, the restriction happened more often, from hours to half-hours to minutes.

My first reaction was “CheerBot is a positive project for the community, I should get a free pass!”. I went through a full appeal process with Twitter’s safety team, was re-granted access but got restricted shortly after, went through a discussion in the official forums - they won’t respond to individual cases. Was looking into Twitter’s automation rules - kind of ambiguous. I was feeling skeptical about CheerBot’s future at this point. I even tried couple of moonshots like getting in touch with the Twitter community projects team and Twitters’s sales team to get some insight on how big players are getting a pass doing similar things (hint: 💰).

Then I actually got a hold of a nice person from Twitter’s support who couldn’t tell me much about how to go around the restriction rules but said the following: “CheerBot is a great positive project and I would hate to see it go. You have to understand that for each great project like yours we have hundreds of spammers and malicious projects. You’re super driven, you’ll find a way”.

My path to 90% uptime, how to avoid restrictions

The following months after were a crazy research frenzy on how Twitter’s spam protection actually works and what can I do to keep CheerBot’s core functionality intact while not going into Twitter’s red zone. Some of the information is available online, some I got from Twitter agents I worked with in the past (obviously they couldn’t spill the beans, but were helpful) and the majority of it I got though tons of trial and error and deduction.

Over the past couple years Twitter has done some major leaps in detecting automated patterns and bot behaviour, most of it through machine learning and to an extent it’s a cat and mouse game between the bad people who use bots for phishing and scam and Twitter’s security algorithms. The more a bot adopts patterns and usage habits that fits a human user, the more difficult is it to block it. In addition, automated services push tweets through the API that has its own rules on connections, how often can you tweet and who are you tweeting at in relation to the user that initiated the request.

After a ton of research, there are couple of flow limitations that either flagged CheerBot or triggered a restriction:

Here’s my current working model for CheerBot

Additional stuff that helps

CheerBot’s such a fun ride and I’m happy to try and help if you have have any questions about running a bot on Twitter.

Feel free to send a message my way @omerkaplan!

#programming - look at me I'm building stuff!

Latest Posts in #programming