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:
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(); 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:
[...] How to create a jabber chat bot based on AIML,the C# way. [...]
thanxs post :)
thank you very much good works
gooddd
thank you!!
thank you!
I like to talk with Alice.(*^__^*)
thanks for your great tour!that’s exactly what i’m looking for
you can add alice@35.cn as a contact from your jabber client.
how do u add her?????????