Getting Started with the A.L.I.C.E. Bot and Mac OSX

A beginning tutorial on using Mac OSX to install, modify, and serve A.LI.C.E. Bot

By Caleb John Clark (© 2001, 2002), with help from Brett Clapham and the Alicebot open source community - 07/15/01. Last update 02/02/2002.


NEWS: The Alicebot project has resulted in a site that pretty much makes the below tutorial obsolete.

The Pandorabots site hosts bots for free and lets you edit and play with them all through a web browser. They even convert text to AIML for you. And they have a great tutorial.

If you find an install for OSX the below might be of some help if you want to run the bot on your own box or server. But I am no longer going ot update this article and the links are likely to cobweb at some time.

A.L.I.C.E. Bot is an award winning open source chat robot.

What you'll need:
  1. A Mac running OSX.
  2. A Text editor like OSX's TextEdit, or BBEdit for OSX.
  3. A current Web browser
  4. Optional: High speed always on Net connection and HTML experience or an authoring program.
alice chat bot: computer woman face

Contents


Introduction


The subject of Artificial Intelligence has interested me for many years, but I've found it hard to get involved because I'm a Mac user and not a practiced programmer. Then I met ALICE and installed Mac OSX and it was love at first chat. The two are a good couple. ALICE is award winning chat bot that is free to download and modify because it's open source and she runs using Java which is platform independent. ALICE is programmed in an easy to modify XML spec called Artificial Intelligence Markup Language (AIML). Combine that with OSX which propels Mac users into a new level of geekdome because of its UNIX base and new tools, and you've got a great environment for newbies to work with some basic A.I. by "Variable Hacking" existing code.

I have written this tutorial as my contribution to the ALICE open source community in the hopes that it helps the effort. I hope it helps the ALICE community and makes people think about and use A.I.


Download and Install


Start this tutorial by talking a little to the bot we're going to work with. Go to the ALICE Foundation Web site and click on "Talk to ALICE" in the upper right of the page. Try typing "What's the latest gossip?" and "What do you know about me?"

We're going to download and unstuff all the files we need to serve and modify our own ALICE bot.

  1. Using a current browser and OSX, Download version 4.1.4 of Program D or any other program you can find that will run on OSX.
  2. Unstuff the file. You should now have a folder called "ProgramD_4.1.4" that looks something like the image to the right.
  3. Put the "ProgramD" folder into the "Develolpment" folder of your User folder.
alice chat bot: folder structure

Below is a description of some of the key files. We are most interested in the "SERVER.sh" file which we'll use to start ALICE in the next section.

  • File "server.sh"
    The shellscript to run your server on Linux, Max OSX and other brands of UNIX
  • File "server.properties"
    This file contains the server configuration.
  • Folder "bots"
    This is where all your AIML is stored. The default bot is called Alice, but you can specify other bots as well.
  • Folder "templates"
    Templates for different platforms. File "chat.html" is the Web Interface.

Start Server


(If you are UNIX savvy refer to the image to the right and you'll get the point. If not, read below).

With OSX, this is no longer your mother's Mac. We're going to use a utility called Terminal and its command line interface to launch a Java shell script that will start up ALICE (cool huh!).

Caution: The Terminal interface does not have any safety protocols that ask such things as "are you sure you want...". Type carefully.

The screenshot to the right is a record of what you're going to do. Text that is underlined is what you will type. The rest is what you're hopefully going to see happen.

  1. Go to "Applications/Utilities/Terminal" to start Terminal up. A small text window will come up with only first line in the image to the right "[localhost:~] name of your home folder." This is your command line for entering instructions.
  2. Type "ls" and hit return. This means List Files and will show you where you are. You should then see the folders that are in your User folder.
  3. Type "cd Development". This tells OSX to Change Directory to your Documents folder.
  4. Type "ls" again to see where you are You should now see the contents of the server folder.
  5. Now we'll bot the bot! Type "sh server.sh" using that exact upper and lower cases.
  6. You should then see the line "Starting Alicebot.net 4.0 Beta Server..." and the rest of the lines below it start to appear in series. When you see "underfined", you're booted baby!
  7. Try typing "Hello" after the "undefined" line. You should see ALICE think a little and respond as shown in the last lines to the right.

Congratulations! You've birthed your first bot.

Next we need to get ALICE running in a Web browser.

alice chat bot: terminal data

(Lots of code and text appears here as the bot loads,
then near the end you'll see this:)

alice chat bot: terminal hellow world'


Web Interface

OK, that was cool but we need a much better interface for our bot. Luckily ALICE comes with a ready made Web page interface pictured at right.

  1. Open Internet Explorer 5.0+ or another fairly new browser like Opera.
  2. Enter the URL after the line in the Terminal Window that says "HTTP server listening at".
  3. You should then see a default Web interface for ALICE similar to the one at the right. Try talking to her a little to make sure she's still working.
  4. Now if you want to see ALICE work while you talk you can arrange your desktop so you have a view of the Terminal window and the Web interface.


If you have a fast Internet connection we're now going to go pubic. If you do not, or you're working off-line skip to the next section.

        alice chat bot: alice chat window

        Web Serving (Optional)

        Now, if you have a fast dedicated (always on) connection to the Net, it's time to go public! Ideally you're be on a personal cable modem or DSL, with no firewall. If your network does have a firewall you'll need to have access to port mapping to make it public on the Web.

        ALICE comes with a built in Web server that uses your computers 2001 port (Don't worry, you don't actually have to know what that means).

        1. Make sure you're connected to the Web on your network.
        2. Drop the Apple Menu down to "System Preferences"
        3. Select "Sharing"
        4. Make sure it looks like the graphic to the right. Since ALICE has a built in server we do not need to enable Websharing. Low in the window you'll see the IP of your computer.
        5. In a browser, enter "http://yourIP:2001". So for the below IP we would enter "http://192.168.100.248:2001"
        6. Call or email a friend and have them try that same URL.

        Now all you have to do is fight the urge to immediately buy an OSX dedicated server and go into the bot business!

        Trouble shooting: Firewalls and other complications are common at businesses and on small networks. These can prevent your computer from being "public" on the Web. At work you can ask your IT department if they feel comfortable "port mapping" port number 2001 to your computers IP address temporarily so you can experiment with your baby bot. Show them what you're doing and most likely they'll be very interested in experimenting as well. Once this is done you can often use your networks domain and the port as the address public Web address, e.g. www.yourcompany.com:2001

        alice chat bot: starting server in osx

        Birth Your Own Bot

        We love ALICE just the way she is...but, since she's open source we can change her name and personality and thus customize her into our own bot.

        However, we must remember to give credit to Dr. Richard Wallace, Program D author Jon Baer, and the open source community so as not to lead people to believe that we created this bot all by ourselves.

        We'll change her name here. More changes can be made in the "Advanced" Section later.

        1. Open this file in BBEdit for OSX: "server\bots\Alice\startup.xml" Don't panic if you're not a programmer, we're only going to change variables.
        2. You'll should see the code to the right plus a lot more.
        3. Type your new name in the underlined parts of the code and change the gender if you want. Then reboot your bot in the terminal line.

        alice chat bot: code


        Modify the Web Interface (Optional)

        This screen shot is of my first bot. If you want to change the look of the Web Interface you'll need to know basic HTML or an authoring tool like Dreamweaver, GoLive, Homage, etc.

        1. Make a copy of "server/templates/html/chat.html" so you can go back if you mess things up.
        2. Open the file and take a look. This code is well commented and pretty self explanatory if you know HTML. <bot_xxx>
        3. Modify at will.

          It's a good idea to constantly check your work in a Web browser by clicking on "Refresh". That way you won't get to far past a bug and not be able to find it easily.

              alice chat bot: bat bot screen shot


              Advanced Teaser


              Caution: Start any real hacking jag by making a copy of your nice working "server" folder, you may need to go back to it if you make a mistake. And, as you make changes to ALICE make sure to always check them by talking to her. You don't want to change too much code without doing this, or you'll never be able to find out where you broke your bot if you do something wrong.

              The best place to start for more resources is the A.L.I.C.E. Foundation Web site.

              Hacking. Now that you're a downright dangerous hacker you can get into some real trouble.

              • Start opening up some files in your bot folder with "std-" in the file name. You'll notice AIML language works generally with chunks of code within a <category> tag. On a very basic level the bot looks for what people say, <pattern>, and responds with <template>. You can try changing the text within <template> tags, then rebooting the bot and asking the exact question in <pattern> to see your new answer come up.
              • Any easy first hack is to change the greeting. Open up "server\bots\Alice\std-connect.aiml" and change the text that says "Hello there" to something else, then reboot your bot.
              • The AliceBot.org site has supporting documentation on how to learn to code AIML.

              Reverse Engineering

              1. Look at all the files in BBEdit in the bot you're running at: "server/bots/Alice/".
              2. Now watch the Terminal window while you talk to Alice. You'll be able to see which ".aiml" files the program is accessing to respond to each question.
              3. You can then open up that ".aiml" file in BBEdit and find where the code is to change that response.

              ALICE Remembers

              1. Type "what do you know about me?". You should see a table of what ALICE can remember. Type your name or age and ask her again. Notice the "Personality" section. If you are mean to ALICE this will change to "Aggressive". Experiment with trying to get ALICE to remember things about you.
              2. Type "what's the latest gossip?" and you can access her gossip function. We can guess that this works by writing "I" statements from other people ant a text file that it randomly access.

              AIML code and documentation


              Feedback


              Feedback on this tutorial is much appreciated. Bug reports? Suggestions? Typos? Just email the author at "calebjc@well.com"