How to Make a Twitter Bot: The Definitive Guide

This article is a draft, feedback and suggestions are very welcome!

Hey there, Stefan here!

So you want to make a friendly/useful/artistic Twitter bot and probably have a bunch of questions, like How often should my bot tweet? or Why am I getting this weird error message? and How do I even make a Twitter bot?

Hopefully this ambitiously titled guide will answer your questions -- and you are always free to ask for more help in the Botmakers community.

Note on needing a phone number

Quick note before we begin. One important requirement for making a bot on Twitter is attaching a phone number to your bot's account. While this is more of a technical aspect of botmaking, it can be a real pain to deal with, so it's best to get over with it early.

For more information on this, check out the Twitterbot tutorials page here on Botwiki.

What kind of a bot should I make?

Let's first talk about the kinds of bots you absolutely should not make. Start by reviewing Twitter's Rules and best practices and their Automation rules. There are also API rate limits, but we will get into that shortly.

The bottom line is this: don't let your bot annoy people. Try to avoid interacting with people who don't follow your bot or knowingly initiate the conversation either through a tweet with your bot's handle, a direct message, or a unique dedicated hashtag (see @NixieBot for an example of such approach).

There certainly are clever examples of bots who do interact with random Twitter users who didn't explicitly opt-in, but this is a bit of a gray area and you should use your best judgement here.

And it hopefully doesn't even need to be said that you shouldn't make bots that harass people, post spam, or do any other malicious activity. Remember, bots should always punch up, never punch down.

As for what your bot should do, well, here are a few tips:

For even more inspiration, check out these essays and articles.

Making a (Twitter) bot is not always a straightforward process, with steps to go through. Sometimes the decisions you make affect each other, for example, you can start with an idea and then decide what language and hosting platform you'll use. But you can also first look at the various platforms you can use to host your bot and play with their strengths and limitations. More on that in an upcoming section.

Can I make a bot that tracks keywords or hashtags?

From Twitter's Automation rules:

Automated Retweets: Provided you comply with all other rules, you may Retweet or Quote Tweet in an automated manner for entertainment, informational, or novelty purposes. Automated Retweets often lead to negative user experiences, and bulk, aggressive, or spammy Retweeting is a violation of the Twitter Rules.

As explained above, there are some gray areas when it comes to automating certain actions on Twitter, including automated retweets.

One way around getting your retweet bot suspended is to make your bot private. This way you can follow the topics you're interested in without bothering anyone since notifications from private accounts don't show up to people your bot is not following.

The biggest drawback here is that it will be harder for others to discover your bot, and as of February 2017, there is no way to approve follower requests for a protected account via the Twitter API, so you will have to handle follower requests manually.

How often should my Twitter bot tweet?

Alright, you might have a rough idea what your bot is going to be posting about now, great! How often should it post though?

As I mentioned earlier, Twitter has limits on how often you can call their API, so you should keep those in mind.

Other than that, it's all about striking the right balance. If your bot tweets every time a certain event happens, it's okay if your bot posts more frequently, as long as it stays under the API rate limit.

But also consider that some people don't want their home timeline cluttered with just one account, so for bots that don't work with real-time data, spacing the tweets out makes a lot of sense. As I said above, one good rule to follow is to make sure your bot doesn't annoy people.

There are bots that post every hour, once or twice a day, or even just once throughout the whole year.

Here are some thoughts from a member of Botmakers:

Hard question. I look at it as a logarithmic-scale line starting at once a minute and ending somewhere around once a week or month.

There is a hard upper bound of 25 tweets per 15 minutes per account.

There are multiple approaches you can take to figure this out, and they're mostly situational:

The easiest approach is to have your bot post as often as it can, like if you're running @congressedits, you want to catch all edits.

If you have too much information for this and need to attenuate the flow, or if your corpus is fixed or precomputed, then it comes down to questions like, do I want to follow this bot myself? How often would I like to hear from it if so? Is there prior art that I am mimicking? If it's a fixed corpus, how long should it run before it ends? How often would others like to hear from it? should it be annoying/how much so?

If you're unsure, post every 30 or 60 minutes, tweak it later if you don't like it.

-- @air_hadoken

Do I need to attribute content tweeted by my bot?


How do I make a Twitter bot?

With most of the non-technical questions out of the way, it's time to actually build your Twitter bot.

Botwiki has a lot of tutorials and there are many open-source Twitter bots and Twitter bot project templates on Glitch that you can use.

Just find one that's close to your own bot idea and take it from there.

Where should I host my bot?

There is a number of platforms you can use depending on how much you're willing to spend (no worries, free options exist) and how comfortable you are dealing with web servers.

Also, when coming up with ideas for a new bot, it might actually be helpful to start here. For example, Cheap Bots, Done Quick! is a site that lets you make bots using Tracery and hosts them for free. It doesn't require advanced programming skills, but is flexible enough so that you can get really creative.

Glitch gives you more freedom while taking care of most of the technical challenges for you (and comes with some cool libraries pre-installed). And it's also free to use.

For a comprehensive list of available hosting platforms, see the Bot hosting page on Botwiki.

Why is my bot not working?

Twitter will send you an error message that should help you understand why your bot stopped working.

For example, if you're using the Twit library, here's how you can see the error message:'statuses/update', { status: 'hello world!' }, function(err, data, response) {
  if (err){

It's possible that your bot tweets or reads the data from Twitter too often, then you just need to adjust the frequency. It's also possible that your bot was suspended, in which case you will also get an email notification and instructions on what to do next.

If you're not getting any error messages from Twitter, and the bot doesn't seem to be suspended, the problem might be with your code. It's perfectly fine to ask for help, in fact, that's why the Botmakers community exists. Glitch even has an "ask for help" feature built right into it.

Wrap up

I hope this guide will help you deal with some of the biggest questions and challenges of making friendly Twitter bots. Be sure to join us in the Botmakers community. We are artists, journalists, educators, tinkerers, bot enthusiasts, seasoned developers, and always happy to help a fellow botmaker out :-)

If you'd like to leave me feedback and suggestions for this guide, feel free to send me an email!

PS: See more of my tutorials here.

Special thanks

  • Eric (

Last updated on July 3, 2017.

#tutorial #guide #twitter #twitterbots #tweet frequency #api limit #api rate limit #how often should bot tweet #hyperdev #glitch #cheapbotsdonequick #cbdq #hosting #keywords #hashtags #phone number #fourtonfish #botwiki-original

Botwiki is a personal side project that's made possible through donations and hard work and dedication. Huge thanks to everyone who helped us out! 🙌 PS: Here's a list of our supporters.