Hi and thanks for the visit. If you're new here you may want to subscribe to my feed.
Roll your own C# Jabber chatbot
using agsXMPP and AIMLBot.
Here is a very quick and dirty tutorial about how to use these libraries to build a Jabber chatbot in C#. Since Google Talk came out, Jabber and the XMPP protocol have received more attention and are being used more and more. Who doesn’t have a gmail account?
WARNING/PREREQUISITES: You should be experienced with C# and using agsXMPP/AIML
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?
You must log in to post a comment.