Introducing Chatterbot, a ruby library for producing bots.


Setting up a Bot

Make a Twitter Account

First thing you'll need to do is create an account for your bot on Twitter. That's the easy part.

Install Chatterbot

gem install chatterbot should do the trick.

Run the Generator

Chatterbot comes with a script named chatterbot-register which will handle two tasks – it will authorize your bot with Twitter and it will generate a skeleton script, which you use to implement your actual bot.

Write your bot

Chatterbot has a very simple DSL inspired by Sinatra and Twibot, an earlier Twitter bot framework. Here's an example, based on @dr_rumack, an actual bot running on Twitter:

    require 'chatterbot/dsl'
    search("'surely you must be joking'") do |tweet|
      reply "@#{tweet_user(tweet)} I am serious, and don't call me Shirley!", tweet

Or, you can create a bot object yourself, extend it if needed, and use it like so:

   bot ="'surely you must be joking'") do |tweet|
     bot.reply "@#{tweet_user(tweet)} I am serious, and don't call me Shirley!", tweet

That's it!

Bots in Action

You can check out the bots I've written on my Twitter Bot page, and there's a bunch of relevant stuff tagged as 'twitter' on muffinlabs.

Got questions? Did I document something poorly? Contact me here or on Github and I'll see what I can do about that.