How to create a jabber chat bot based on AIML,the C# way.

I have created a jabber chat bot based on on the A.L.I.C.E(Artificial Linguistic Internet Computer Entity) and AIML(Artificial Intelligence Markup Language).which is named,you can add to your contact list and chat with her anytime:


It’s really simple to build your own alice chat bot by using agsXMPP and AIMLBot.The following sections is my quick and dirty tour on how to do it(You should know how to use agsXMPP and AIMLBot first):

After downloading and compiling the agsXMPP and AIMLBot,add them as References to your bot project:


Initialize AIMLBot :

AIMLbot.Bot myBot = new AIMLbot.Bot();

Response chat message in XmppClientConnection’s OnMessage Event:

AIMLbot.Request request = new Request(msg.Body, GetUser(msg.From.Bare), myBot);
AIMLbot.Result reply = myBot.Chat(request);
agsXMPP.protocol.client.Message replyMsg = new agsXMPP.protocol.client.Message();
replyMsg.Type =;
replyMsg.To = msg.From;
replyMsg.Body = reply.Output; 


a simple implementation of GetUser:

protected AIMLbot.User GetUser(String jid)
   Hashtable myHash = Hashtable.Synchronized(userSessions);
   AIMLbot.User user = (AIMLbot.User)myHash[jid];
   if (user == null)
       user = new AIMLbot.User(jid, myBot);
       myHash[jid] = user;
   return user;

that’s all,it’s really easy and simple,huh?

PS:you can download free AIML sets from here

10 thoughts on “How to create a jabber chat bot based on AIML,the C# way.”

Leave a Reply

Your email address will not be published.