Matt's Blog

Twitter Bot: Magic 8 Ball

April 22nd, 2008 at 7:24 PM (17 years ago) by Matt Freedman

On the Weekend, Gary Jones from BlueFur (Twitter: bluefur) came up with the idea of a Twitter robot that would act as a Magic 8 Ball. He asked me if I wanted to help make it, I accepted, and development began.

What we came up with was a small script that would automatically reply with a Magic 8 Ball-type answer when it was “replied” to. To use it, all you have to do is write a “tweet” replying to magic_8ball with a yes or no question. Which would look like this “@magic_8ball <yes or no question>”.

This little “Twitter Bot” uses the Twitter API to receive the replies to it, and then send out replies with a randomly selected answer. We quickly found out that the Twitter API is quite restrictive. As outlined in Gary’s post, Twitter only allows 70 authenticated API requests an hour, which not only inconveniences developers while testing their Apps, but also users using Twitter Apps. Also, Twitter restricts API calls for replies and such to the latest 20, which can create quite a few problems.

We’ve decided to make this application Open Source, so that other developers looking to develop with the Twitter API can hopefully learn from our code. Feel feel to use, modify, hack and learn from this code to create your own Twitter Applications. The code is release under the GNU General Public License version 3 (or, at your option, any later version). You can get the code here (or in txt format here).

If you have any questions about the code, feel free to let me know.

I’m on Twitter under mattfreedman, feel free to follow me.

5 Responses to “Twitter Bot: Magic 8 Ball”

  1. Wil Reynolds
    Wil Reynolds says:

    Thanks for sharing, we are going to be looking into creating a fun bot and I can imagine that your source will only help us. Thanks!

  2. nic
    nic says:

    mad idea – trying it out myself, but keep getting error410 (Could not authenticate you)

    using the right login password, can’t figure it out. this is the first time i’ve played with the twitter api, so i’m probably missing something fairly obvious.. =P

  3. Matt Freedman
    Matt Freedman says:

    This code is out-of-date now (Twitter changed some API things awhile ago) and isn’t actively maintained. However, it shouldn’t be too hard to fix, if you have some time check out the Twitter API Documentation. Building this little bot was a great learning experience, and updating it should be the same. :)

    Besides, nobody ever used our @magic_8ball bot (and it’s obviously broken now). 😉

  4. 1 domain(s) destroyed — Secret.
    1 domain(s) destroyed — Secret. says:

    […] good idea does not merit implementation. Incidentally, it looks like someone else did work on a similar project (though that looks to have gone extinct now […]

  5. madsen
    madsen says:

    Heh, I was 3/4 of the way through completing my own, when I decided to google if this has been done before. It is a great learning experience though.

    Mine is @8ball_

Leave a Reply

Quote selected text

Leave the following field empty: