Artificial Intelligence Service based on ProgramAB and AliceBot

AIML is known as Artificial Intellegence Markup Language.  It was created by Dr. Richard Wallace to power the ALICE bot.  AIML is a recursive language that allows breaking down natural language text input to match a repsonse that the chat bot can send.

Here is a simplistic AIML example: 

<?xml version="1.0" encoding="ISO-8859-1"?>
<aiml version="1.0.1" xmlns=""
    <pattern>HELLO WORLD</pattern>
    <template>Hello to you too!</template>
    <pattern>HELLO *</pattern>
    <template>Hello to you too <star index="1"/> !</template>



#file : service/ edit raw
# more info @:

# create a ProgramAB service and start a session
alice = Runtime.start("alice", "ProgramAB")

print alice.getResponse("How are you?")

# create a Speech service
mouth = Runtime.start("mouth", "MarySpeech")
# create a route which sends published Responses to the
# mouth.speak(String) method

alice.getResponse(u"What is new?")
alice.getResponse(u"Tell me a joke?")
alice.getResponse(u"What time is it?")
# UTF8 test

Mastablasta's picture

ProgramD AIML

Some days ago I´ve started with ProgramD and AIML.

The installation was a little tricky (for a noob like me) but got it working after some hours. There are lot of aiml databases you can download (ALICE, Charlie etc.) so you can start pretty fast talking to your bot. In my opinion most of these aiml-files are too simple as AIML offers many more tags to use. After 2 days of reading and checking more than a 100 websites it´s still difficult to find good tutorials.

So far I ended up in using GaitoBot AIML Editor which seems to be a good helper to start with (it´s free). Here you can create and even test your files immediately. You  will be able to do simple files within a short time.

I have mentioned "too simple" before. My goal: a database for first names with the bot recognizing fake names e.g.:

Master: "My name is washing machine"

Bot: "Don´t fool me! Washing machine is not a name for a human"

So I started to use the condition tag and set name and value. For real names I get the correct response e.g. Mike, nice to meet you! or using the li tag for random answers.

Now I am stuck at the point where it comes to the fake names. I´ve created a condition tag for every real name, pointing to the correct answer, working fine. I was hoping to be able to make another condition tag for all inputs which does not match the prior condition tags (the real names). To say it more simple:

if input = real name then say hello name

if input = fake name then always say get lost

Thanks for any suggestions!

SOLVED! After 24 hours of brainstorming I got things moving! I´ll keep you up to date soon.

Update 10.08.2014 4:37PM BRT:

The condition-tag would need a whole database of existing names. I tried and it works. But no one wants to add thousands of names. Here is the future name-id plan:


Mastablasta's picture

AIML 2.0

Today I tried AIML 2.0 with program AB (version Very easy to install and to run. It already contains a bunch of aiml.files and you will see at the cmd where it takes the info from.

Here we can create databases and the prior goal is reached.

It also retrieves a lot of info from different websites (Wiki, WolframAlpha, Jeannie bot, etc.), grabs audio/video from Youtube or shows a city on the map. It calculates, it translates (I could only get  english/spanish to work). Also all my AIML 1.0.1 files run normally with programAB, just load them into the AIML 2.0 bot. As I like swearing I have deleted the profanity.aiml and the inappropiate.aiml at the aiml-folder and aimlif-folder and added my own badwords.aiml.

Some examples:

Human: What is the weather in Berlin

Robot: It is currently clear.  57F

Human: convert 57f

Robot: 13.889 C

Human: 300+200/25

Robot: 308

Human: my dad is edgar

Robot: I will remember your father's name is edgar.
Isn't edgar usually a male name?

And this happened after the "my dad is edgar" input:

STATE=my dad is edgar:THAT=X is your wife:TOPIC=berlin
input: my dad is edgar, that: Xis your wife, topic: berlin, chatSessio
n: org.alicebot.ab.Chat@a70ad76, srCnt: 0
Matched: MY DAD * <THAT> * <TOPIC> * reductions2.aiml
0. <srai>MY FATHER is edgar</srai> from MY DAD * <THAT> * <TOPIC> * topic=berlin
>NAME</SET> <THAT> * <TOPIC> * topic=berlin)
Set predicate familiarpredicate to father in MY <SET>FAMILIARNAME</SET> IS <SET>
Set predicate contactname to edgar in MY <SET>FAMILIARNAME</SET> IS <SET>NAME</S
ET> <THAT> * <TOPIC> *
E</SET> <THAT> * <TOPIC> * topic=berlin)
Matched: REMEMBERFAMILIARNAME <THAT> * <TOPIC> * familiar.aiml
Set predicate familiarpredicate to father in REMEMBERFAMILIARNAME <THAT> * <TOPI
C> *
Matched: GENDERCOMMENT <THAT> * <TOPIC> * familiar.aiml
4. <srai>GENDERNAME edgar</srai> from GENDERCOMMENT <THAT> * <TOPIC> * topic=ber
Matched: GENDERNAME <SET>NAME</SET> <THAT> * <TOPIC> * sraix.aiml
Set var gendername to M in GENDERCOMMENT <THAT> * <TOPIC> *
Set var genderpred to F in GENDERCOMMENT <THAT> * <TOPIC> *
Set predicate father to edgar in REMEMBERFAMILIARNAME <THAT> * <TOPIC> *
Learn Pattern = WHO IS edgar
Learn Pattern = WHO IS EDGAR
Learn That = *
Learn Template = edgar is your father.
Learn Pattern = edgar
Learn Pattern = EDGAR
Learn That = *
Learn Template = Your father.
writeCertainIFCaegories learnf.aiml size= 0

He learns fast and easy. Nice to play with. I will do lots of reading this week and always keep you up to date.

Mastablasta's picture

Program AB, AIML 2.0 and CallMom

As program AB is a typical aiml interpreter and features like "google blablabla", play "highway to hell" or "map Los Angeles" are not performed, I have tested the CallMom app on my S3 with Android. Default setting is Mitsuku but you can change to other bots incl. Alice 2.0. Looks like to be the same Alice running as on program AB. Just did it for a test as I usually use my cellphone only to recharge its battery.

Compared to aiml 1.0 or 1.0.1 (both files still run on aiml 2.0!) the included aiml.files and databases are really big. Together with the features mentioned in my previous post it appears like a "small intelligence". 

Adding new aiml.files got much more easy as there is no need to change the bot.config for every singe file. Just drop the new file into the aiml-folder you are using. That´s it.

Editing the sample files is possible as it was on previous aiml-versions. But there are a lot more tags available now, link:

The GaitoBot Editor is also working fine for aiml 2.0.

You can change the properties (thanks to kwatters!) and re-name the bot (properties.txt) and set your personal info at the predicates.txt as well. Whenever I start the program he knows I am the botmaster and he knows my name.

I´m trying to figure out how the learnf-tag works as he learns in the current session but after restart these learned things are gone and the learnf.aiml is empty. It is supposed to write these new info right into that file. Could be that the learnf is not configured correct. This is the next step for me.

If we could get this to work with MRL and InMoov......holy shi*! You will have a realy smart machine ;-)

.....Human: weather in rio....Robot: It is currently sunny, 81 Fahrenheit


Mastablasta's picture

Discovering Program AB and AIML 2.0

Lack of programming expierence and english language forces me to ask some questions.

I found this info from Richard Wallace:

Program AB will output the <oob> tags but by itself, AB doesn’t do anything with them.  Shortly we’ll be releasing an app that links AB.jar as a library.  This app post-processes the AB outputs and takes device actions based on OOB tags.

AB does have <sraix> to connect to web services though.  It also has the <system> tag to call another program.

Do I understand this correct that ProgramAB will be able to e.g. start a web browser or launch another program? I found that AB.jar but I´m still confused.

learnf.aiml is still empty, doesn´t save anything but shows "write"..... I´m still fighting.

Translate to almost any language works. Just type translate german car and you get Auto or translate french i like you my friend = J'ai comme toi mon ami.


Mastablasta's picture

How to make your bot learn

Using programAB and the ALICE aiml files 2.0 makes a bot learn easy:

Human: my table is red

Robot: OK, now you can ask me "What is my table?"

Human: ice is cold

Robot: Now you can ask me: "What is cold"? and "What does ice be"?

Before you end a session with your bot you need to use wq (write and quit) and hit enter. Now you go to the aimlif folder and you will see a new aiml.file called null.aiml, Open it with notepad and you will see all the things you told the bot before. Rename the file to e.g. null1.aiml and start the bot again. Add new info to him, use wq + enter and look at the aimlif-folder again, the next null.aiml is ready! I suggest to rename every null.aiml folder after each session. E.g. you teach him things about your house name it house.aiml.

I did some tests without renaming the null.aiml. In some cases he kept the old info for 3 new sessions but after a 4th session the null.aiml only contains the trained info of session 4, training of session 1-3 was gone.In other cases the trained info was already gone after the 2nd session.

Mastablasta's picture

How to make your bot learn Part 2

Another way for the bot to learn or you to teach the bot is using the "Category Browser - Pattern Suggestor".

You should have a file named 1000.txt at the data folder. Rename this file to sample.random.txt (this is a sample file with only 1000 inputs). Run programAB and type ab and you are at the pattern suggestor.

Now you are able to make new aiml categories without using an aiml-editor or the notepad. It sure depends what the sample.random.txt file contains. Take a closer look and you will see that all these inputs are simple questions or phrases. Time to add as many as possible!

To be able to follow the progress of using ab I did a new and empty bot with the typical folders named aiml, aimlif, config, sets, maps. Start programAB, type ab, go thru some categories, add whatever you want (for testing) and type wq. Now check your aiml and aimlif folder. :-))))

Here is a nice tuto:

Mastablasta's picture

Update learning

He doesn´t take some inputs. The name of my bot is Elias. If I type e.g. Elias is my boy he doesn´t take it as a learned input. In cases like this you just type learn Elias is my boy.

Mastablasta's picture

InMoov + MyRobotLab + programAB

Since today programAB is fully integrated in my script. Awesome!

Now I need to fill him up with words. For this I did a small GUI (first time I did a Java GUI).

All I need is words/phrases for the "ear.startListening" and of course a def. I use 2 outputs, one for a single def and the 2nd output for multi-def.

Maybe Ma.Vo. could integrate something similar the the gesturecreator.

MaVo's picture

You are learning Java now,

You are learning Java now, you could add it yourself!

Nice work, Masta.

Tell me what you want exactly, maybe I can free up some time for it.

Mastablasta's picture

1st test with programAB

kwatters's picture

HtmlFilter service

I added a HtmlFilter service that can strip html from the program ab reponses.  (it can also add html but that's not the default use case)

Here's an example of using it from python 

alice = Runtime.createAndStart("alice", "ProgramAB")
htmlfilter =  Runtime.createAndStart("htmlfilter", "HtmlFilter") 
# create a Speech service
mouth = Runtime.createAndStart("mouth", "Speech")


Mastablasta's picture

2nd test

AdolphSmith's picture

You have done it Wow !!!. I

You have done it Wow !!!. I really like this 10 out of 10 Masta great

Mastablasta's picture


Thanks MaVo. One days work though and updated, looks a bit better now.

If someone wants the GUI, please tell me. Really a fast help for using programAB.

Let me know your bots name and I change the GUI for that name.

BillC's picture

Very nice.

Can you send me a copy of this so I can use it? My robot name is Robbie


Bill C

Gareth's picture

Other names......

This is really great...tested and working....

Greg pointed me to this resource :-

you can select a new bot voice and insert it instead of Ryan

from the MRL code example......


moz4r's picture

UTF8 Write support

Hi is it possible to change the "write AIML method" to support UTF8 encoding ?

moz4r's picture

I found a workaround, not

I found a workaround, not clean but seem ok  :

import io
import glob, os
oridir=os.getcwd().replace("\\", "/")
for file in glob.glob("*.aiml"):
    with'/'+file,'r',encoding='iso-8859-1') as f:
        text =

    with'/'+file,'wb') as f:
            print file+' converted'

pinchis123's picture

help whit programAB

excuse me want to make imoov Talk or can have a conversation with someone
but when we run a code error appears programAB and python , 
not if we can help or assist with the code thanks
kwatters's picture

What's the error? Send a "no worky"

We've love to help, what's happening?  Can you reproduce the issue and send a "no worky"  so we can see the log file.

I suspect it's just an issue with the script

kwatters's picture

Google speech is no longer supported

It seems like you're using version 1.0.119  ... that's a very old build.  I would recommend using build 1412  (available from the link in the shoutbox.)

That being said, the "Speech" service used google's speech API and that no longer works.  I recommend using "AcapelaSpeech"

Try changing your script to say the following:

mouth = Runtime.createAndStart("mouth", "AcapelaSpeech")


Hope that helps! 


pinchis123's picture


one question if I use this code as
I do to make you connect to arduino to inmoov
can move your mouth every time you answer 
another question as I can change the good language 
if I want to speak Spanish is a link or an instruction
 I hope I can help thanks
pinchis123's picture


one question if I use this code as
I do to make you connect to arduino to inmoov
can move your mouth every time you answer 
another question as I can change the good language 
if I want to speak Spanish is a link or an instruction
 I hope I can help thanks
pinchis123's picture


The probe code Disculpen coming on this page ,
so I was wondering if you can change the language for example
 in Spanish hope your help thank you very much