Creating a chat bot with php, xmpphp, openfire, kraken and cleverbot with support for icq, aim, yahoo, msn, hotmail, facebook chat and more

A long time ago I used to run a site called icqbot.net where I distributed a free perl script that would connect to ICQ and have conversations with them.. it utilized the elizatalk AI engine as it’s brain and then later a different system called MegaHAL.. it wasn’t until AOL came after me for violating their trademark in my domain name ( they own ICQ ).. so the party was over.

Today I happened upon a site called Clever Omegle ( http://www.iywib.com/cleverbot_omegle.php ) and LOVED it.. It basically takes the random chat of omegle and marries it with the AI of cleverbot.com to create something really entertaining.

I decided I could utilize this to bring my old bot back to life! but I really didn’t want to reverse engineer protocols again and there wasn’t any great libraries out there to write the connection part. This is when I discovered the OpenFire XMPP server ( http://www.igniterealtime.org/projects/openfire/ ) by “Ignite” .. there is a linux and windows version..

Openfire would be my connection point from PHP to the other networks.. to do that I would need to install the latest beta Openfire plugin called Kraken ( http://sourceforge.net/projects/kraken-gateway/files/kraken-gateway/ ) which allows connection to ICQ, AIM, Yahoo and many other popular networks.. all you have to do is register your accounts and link them to your account on your Openfire server.

Once that was complete, I found a PHP class that allowed connection to cleverbot, all you do is pass a message and get a response.. I would link to that but Cleverbot’s folks are very quick to slap the hands of people who do this sort of thing and I’m doing it merely to see if I could! ( and it’s fun ) .. so you’ll have to scour the net to find methods to communicate with cleverbot via PHP.

Once I had that interaction working.. I downloaded the xmpphp library ( http://code.google.com/p/xmpphp/ ) and used the author’s example as the base for my bot.. the only thing I had to do with adjust the connection string to point to my server with my credentials and then inject code to load up the cleverbot class I found.. when an incoming message was detected, I pass that to the cleverbot object and pass back the response.

This has MANY advantages over my old bot.. it can connect with virtually any network.. it has a much stronger AI powering it.. and the Openfire server has a monitoring plugin that collects chat logs FOR me .. so I don’t have to code any of that junk.

The code writing to accomplish this was minimal .. the author’s example xmpp code was just under a hundred lines and I only had to write 5 lines of code in myself to tie the pieces together.

If you want a more detailed process, shoot me a message via my contact form and I’ll be happy to assist… if you know of any public xmpp servers out there with support for multiple protocols then you’re already 90% there 😉

Related search terms:

8 Responses to Creating a chat bot with php, xmpphp, openfire, kraken and cleverbot with support for icq, aim, yahoo, msn, hotmail, facebook chat and more

  1. Mrox2 says:

    Interesting , thanks for this article, i myself trying to link my Carla Radames msn to clever bot but im new to this coding stuff although your topic is much of a help, but i dunno where to start, But thanks again !
    -Mrox2

  2. Mike says:

    already considered this? http://belski.net/archives/37-Phurple-for-PHP-5.3-and-up.html

    phurple is the php ext binding to libpurple, so even more protocols can be done

  3. gokulkrishh says:

    how i can i implement a facebook chatbot

    • lonnie says:

      It’s possible but difficult… Facebook useses A LOT of javascript to render their pages, and they use random class names .. so it’s very difficult to code for facebook unless you use Javascript.

      With that said.. I have had some luck using http://m.facebook.com :) the mobile version… perhaps that’s a good hint

  4. Bikram Thapa says:

    Hi, there I am trying to build IMessenger with Openfire and php, may be node js as well in future. Could you help?

  5. Nilesh Badgi says:

    Hello Lonnie,

    I am looking for openfire with php based web application developments. So let us know what code you have done, or how can we go with that, It will be very help full for us.

    Thanks
    Nilesh

Leave a Reply to Bikram Thapa Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">