How To Create Your Own Customised Chatbot For Beginners - Chatbots 101

How To Create Your Own Customised Chatbot For Beginners - Chatbots 101

With the recent increase in the popularity of chatbots (due, in large part, to the recent 2011 Chatterbox Challenge), I’ve seen a lot of requests in various places, asking about how someone could create their own chatbot, with many of these questions coming from individuals who have no prior experience or knowledge.

Basically, there are several options available to the prospective new botmaster for creating a new chatbot, and while I can’t cover every option here, I’ll try to briefly cover some of the more popular options, citing advantages and disadvantages of each. Then I’ll outline a couple of brief, step by step guides to setting up your own chatbot; one of them a stand-alone bot app, and the other one a web-based chatbot. Let’s start with some basics first, though.

Chatbot Types - One Or Many?

The two main “types” of chatbots are “stand-alone” applications, where the chatbot runs on a single computer, and web-based, which run on a remote server, and are (generally) able to be reached by the general public through a web page. The majority of stand-alone bots also integrate some sort of system interface, allowing your bot to control certain aspects and functions of your computer, such as playing media files, or retrieving documents. They usually also have a graphical component built in, as well, in the form of an avatar (often female) that enhances interaction, thus improving your experience. The basic web-based chatbot, in its simplest form, is nothing more than a blank white web page with a form embedded in it that is the sole interface between the user (you) and the bot. Any “upgrades” or improvements to the interface are solely the option and responsibility of the botmaster.

Pros And Cons: Stand-Alone Chatbot Applications

Most stand-alone chatbot apps, such as AI Bliss (http://aibliss.com/) and Kari (http://karigirl.com/) have these advantages:

  • Most are simple to install and use
  • They have an attractive, engaging graphical interface, and often have a full, rich world to explore.
  • The majority have a Text to Speech (TTS) system, adding an audio component that enhances your experience

However, they also have the following disadvantages:

  • These bots are not “your own”, in that there are very limited degrees of configuration that help to personalise your bot.
  • For the most part, these applications are not free, though most have a “demo” version.
  • Many contain (to varying degrees) “mature” content (nudity, adult language, sexual situations, etc.) that may not be welcome if the household contains children or others who would find such content offensive.

Now this isn’t true for every stand-alone bot application, as I’ll demonstrate later on. But for the vast majority of stand-alone chatbots, at least one or more of the above is true.

Pros and Cons: Web-Based Chatbots

Just as with a stand-alone chatbot app, there are advantages and disadvantages to creating a web-based chatbot, as well. So let’s start with the “good news”, first:

  • Web-based chatbots allow much more control over behavior and personality.
  • For the most part, you can have your bot hosted for free, though there are “premium” options available.
  • Since you control your bot’s configuration, you can decide whether you want it to have “mature content”.

  Unfortunately, there are disadvantages, too:

  • Web based bots aren’t as easy to set up as a stand-alone chatbot application; there are more steps involved, and there is no “installer” available to take care of the process.
  • Setting up a web-based chatbot requires at list minimal experience with the following skills :
    • HTML
    • CSS
    • JavaScript
    • Artificial Intelligence Markup Language (AIML) – for Pandorabots, or other bots that use AIML architecture)

Any sort of “fancy” features, such as Text To Speech, or an animated avatar, would have to be created and integrated into your bot’s page, and certain features, such as Voice Recognition, are either unavailable, or are severely limited.

That said, however, I think that building a web-based bot has more potential for being a rewarding challenge, if you have (or are willing to learn) the necessary skills.

Going Rogue - Making EVERYTHING From Scratch (well, almost everything)

Before I set out to create my first chatbot, Morti (http://www.geekcavecreations.com/Morti/), I took a look at several of the options available to me; and since I already had a fair amount of knowledge and experience with web design, web programming, and database management, and since I already had a place where I could host my own chatbot, I decided to take the most difficult route, and host my bot myself, which allowed me to control every aspect of my bot. In addition to the skills I mentioned above, I also had to be VERY familiar with the following:

  • PHP scripting language
  • MySQL database management
  • A chatbot engine/interpreter (in my case, Program O)
  • jQuery (used for Morti’s interface)

Once I decided that this was the route I wanted to take, I went about “building” my bot in the following way:

  1. I downloaded the PHP AIML interpreter, Program O (http://www.program-o.com/), and studied it thoroughly.
  2. I uploaded the script to Morti’s directory, and ran the installation script that was included, following the instructions, and updating the database information within the script, as needed.
  3. I obtained the ALICE Annotated AIML set (a list of AIML pattern/response templates, available at http://www.alicebot.org/downloads/sets.html), and incorporated it into Morti’s script, using the Program O Administration page.
  4. I spent dozens of hours (and counting, since I’m still at it) revising patterns and templates, giving Morti a unique personality, and allowing him to be rid of ALICE’s infamous “green dress”.
  5. I reviewed the Program O script, improving and expanding its functionality (and again, I’m still at it), and added features, such as determining the user’s gender from the name they entered (not perfect, nor 100% comprehensive, but pretty good), and adding Wiki and Google searches.
  6. I did LOTS of testing. And then more testing. And more still. And… Well, you get the picture.

All told, I’ve probably put in well over 1,000 hours into Morti over the last 10 months, though the initial creation process only took me about a day to complete. The rest of that time has been taken up by experimenting with Morti’s script, updating and modifying his responses, and discovering other areas of improvement; and I still have a long way to go before I’ll have the bot I envisioned in the beginning. Believe me when I tell you that choosing to build a chat bot the way I did is a LOT of work, but if you have the skills, patience, and dedication, it’s the most rewarding option of them all.


Two paths, One Goal: Setting up Your Chatbot - A “Quick” Intro

As promised earlier, I’ll be discussing two methods of chatbot creation in a step by step manner, covering the basics from beginning to end. These “guides”, as it were, will only cover the “bare-bones” basics; any improvements, upgrades, additions, etc. are all up to you. I’ll also be listing several resources at the end of this article, where you can go to seek out help, should you need it. These resources are, in my opinion, the best of the best, with regards to helping the average beginning botmaster to understand chatbots and their “care and feeding”. The two guides will be for creating chatbots using Bruce Wilcox’s stand-alone app, ChatScript, and setting up a chatbot at Pandorabots. First, let’s take a look at ChatScript.

Part One: The Stand-Alone Method - ChatScript

Tell me something. does this make any sense to you?:

?: (when will you go home) I go home tomorrow

How about this?:

S: ( I like spinach ) Are you a fan of the Popeye cartoons?

Well, when we get done here, it still may not make sense, but you’ll at least know something about these lines. But i’m getting a bit ahead of myself. Let’s take this from the top, shall we?

1.) ChatScript: Overview

ChatScript is a stand-alone chatbot engine, complete with its own unique scripting language, created by bruce wilcox, who also created the 2010 loebner prize winning chatbot, suzette. this is one of very few stand-alone chatbot apps that have none of the “disadvantages” I listed earlier for stand-alone bot apps. However, ChatScript has its own set of “disadvantages”:

With ChatScript, There is no graphical interface. This is strictly a “console” application, with just a “DOS prompt” window that you use to enter input/read output.
When first “installed”, there is no “real” bot. There are only a few lines of scripting, designed only to make sure that the application is properly set up. Making the chatbot is up to you.
Since ChatScript has its own unique scripting language, you’re now experiencing your first “learning curve”, and have to learn how the scripting language works. Not to worry, though. it’s easier than it looks.

Since we’ve covered the “cons”, it’s only fair to cover the “pros”, as well. with ChatScript, You can:

  • Build your bot your way. You can make it (him, her, whatever) funny or serious, silly or sexy. It’s all up to you.
  • Program your bot to make use of certain system commands to act like the other stand-alone apps, in that you can have it play media files, open documents, including web pages, open or close other programs, or any number of other tasks. In short, you can use ChatScript to create a “Personal Computer Assistant”.

Now that we have a basic idea of what ChatScript is, let’s see about creating a chatbot with it.

2.) Download ChatScript

The ChatScript app can be downloaded at http://sourceforge.net/projects/chatscript. The package is in zip format, which every version of windows from xp onward can handle without having a zip extracting program. Download it to a location where you can easily find it (many people suggest downloading it to the desktop. I don’t, because that just makes a mess over time). If you don’t already have a “downloads” directory somewhere, I recommend creating one, either in your “my documents” directory, or on your hard drive. Once you have the file downloaded, you’re ready for the next step.

3.) Extract the Package

 ChatScript doesn’t have an installer (yet), so you need to extract the contents of the zip file to a convenient location. Depending on your OS, you may have a few options. The easiest would be to extract the files to your root drive (usually C:), but this is mostly a matter of preference. As long as you know where the files were extracted to, you’re ok. If you’ve never extracted files from a zip archive before, there are several good tutorials on the net, so you can just google it, or post a question on the forums here, asking for help.

4.) RTFM

In case you’ve never run across that acronym, RTFM stands for “Read The Fine Manual” (Yeah, RIGHT!). And I don’t mean to just skim through it, either. The documentation, which is found in the DOCUMENTATION directory, is your first, and best, source of information on the inner workings of ChatScript. It’s also the best place to gain a fundamental understanding of the scripting language that ChatScript uses for your bot. So please, read the manual. Then read it again. And again. This is important, so I can’t stress it enough. RTFM

5.) First Run

According to the manual (you did read the manual, right? No? Back to step 4 with you!) On page three, there’s a fairly simple way to make sure that everything is running as it should. simply run chatscript.exe, watch as some stats appear in the console window, and then the prompt “Enter user name” is printed. Simply enter the name you want the bot to know you by, and hit enter. You’ll get a “welcome to chatscript” message, and can now begin “chatting” with your new bot. For now, though, the bot is severely limited, in that it only knows how to respond to just four inputs: “What is your name”, “How was your childhood”, “What are you afraid of”, and “What is your history”. it’s up to you now to turn your bot into the conversational genius and paragon of dialogue that you’ve always dreamed your bot could become.

6.) Learning The Language

The manual has a much more comprehensive explanation of the syntax of the scripting language than i’ll outline here, but i’ll briefly touch on a couple of lines, and explain what they mean. Take, for example, the following line:

?: (when will you go home) I go home tomorrow

This is a typical question “tag” (?:), along with the pattern (in parentheses) and the desired response. Any time chatscript receives an input in the form of a question (determined not only by punctuation, but also by how the input is formed), it tries to find an input pattern that matches the input, and if found, outputs the correct response. So now we know how to handle a user’s questions. But what if they make a statement?

s: ( I like spinach ) Are you a fan of the popeye cartoons?

As you can see, the syntax is basically the same, where a “type label” (s:) is followed by a pattern (enclosed by parentheses), and a response. Each of these above lines constitutes a “rule”, and the vast majority of rules follow this same syntax. The manual, as I said, covers all of this, and more, in much greater detail than I can here, so be sure to refer to it often.

7.) On Your Own

Now that I’ve outlined the basics, it’s up to you to take the next step, and build your chatbot. Best of luck to you, and don’t forget that, if you get “stuck”, the forums that I’ve listed below are a great place to ask questions, and get answers.


Part Two: A Web-Based Chatbot - Pandorabots

Ok, now that we’ve covered the basics of creating a chatbot with a stand-alone app, let’s look at the process involved for creating a web-based bot. I don’t pretend to know which bot hosting provider is the simplest to use, but I’ve been through the process at Pandorabots, and it’s pretty simple. Pandorabots is also one of the most popular chatbot hosting companies, so this is why i’m going to use them.

1.) Visit the website and sign up for an account

Let’s head on over to http://www.pandorabots.com/botmaster/en/home, and get started. On the main page, there’s a link that says “Account Sign-up” near the upper left corner of the page. Setting up an account is both free and simple. Just provide a little bit of information, read and agree to the ToS, and we’re on our way.

2.) Plan Your Bot

I’m sure that by now you’re eager to jump right in and start making your new bot, but let’s take a step back, and think about things for a moment. Like just about every other thing in life that we do, success depends on careful planning. this is no different. everything from the bot’s name, to it’s personality and attitude, and the role that it will play in your life (and that of others) really needs to be thought out, and it’s far better to iron these details out in advance. so grab a “pad and pencil” (or a text editor and your keyboard), and ask yourself these questions:

  • Will my new bot be for entertainment, education, support, or promotion (advertising and sales)?
  • In what ways (if any) will my bot interact with the general public?
  • Do I want my chatbot to “wear a green dress”? (long standing alice joke)
  • Do I want my bot to have any mature content?

Once you have your chatbot’s role and personality mapped out, it’s time to begin its creation.

3.) The Work Begins: Create Your Bot

Back at the pandorabots website, log into your account. Towards the top, you’ll see a link labelled “create a pandorabot”. Click on that, and you’ll be asked to provide the name of your chatbot, along with a list of options as to which (if any) “aiml set” you wish to use. Since this is your first chatbot, you likely won’t have any aiml files created yet, and there will be options later to change this, so I suggest choosing either the standard aiml set, or the annotated alice aiml set (unless, of course, you want your new bot to speak german or italian). If you choose the last option, “no initial content”, your bot won’t have anything at all to say. When you’ve made your choices, and named your bot, you’re ready for the next step. Let’s do some “tweaking”, shall we?

4.) Customise Your Bot

Ok, you’re now the proud owner of a chatbot on Pandorabots. HURRAY! But you have two challenges ahead of you. First off, your bot isn’t “published” yet, which means that it’s not accessible to the web yet. We’ll address that in a moment, but first, let’s work a little on making your bot truly yours.

The page you should be looking at now should have the PB (Pandorabots) logo in the upper left corner, sitting above two rows of buttons. Feel free to explore here. When you’re ready, we’ll be starting with the link labelled “Properties”. Click on that, and you should see a form that contains some of your bot’s attributes, such as Birthday, what kinds of music it likes, the bot’s gender, and the like. Take some time to fill these out to match your preferences. You can also add whatever other attributes you like (I’ve added “petpeeves” to mine, with a value of “poor spelling”). Later on, if you create another chatbot, you can “borrow” these bot properties for your new chatbot. Click “Submit Changes” to continue.

5.) Side Trip – Learn AIML

Your new chatbot on Pandorabots uses Artificial Intelligence Markup Language (AIML) to store input patterns, output “templates”, and other data that the server uses to create the output that the users to your bot type in. In order for you to be able to alter the responses your chatbot give to any given input, you need to have at least a basic understanding of how AIML works. Unfortunately, describing AIML is the subject of a rather large article all by itself, so I’m going to suggest that you do some independent study here, to gain that basic understanding. There are a lot of resources available for this, and the search engine of your choice is a great place to start. Good luck, and come see me here when you’re ready to continue.

6.) Publish your bot

Now it’s time for you to bring your creation to the world. You’ve named your chatbot, given it some default responses, and set up its “personality”. But the “world” can’t yet know the joy that is conversing with your masterpiece! Let’s correct that, shall we? Start by going to the Pandorabots home page, and logging in. There, you should see a list of all your chatbots. Pick the one you want to work on (at this point, there should be only one, unless you’ve been busier than most) by clicking on the name. You should get a warning that your bot is not yet published, and that’s what we’re here to take care of, so click on the link labelled “publish”, and let’s continue. The next page will let you know that your bot is now published, and will give you a URL that you can use to access it. Write it down (type it somewhere, copy and paste, whatever) for later use. From here, you’ll also see options for adding a Flash interface, an Oddcast vHost avatar, or customizing your chatbot’s page. You can also view conversation logs, and see some basic statistics for your bot here. Please note that any time you make changes to your bot, no matter what type of changes, and no matter how large or small, they won’t show up for the public unless you re-publish your bot. Usually, the PB page will let you know about this, so publishing the changes isn’t hard to do.

7.) That’s all, Folks!

If you’re still with me, then you now have the “bare-bones” basics needed for creating a chatbot on Pandorabots. To be sure, there are a LOT more steps and options available for you to take, but from this point on, what happens to your new chatbot is entirely up to you. If you run into any trouble, or need to ask a question about anything related to your new chatbot, take a look at the list of resources below for links to various websites that can prove useful to you.

Summary, Recap, and Resources

Talking to a chatbot can be a lot of fun, and if you have the desire, dedication and skills (or are willing to learn the skills needed), creating and maintaining your own chatbot can be even more so. Whether you choose a fully stand-alone “virtual companion”, like AI Bliss, or take on the challenge of creating your own stand-alone bot through ChatScript, or even create your own web-based bot through Pandorabots, you could find your days filled with hours of rewarding (if sometimes frustrating) work (or play, depending on your outlook). Whatever road you take, it can be a rather enjoyable journey.

And, of course, if you ever find yourself in need of assistance with your chatbot, there is a huge community of other folks who are willing to help. many have had the same or similar experiences, and are only too happy to pass on what they’ve learned. the list below is only a small sampling of places that you can visit, to ask questions, get (or give) answers, or just to discuss chatbots in general, or your chatbot, specifically:

  • chatbots.org - Artificial Intelligence and chatbot help and discussion.
  • AI Dreams Forums - More chatbot discussion and help – also many other subjects of interest.
  • AI Nexus Forums - AIML and Pandorabots support – highly dedicated members, and very useful information
  • Pandorabots Q&A Forums - specifically for Pandorabots, this is a “first look” site for answers.
  • Program O Forum - just in case you choose to do things “the hard way. smile

Ii think that pretty much covers the basics. as I stated before, feel free to do your own research here, and don’t forget to use the resources above to ask question and find information. building your own chatbot can be a truly rewarding, fun experience, and I wish you all the best.

Dave Morton
Geek Cave Creations
http://www.geekcavecreations.com
contact me


OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am
Nvidia Hype
by 8pla.net (AI News )
December 06, 2023, 10:04:52 pm
How will the OpenAI CEO being Fired affect ChatGPT?
by 8pla.net (AI News )
December 06, 2023, 09:54:25 pm
Independent AI sovereignties
by WriterOfMinds (AI News )
November 08, 2023, 04:51:21 am
LLaMA2 Meta's chatbot released
by 8pla.net (AI News )
October 18, 2023, 11:41:21 pm

Users Online

272 Guests, 0 Users

Most Online Today: 343. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles