This quick tutorial will show you how to develop your own functional IM bot that works with Google Talk, Yahoo! Messenger, Windows Live and all other popular instant messaging clients.
To get started, all you need to know are some very basic programming skills (any language would do) and web space to host your “bot”.
For this example, I have created a dummy bot called “labnol” that listens to your IM messages and return related search phrases based on Google Suggest. To see this live, add labnol@bot.im to your GTalk buddy list and start chatting.

If you like to write a personal IM bot, just follow these simple steps:
Step 1: Go to imified.com and request an invite. You should also give your bot a decent name because you can have just one bot per email address.
Step 2. An email with a secret key should arrive in your Inbox the next minute. Copy that key to the clipboard and go here to redeem that key.
Step 3. Now it’s time to create a bot which is actually a simple script that resides on your public web server. It could be in PHP, Perl, Python or any other language. More here.
This is the source of the PHP script I wrote for the labnol IM bot – pretty self explanatory – it reads your message, gets the relevant data from Google Suggest and echoes it back to the IM window.
<?php // Get all the related keywords from Google Suggest $u = "http://google.com/complete/search?output=toolbar"; $u = $u . "&q=" . $_REQUEST['msg']; // Using the curl library since dreamhost doesn't allow fopen $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $u); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $xml = simplexml_load_string(curl_exec($ch)); curl_close($ch); // Parse the keywords and echo them out to the IM window $result = $xml->xpath('//@data'); while (list($key, $value) = each($result)) { echo $value ."<br>"; } ?>
Step 4: Once your script is ready, put it somewhere on your web server and copy the full URI to the clipboard.
Now login to your imified account, paste the script URL and add that im bot your friends list. That’s it.
This was a very basic bot but the possibilities are endless.
For instance, you could write a bot that will send an email to all your close friends via a simple IM message. Or you could write one that will does currency conversion. See stuff that is already implemented in this list of most useful Google Talk bots.
Find this article at: http://www.labnol.org/internet/tutorial-create-bot-for-gtalk-yahoo-messenger/4354/
Tags: feature, google talk, im, php, programming, tutorial, yahoo messenger, Internet

Reader Comments
wow that seems to be a excellent post because now you can program your own bots! Wooh the technology is growing huge guys!
Written by Amit Bhawani on 09.01.08
that’s great,Excellent tutorial, I think I will try to write a bot,thanks
Written by 禾草唐楷 on 09.01.08
amit, this has got to be one of the most clearest and useful imified bot scripts i’ve seen yet. nice job!
Written by booyaa on 09.01.08
Well…I need to sharp my programming skills to write my own bots.
Written by Chris Martin on 09.01.08
I need to know if there is any AIML implementation present in PHP. So that we can create Artifically Intelligent bots that can talk with us.
Written by Gautam on 09.01.08
Yea that’s cool, but you can do more complicated things with that structure fyi ;)
Written by Television Spy on 09.01.08
A very interesting, and very cool development I must say. I could see this being useful for web hosting companies and ISPs where commonly asked questions and requests for information can be answered with a chat bot
Written by Adam on 09.01.08
Jesus christ this gave me a heart attack. I got linked here from Digg ( link ) and when I saw the name Amit in the .png file I thought it had somehow already managed to decipher my own name!!
Stick a fork in me, I’m done!
Greetings from Sydney, Australia :)
Written by Amit Singh on 09.01.08
Very neat work, I’ve tried adding a bot, but it doesnt show online. Do we need to do something to make that happen?
Written by Abhimanyu Grover on 09.02.08
nice article. Maybe I’ll make the bot soon. I think I can get many things in this blog. thanks
Written by enggar on 09.02.08
you have all noticed that imified.com plan to make the developers pay for this when it comes out of beta ?
but do not worry “You’ll have plenty of upgrade options when our Beta period ends”
Written by memals on 09.02.08
I was able to use fopen on dreamhost using a custom php.ini, they have instructions in their wiki on creating one.
Written by Tzafrir on 09.02.08
Is it possible to make a bot which pushes messages to its subscribers ?
As far as i can see the bot can only reply on questions.
If it is posible i would like to use it on my new site link
Written by Knud on 09.02.08
I’m kinda lost here. after pasting the script url, how will I add the bot on my friendlist? and where is that? Am I going to add the link on my gmail chat, yahoo msgr? is that it?
Written by jsonv on 09.02.08
Great tutorial! Having the same problem as Abhimanyu invited the bot however it has not accepted my request! I knew I should not of called it Hal 9000…
“This mission is too important for me to allow you to jeopardize it”
Written by Sean on 09.02.08
I have the same problem, my bot is offline, i don’t know how to activate it.
Written by Mauro De Giorgi on 09.02.08
Thanks. This was really helpful. Now I can make a bot that gives information of all my company products.
Thanks a lot !
Written by Jash Sayani on 09.02.08
Actually, this post is about how to link a custom PHP script to IMified. It is not about writing “your own IM Bot”.
Written by Peter on 09.02.08
Amit..this is great. But i dont know why my bot isn’t alive as i add my bot just now? How long do i have to wait?
Written by Muhaimin on 09.02.08
me having the same problem :( bot is invisible. Anyone know what to do?
Written by george on 09.02.08
Cool! The script is very straight forward too, good job!
Written by Tabris Chen on 09.02.08
I feel like whole imified.com bot network is down. I can’t even access regular imified bot.
Amit, congrats for reaching on delicious and digg’s homepage ;)
Written by Abhimanyu Grover on 09.02.08
I have the same problem, my bot appears offline.
I tried link but it is also offline :(
imified.com has big troubles !!!
Written by Abdullah on 09.02.08
I dont think the bot will work until the Digg Rush is over =)
Written by Adam on 09.02.08
The IMified bot has been down since a couple of months now. I just created this bot, and well quite obviously, it’s offline.
Written by Santosh on 09.02.08
We’re currently experiencing some difficulty bringing your new bot online due to an appearance on the Digg home page resulting in an unexpected high load.
Please bare with us while we get things back online. You can check our blog link for the latest status.
Written by Santosh on 09.02.08
Great post. Thanks for sharing this tip. Tinh
Written by Tinh on 09.04.08
Lol. as if I’d give my IM login data to imified. Next thing you know: They sell it… or “lose” it… Haha.
Besides: I have my own IM libs in Java on my server.
Written by BAReFOOt on 09.04.08
Seriously, if you’re smart enough to write PHP, Perl, or whatever, you should be smart enough to write a bot to connect to Jabber or any other protocols.
The primary benefit here is that they host the bot process for you so you don’t need a VPS or the like.
The negative is obviously that this is event based and can’t actually initiate a conversation or push content.
Barefoot: put the tin foil hat away and just create a new SN that you’d use for the bot…
Written by Andrew on 09.04.08
Andrew: You can push content using IMified. See the developer docs at link for details on our APIs.
Barefoot: you don’t need to give us any login info. We create a Jabber account for each bot on our servers and your bot runs as link .
Written by Adam Kalsey on 09.08.08
Wow this is what Ive always wanted, just didn’t know how to setup one. Thx
Written by MR on 09.11.08
Thanks for creating this tutorial, it’s been very informative. I’ve kind of started to play with it and mash it up but I was wondering why the “output=toolbar” parameter? Thanks in advance!
Written by Nano Taboada on 09.14.08
We followed this and with a little twist we were able to create a bot to use in our company intranet.
Thanks!
Written by Cybernotch on 09.15.08
Thanks, I always wondered how to create my own bot. I’ve been slightly envious of one of my friends who created a fairly complex one over the last 15 years, and I doubt I’ll stay motivated enough to make anything even comparable to his, but at least I can have a fun little bot to tool around with now.
Written by Dan on 09.16.08
Insted of simplexml you can use PHP version of jQuery and simply do AJAX request.
It’s called phpQuery and can be found here:
link
Written by Tobiasz Cudnik on 09.27.08
Hi
I created a bot on imified. But the bot is offline. Trying to add it as a gtalk buddy does not seem to have any effect. Can anybody help?
Written by vinayak on 01.13.09
the form has changed a bit from what you are showing in the blog post.
how long does it take for a new bot to come online ?
Written by shivani on 02.03.09