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 alice@35.cn,you can add alice@35.cn to your contact list and chat with her anytime:

image

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:

image

Initialize AIMLBot :

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

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 = MessageType.chat;
replyMsg.To = msg.From;
replyMsg.Body = reply.Output; 

XmppCon.Send(replyMsg); 

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

Related posts:

TAGS: , , , ,


10 Comments »

repoze.who: perform login programmatically | Joiner.ro - Indexare gratuita feed-uri RSS On July 9th, 2010 at 1:03 am (#)

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

مسلسلات On August 18th, 2009 at 6:28 pm (#)

thanxs post :)

sohbet On October 13th, 2008 at 4:26 am (#)

thank you very much good works

porno izle On October 1st, 2008 at 4:08 am (#)

gooddd

rond On September 22nd, 2008 at 10:06 pm (#)

thank you!!

soolad On September 17th, 2008 at 4:20 am (#)

thank you!

Christina On September 12th, 2008 at 11:42 am (#)

I like to talk with Alice.(*^__^*)

peter On September 4th, 2008 at 2:17 pm (#)

thanks for your great tour!that’s exactly what i’m looking for

Dean Lee On September 2nd, 2008 at 4:04 pm (#)

you can add alice@35.cn as a contact from your jabber client.

RAXYNEWTY999CHOOCHOO On September 1st, 2008 at 10:17 pm (#)

how do u add her?????????


Leave a comment


(will not be published)