AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

PHP AIML Chatbot


I’m trying to build a Chatbot using PHP and AIML for a University project.

I’ve got my head around the basics of AIML and I’ve created a short AIML brain for my Chatbot, however; I can’t find anything online or in the library that explains how you interpret AIML in PHP.

Can anyone point me in the right direction to get started with the basics? I know that Program E/O etc. exist but they are far more complex than I need at this stage.

Any suggestions would be appreciated!



  [ # 1 ]

Hi, Scott! Welcome to! smile

To the best of my knowledge, those two are pretty much it, unless someone has developed another AIML chatbot engine in PHP and just hasn’t made it public. Having worked with both Program E and Program O in the past ( and in the case of Program O, in the present and future, too, since I’m the lead developer for the project wink ), I can tell you from experience that you’re not going to easily find something “less complex”. You could, perhaps, make something that would suit your needs, but that’s a lot more complex than using an already existing script. Of the two chatbot platforms mentioned, Program E is probably the most “botmaster friendly”, but it’s functionality is limited; or at least it was when I was working with it a few years ago. At that point it was “orphaned code”, but recently it’s been “revived”, and is now being actively developed once again on GitHub, so perhaps it’s improved since the last time I looked at it.

Now, with all that said, can you list exactly what criteria you’re looking for, in terms of simplicity and functionality? Perhaps I can give some useful advice and/or information, if I know a few more details. smile


  [ # 2 ]

Thanks - It’s good to be here, haha! cool smile

Thanks for the brief summary about existing PHP AIML chatbot engines. I didn’t know that you were currently the lead developer for Program O, that’s pretty cool.

I’m essentially trying to create a chatbot for online help, similar to O2s Ask Lucy, for my final year project at University. I’ve got good CSS, HTML, JQuery and PHP skills and I’ve got a basic understanding of AIML.

I don’t want to simply copy the AIML chatbot engine from Program E or Program O as it would drastically reduce my overall mark by using an external library as all I’d essentially need to do would be to create an AIML file and create a different front end (I think).

What I’m looking to do is create a basic PHP AIML interpreter / chatbot engine to enable a simple ‘proof of concept’ chatbot that can read different AIML datasets dynamically and respond to the end user in an almost identical way to O2s Ask Lucy. My dataset will be a local FAQ and I’m hoping to create different interfaces for desktop, mobile and tablet.

I don’t suppose you remember how the original Program E or Program O chatbot engine as created? i.e. what was used as a reference point.

Any advice / information you could provide would be excellent David.

Thanks in advance!


  [ # 3 ]

Well, since I’m actively developing Program O, and since it’s Open Source (and I’m not giving away “trade secrets”), I’d like to suggest downloading the latest “Beta test” version at and taking a look at how the script parses the AIML into response text. This newer version parses the AIML categories as XML, which is a lot simpler than using string replacement functions and if/else blocks. The file you really would need to look at is parse_aiml_as_xml.php, which is in the chatbot/core/aiml folder. In it, you’ll find all of the functions for parsing the XML into text. It may prove to be a useful “starting point” for you. smile


  [ # 4 ]

Thanks David, I’ll take a look at the Beta version. Parsing as XML definitely seems a lot simpler than the way Program E does it.

When the AIML file has been parsed successfully, how do you actually initialise the interpretation? What file contains the ‘brain’ as such within Program O? (Appears to be a lot of files, haha).

I’ll see what I can come up with over the weekend and hopefully you can provide some helpful nudges if I get stuck.

Thanks tongue wink


  [ # 5 ]

The “brain” in Program O actually resides in a database. All of the different AIML files are stored in a DB table, and accessed by searching that table for any categories that may potentially match the user’s input. This method is very useful when you have more than one AIML file for your chatbot, but may be overly complex in execution if your chatbot has only one AIML file, and only a few hundred AIML categories. Given that you stated a preference for simplicity, and also given the brief description that you gave of your needs, there may be a simpler method for determining which output is parsed, but I’d need a pretty exact description of the requirements for your project before I could advise you about that.


  [ # 6 ]

Writing a new chatbot interpreter

may easily exceed the alotted time
of a course project, I believe.

This example site is for educational
purposes, which may not be directly
used in any college project work.


  login or register to react