Monday, 21 November 2011

Making your chatter Bot using Jabber/XMPP

What is Jabber/XMPP?

Jabber is a non-for-profit organization who overlook the development of XMPP.

XMPP : Extensible Messaging and Presence Protocol (XMPP), an open XML based communications technology, widely used for IM, chatting.

There are many many implementation of XMPP as a server, and many many Jabber clients also. Gtalk/MSN/AOL/mac does support XMPP, so using any Jabber client you can communicate with above all account holding buddies.

Q. Where to get a Jabber client?
A. Here you can find the list :

Q. Where to get XMPP server?
A. I used Openfire for it that you can download it from here :

Step for Making your chatter Bot

Step1: Download and Making you server up
Download XMPP server and install it on a machine. If you are Window/Mac user then you can directly download exe/dmg file and install.

But if you are installing it on Linux, then most simplest way is to download the tar file, extract it and run the openfire
executable file from bin folder, like "$ ./openfire start". Make sure before you start openfire you have Java set on your system.
In the script of openfire, just set some environment variable to access the Java like this.
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JRE_HOME=/usr/lib/jvm/java-6-openjdk/jre

And while logging it might ask for access on certain directory or files, so instead giving access to them just edit the log4j.xml files(which you might find in lib directory), and change the log file, either you can hardcode them or just change the directory where you already have the access.

In case of Windows and Mac you can start your Openfire from program files or Applications.

Step 2: Install
Once you started Openfire, you can hit this url in browser http://localhost:9090/ and configure it. Its very simple, let me know if you face any problem in that. For this step you will need a DB also, you might use Mysql or anything like that.

Step3: Writing a Client
Write a client, using smack API, before that download the smack API from Openfilre download link(above), or precisely this will do,

Smack here very good tutorials on "how to start" and all, so using that write Java based application which can act as a bot, Lets call it "".

Step4: Certification
SSL Certification: If you want to send friend request to gtalk/msn or any other Jabber clients most likely they ask for a SSL certification because they prefer to communicate securely. If you are deploying this for a local purpose(intranet) possibly you can create a self signed certificate and deploy that in Openfire. Or else create a CSR, give it to CA and get a cert file and deploy that in Openfire.
How to generate keyfile, CSR and all, you can take help from this URL :

so kool everything is ready. One simple illustration of How it will work? Like If you want to send a friend request to a, that can be done using a Client "xyz", once "aramis" confirms the friend request, "xyz" can send any chatting message to aramis and aramis send back any message to xyz, the client program of xyz will receive that in the Chatlistener.

So whoever is online at their chatting client, you are reachable to them...kool