Making your IM Bot Usable with Typing Notification
October 23rd, 2007; Posted in Code Add:
Del.icio.us |
We are all big fans of usability and are in a constant effort to make our applications more fun and more easy to use. A key part of RallyClock is the IM bot, or the daemon (i.e. process that keeps running) we wrote to process your messages and then send you back a reply.
One thing we did notice in our development and usage efforts is there is sometimes a bit of a lag over the Jabber network from when you send the initial message, we process it, and then send back a return. Instead of keeping you hanging, we decided to use the already-present IM typing notification feature found in most IM clients.
Concept
The concept is fairly simple and mimics the chain of events when you are IM’ing conversation with a fellow human.
- John types a message
- Sue reads the message, then starts to compose a return message
- John sees that Sue is typing, and is anxiously waiting for the return message
Without that notification, John wouldn’t know if Sue is going to send a response, or even if she got the message - which could spell a lot of stress and anxiety for John. That little icon really gives us a great deal of feedback - we know the message didn’t end up in the bit-bucket, and we know that we should get a reply in the near future.
After a few tests with our RallyClock bot, we noticed a void during our “conversation”, i.e. when sending commands to the bot. We really want to make sure the user who sent the command knows the bot received it and is in the process of sending back a message.
Implementation
After a few minutes of looking at the raw jabber log, we noticed a piece of communication would come across that would trigger the typing notification. It was pretty obvious, actually. A simple composing message is all it takes.
<x xmlns='jabber:x:event'>
<composing/>
</x>
We based our bot on the Jabber::Simple module, so adding this to our processing was fairly simple to implement. In our JabberBot code, we create a jabber object, start our loop, then send our composing message to the client before processing the incoming message. Here is some severely pruned-down code, to give you some context…
jabber = Jabber::Simple.new(Config::SCREENNAME, Config::PASSWORD)
while(1) do
jabber.received_messages do |msg|
# Ah, we have a message, send typing notification
# just about before doing anything else
jabber.client.send("<message
from='#{Config::SCREENNAME}'
to='#{msg.from}'>
<x xmlns='jabber:x:event'>
<composing/>
</x></message>")
#
# ... rest of message processing code here ...
#
end
end
Results
You can try it for yourself with a RallyClock account, it is pretty slick. Or check out this mini screen tour: #1 I am sending a command (show projects) to the bot which #2 sends back the notification while it is “thinking” and then #3 my return message appears…
