The Storyteller

develop your own gtalk/jabber/aim/yahoo bot using imified API

December 28, 2008 · 35 Comments

i’ve found http://bot.im (imified) few days ago and it’s a nice free service for creating your own messenger bots. it provides excellent API to develop bots for various platform like AIM/Yahoo/Gtalk/Jabber and interact with your bot users. To ease developing bots, I have written a wrapper class of imified API for php developers and made it open source under BSD license. You can download the wrapper from below

Download the wrapper with example

To see the example bots developed using this wrapper, please add “storyteller@bot.im” in your gtalk/jabber client or “storytellerbot” in your YM client. then type help and TADA!

please note that processing “help” is different. you need to type the response of “help” command in your bot settings page. also bots allows only one HTML tag which is <br>

example [the callback of this bot is set to http://bot.ofhas.in]

include_once("class.imified.php");
if(!isset($_REQUEST['msg']))
{
die ("This is Hasin's personal bot storyteller@bot.im to demonstrate the imified API - please add this bot from your gtalk/jabber client Or add storytellerbot@yahoo.com in your YM client. Source code is available from hasin's personal blog at http://hasin.wordpress.com");
}
//initiate
$im = new ImifiedHelper("7DCDECB6-C895-9643-909CDC85CBF09954 ","username@example.com","Oye!MyPassword!");
//callback
$im->setCallback("callback");
function callback($message, $step, $network, $userKey)
{
global $im;
$message = strtolower($message);
if("whois"==$message)
{
echo "about me";
}
else if("work"==$message)
{
echo "about my work";
}
elseif("status"==$message)
{
echo "my status";
}
elseif("quit"==$message)
{
echo "ok, bye";
}
else
{
echo "Sorry, I dont understand hierogliphics @^#%@*&#(&!*&@^!*&@#!!!";
}
$im->resetStep();
}

This class also supports fetching user info and sending message to a group of bot users. Check it out

Happy bot development

Categories: Cool Webapps · OpenSource · PHP
Tagged: , ,

35 responses so far ↓

  • ferdous // December 28, 2008 at 8:43 pm | Reply

    gr8 done :)

  • ranacse05 // December 28, 2008 at 8:44 pm | Reply

    thats waht i was looking for a long time. Thanks :D

  • Lenin // December 28, 2008 at 8:44 pm | Reply

    Coming later to master it better :P

  • TRIVUz // December 28, 2008 at 8:47 pm | Reply

    Bot is better then Human.. im creating one for me.. Great work boss

  • Kowser // December 28, 2008 at 8:48 pm | Reply

    Still i have not tested it yet. But i think this is gonna be a important scripts for me.

    Thanks a lot

  • Ishtiaque // December 28, 2008 at 8:57 pm | Reply

    Wow! Just tested it. Its pretty cool! Some of my friends were telling me to create one of their favorite game so that they can play it over common IMs. I guess this is what I was looking for. :) Thanks for sharing and making our life a lot easier!

  • Md. Shoriful Islam Ronju // December 28, 2008 at 8:59 pm | Reply

    Great job. I am trying to create one for me. Thanks Hasin bhai for the post.

  • swordfish // December 28, 2008 at 9:37 pm | Reply

    cool! this just opened a new window for one of my projects :-D

    liked it! Tagged :)

  • Afruj // December 28, 2008 at 9:54 pm | Reply

    Thanks

  • Tanin // December 28, 2008 at 11:46 pm | Reply

    joss hoise hasin bhai

  • bangaliana // December 29, 2008 at 12:26 am | Reply

    ;D

    Just made a quick bot: jokes@bot.im
    Add, To get new jokes (random), type: new

    Have fun!

  • saidur // December 29, 2008 at 12:45 am | Reply

    As usual hasin bhai, you are working on latest technology and i think this is very useful helper for to send message any microblogging application.And also giving nice example. Please add else in the callback function. Because if i write “marattok” it shows blanks :)

    Just for curios to know :
    why call callback function $callback($message,$step,$network,$userKey);
    in this way not like
    callback($message,$step,$network,$userKey);

  • hasin // December 29, 2008 at 1:01 am | Reply

    $callback(…) helps you to invoke the variable function name. It gives you the flexibility to pass any function name as string to be invoked as callback in setCallback($callback) function

    added the else block :) thanks

    thanks everyone for checking it out

  • Adam Kalsey (IMified) // December 29, 2008 at 1:02 am | Reply

    Thanks for whipping up that wrapper class. We’ll get it linked on our developer docs. Let me know if we can help you in any way with IMified.

  • mahmudahsan // December 29, 2008 at 1:12 am | Reply

    cool

  • murshed ahmmad khan // December 29, 2008 at 1:25 am | Reply

    echo “Sorry, I dont understand hierogliphics @^#%@*&#(&!*&@^!*&@#!!!”;

    he he he :D .

  • Justin // December 29, 2008 at 4:18 am | Reply

    Cool, eh? ;)

  • Wesley // December 29, 2008 at 4:21 am | Reply

    Ahh, these are the mybot.im guys are they not? I saw a vid of their product on ycombinator news a few weeks ago, didn’t know they already launched since mybot.im redirected to somewhere else.

    Thanks for the sample as well :)

  • Daniel O'Connor // December 29, 2008 at 6:06 am | Reply

    Ah, my favourite toolkit for this kind of thing is XMPPHP – http://code.google.com/p/xmpphp/

  • Create your IM bot for gtalk/jabber/aim/yahoo with imified API « NURUL FERDOUS // December 30, 2008 at 8:33 pm | Reply

    [...] made a news bot named news@bot.im AKA newsbot24@yahoo.com with the help of a wrapper class wrote by Hasin Hayder. This cool API has been provided by imified recently to make your application IM enable easily . [...]

  • IMified : Make your very own BOT (YIM-AIM-Gtalk-Jabber) « el NiNo // December 31, 2008 at 11:13 am | Reply

    [...] Hasin Hayder made it simpler for us (noob developers) by writing an easy to use wrapper class for the IMified API funtionality. And he released it under CC:LGPL license, so anyone can use that for free in non-commercial purposes with some conditions(ie. declaring the credit). [...]

  • sadiqbd // January 13, 2009 at 1:48 pm | Reply

    gr8 :)

  • Thet Aung // January 16, 2009 at 1:53 pm | Reply

    http://www.egressalumni.org/example2.php
    I got error after downloading your php code and test of it so I would like to know how can I fix it. thanks
    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/mmachet0/public_html/egressalumni/class.imified.php on line 13

  • Thet Aung // January 16, 2009 at 3:07 pm | Reply

    I got it by changing php4 version to php5

  • Gibransyah // February 3, 2009 at 5:47 pm | Reply

    Gracias!

  • Jawaad // February 6, 2009 at 3:11 am | Reply

    Waw, cool.. it’s work..
    But little Question..
    How can i manually put a userkey.

    I mean.. i want to the bot send a message to specific Yahoo user ID that input from REQUEST.

    example:
    /?user=visitor_yahooid&msg=hello

    then the bot send “hello” to visitor_yahooid

    Thx.
    Great Tutorial :)

  • IMified TwitterBOT (Jabbar/Gtalk/Yahoo/MSN/AOL) « el NiNo // February 6, 2009 at 9:21 am | Reply

    [...] wrote a Zodiac BOT for the IMified before, inspired by a wrapper class and usage example by Hasin Hayder. Now, putting a little more effort you can add your twitter in a [...]

  • bay garip // February 22, 2009 at 7:22 pm | Reply

    hi, Just i sign up to imified.com then i couldnt do success it.
    Well i am just begining on php.So i think must upload class.imified.php and example2.php to my site.But i did not understand where i must edit.Just on that? $im = new ImifiedHelper(”7DCDECB6-C895-9643-909CDC85CBF09954 “,”username@example.com”,”Oye!MyPassword!”);

    Bot Key , bot id and password ?

    Coz i tried add the bot to my jabber list before upload anything to my site.But it said; The bot.im certificate failed the authenticity test.
    Reason: Certificate is self-signed.

    So i continue without certificate But then;
    There was an error communicating with the server.
    Details: Authentication error: Not authorized

    By The Way i did not udnerstand which part is wrong
    Thanks

  • maSnun // March 5, 2009 at 9:04 pm | Reply

    Thanks for the wrapper class.

    I built jotil21@bot.im for my mobile community. You can type: “login username pwd” to login to the service. On successful login, you get a menu with new private msg notification.

    Type: “inbox” to view inbox. Type: “inbox 3″ to open your inbox at page 3.

    And so on… Just type “exit” to sign out from the service. Otherwise you’ll stay logged in.

    Currently my users can read their PMs. I found the service just today morning and cooked up the app. I will add more functionalities for the users of http://jotil21.net (Mobile – WML) community.

    Thanks for the class again.

  • maSnun // March 5, 2009 at 9:13 pm | Reply

    One more thing,
    http://bot.masnun.com/index.php would not work as call back url.

    So I typed without the sub domain: http://masnun.com/bot/index.php

    I dunno why it happened to me. But it worked with the second URL. The first one gave some sort of Open DNS error :-(

    Is it a bug of bot.im or a mistake/misunderstanding of mine?

  • vikas // March 9, 2009 at 6:36 pm | Reply

    Hello hasin bhai..

    Can you tell me what is the callback url . Should I give it http://mysite.com/bot

  • maSnun // March 9, 2009 at 9:19 pm | Reply

    The Callback url is the url of the script on your server. Download the wrapper class. Then create a file named “mybot.php”. Copy and Paste the example code into the file.

    Assuming that your website url is http://vikas.com and you uploaded the “mybot.php” to the public_html aka www directory, the callback url would be:

    http://vikas.com/mybot.php

    If you upload it to a subdirectory named “bot” under your public_html aka www directory, the callback url would be:

    http://vikas.com/bot/mybot.php

    Summary: The callback url is nothing but the url where the IMs from your bots’ users are sent to. The callback url receives the data as POST variable and prints out a response which is collected by the bot.im service and pushed back to the user. Hasin Vai’s wrapper class does all these things behind the screen. You can just edit the callback function’s definition to make it work. But remember that subdomains may cause problem. Always type in the real (or absolute ?) path to the script that handles requests and responds.

  • thainam83vn // May 10, 2009 at 3:22 pm | Reply

    Hi,
    I’m newbie of IMified. Yesterday, I create new bot undead@bot.im. Then I use Gtalk to add this bot, but not response from the bot for my invitation, it’s always offline. I don’t know why? My way:
    1. Create an account in http://www.imified.com site
    2. Then create one bot named undead@bot.im
    3. Using Gtalk add this bot

    Please tell me is there any wrong there.

  • thainam83vn // May 10, 2009 at 6:19 pm | Reply

    Sorry, I type wrong. It’s bonjour@bot.im, not undead@bot.im

  • nothing // July 15, 2009 at 4:20 pm | Reply

    Dear,
    I set up bot on Gtalk suscessfuly but I can’t set up on yahoo messenger network. What can I do?
    Thanks!

Leave a Comment