Title: Perl RiveScript Tutorial Comment: Static web page.

Perl RiveScript Tutorial

This tutorial will help you get started with running your very own RiveScript bot, using the wildly popular dynamic programming language of Perl. This tutorial will outline everything from how to install Perl itself to how to get your bot up and running.

Table of Contents

Installing Perl

In order to run a Perl chatterbot, you'll need to install the Perl interpreter. If you're running a Unix-based operating system such as Linux or Mac OS X, you probably already have Perl installed, and you can skip this step.

For Windows users, the recommended Perl interpreter is ActivePerl. ActivePerl can install itself and associate your Perl scripts (.pl) files to it automatically. To download ActivePerl, visit their website at:

Getting RiveScript

After you have Perl installed, you'll need to install the RiveScript module, which enables your Perl bots to utilize RiveScript. There is a standard way of installing Perl modules, but I found that it's a little bit confusing for users new to Perl. So, I have a simpler solution:
  1. Download RiveScript from http://search.cpan.org/perldoc?RiveScript (click the link on the right side of the page under "Download").
  2. After selecting a bot to build from below (AIM or MSN), just copy "RiveScript.pm" from the RiveScript download in step 1 into the folder named "lib" in your AIM or MSN bot's folder.

Creating an AOL Instant Messenger Bot

Download the Bot Template

To get started on creating a RiveScript bot that will sign on to AOL Instant Messenger, download our AIM Bot Template. This is a simple bot that signs on to AIM, handles messages, and can even join chat rooms.

If you're using Windows and you can't open the file, make sure you have the latest version of WinZip. It can open "tar.gz" files.

Extract the archive somewhere on your computer. "C:\" will work for now on Windows, or your home directory on Linux and Mac. From now on, "C:\" or your home directory will be represented by a tilde (~) for this tutorial. So, ~/RsAIM would be "C:/RsAIM" on Windows, "/home/user/RsAIM" on Linux, and "/Users/user/RsAIM" on Mac OS X.

Install RiveScript

As mentioned above under Getting RiveScript, you'll need to install RiveScript if you haven't done so. After downloading RiveScript, move the file named "RiveScript.pm" into your "~/RsAIM/lib" folder.

Register an AIM Screen Name

If you don't already have a screen name for your bot to use, go to AIM.com and register a new screen name for it. Make a note of its screen name and the password you chose. If you already have a screen name for it to use, continue to the next step.

Configure your Bot

To begin setting up your bot, you'll need to modify the file named "RsBot.pl" in your bot's folder. This can be opened in any text editor, such as Notepad on Windows.

Note: If you're on Windows and you open RsBot.pl in Notepad and everything runs together on one line (Vista) or there are lots of "block symbols" everywhere (XP), open the file in WordPad and choose "File->Save", and then it should look fine in Notepad from then on.

Towards the top of the file is a bit of code that looks like this:

# Set up your bot's information here.
our $screenname = 'RiveScriptBot';
our $password   = 'big_secret_password';
our $master     = 'AdminScreenName'; # Your screen name, for admin purposes.
Fill in your bot's screen name and password in place of the values there. The $master variable should match your AIM screen name exactly. If your screen name has spaces and capital letters, $master should match that exactly.

Sign On the Bot

To sign on your bot, open a terminal session and change to the directory your bot was extracted to. Here are the steps to doing this on Windows:
  1. XP: Press "Start" and "Run", type "cmd.exe" and press Enter.
    Vista: Press "Start" and type "cmd", select "cmd.exe"
  2. At the command prompt, type "cd \". The prompt should read "C:\>" now.
  3. Type "cd RsAIM". The prompt should read "C:\RsAIM>" now.
  4. Type "perl RsBot.pl" to start the bot.
Note that if you stored your bot in a different place, you'll need to take that into account when navigating at the command prompt.

If all goes well, you should see your bot sign on. Send it a message and say hello.

Creating a Windows Live Messenger Bot

To Do.