I have been playing with ejabberd, Jabber, XMPP and the various client libraries, specifically the rather wonderfully simple Jabber::Simple and Jabber:Bot.
It all started because I was doing a Fireeagle integration job with a product at work, and was getting frustrated with the fact that it is still not super simple to update my location. It struck me as I stared at my desktop, that I always have Adium running. Wouldn’t it be great if I had a Fireeagle contact that I could just tell my location, and it would go off and update, letting me know when they’re done. Now that part is midway done (post to come), but before I started that, I wanted to research more the workings of a Chatterbot, a computer program that pretends to be a human and can answer basic commands. They have been around for a long time, I remember playing with an IRC bot a while back, getting it to display the last commit messages from Subversion.
So that research turned into a BBC Programmes bot. As I worked on BBC Programmes, I have good knowledge of the site and the data within, and building a bot that integrated with that data seemed a good example of using the restful API available.
If you just want to try this thing out, here are the details of what you need to do.
- You need a Gmail or Jabber compatible IM account
- You need a Jabber enabled client, I’ve listed a few:
- You need to add a new contact: firstname.lastname@example.org
This should be it. You should have a new contact appear in your list (They have a BBC logo as an avatar). You can now begin a conversation with this contact. It’s probably best to start with:
The help menu is your best starting point
You can get more detailed help on the various commands with:
-> ? upcoming
-> ? schedule
This should give you enough information to start making queries against the BBC Programmes data.
[NOTE] I should say at this point, that this service is running on my own little virtual box, and I don’t have the funds to have Deep Blue, so the service may well fall over, or be a bit flaky if many people use it. I’m hoping to persuade my bosses to let me host this on the BBC infrastructure at some point, but until then be aware. The beauty of this kind of service though is that if it dies, your contact just goes offline. When the service is brought up again, the contact comes online. Nothing too drastic in other words.
So here’s a few fun commands to get you going:
# show what's currently on 6music
-> now 6music
# show what's currently on radio4
-> next radio4:fm
# show the BBC One London schedule
-> schedule bbcone:london
# show the BBC One London schedule in detail
-> schedule bbcone:london in full
# show upcoming programmes in the format Films available on BBC One in detail
# you can get a full formats list from: http://add.url.com
-> upcoming films on bbcone:london in full
# show upcoming programmes in the genre Drama/Soaps available in detail
# you can get a full genres list from: http://add.url.com
-> upcoming drama:soaps in full
Upcoming films on BBC Two
Hopefully you get the idea, and like I said the help page should give you all the information you need, specifically around getting hold of all the network names available to the bot.
I have a few ideas for future development, specifically around asking for things that you can watch via iPlayer. So you could ask:
-> available films on bbcone:london
-> available eastenders
This is in the pipeline, and I’ll just add the functionality as I get it finished, so keep an eye on the help page for more commands.
Much of the heavy carrying is handled but the brilliant Jabber::Bot written by Brett Stimmerman. I’ve customised it slightly for my needs, by added the ability to deamonize it and also tweaks around the displaying of help information.
The work that remained was to build a ‘recipe’ script that defines and handles all the incoming commands. There is currently no caching or optimisations, but you can get a copy of this to use yourself from:
You can just add the relevant configuration entries at the top of the script and then start in a way that suits you best. I have moved over to using daemontools, but you can still uncomment the relevant lines in the script (see comments) and use:
and bingo, you should now have your own BBC Programmes bot to communicate with.