i've set up a live chat using ejabberd. It's working pretty well but I'd like to be able to round-robin chat sessions to different operators depending on who is already in a chat and who is free to talk. To implement this I need some way to update a users presence based on wether they are currently in a private chat. I'm currently using mod_shared_roster to advertise presence but it only reports wether a user is available.

This really needs to be done server side because I will need to rely on different IM clients depending on the operators' system.

2 Answers 2


You may consider connecting all operator sessions under one account and different resources. Ex. help@example.com/Operator1 help@example.com/Operator2 help@example.com/Operator3 All with priority 1.

When an operator is in chat with user, send presence with priority -1. This removes the resource from a resource pool to contact when user sends message to 'help@example.com'. When operator finishes chatting with user - send presence with priority 1.

An added feature of this model is that you have only one Jabber ID to communiate to your users - help@example.com

  • this isn't the solution i went with but it's worth a tick anyway.
    – SpliFF
    Aug 26, 2009 at 5:57

I've found a workaround. Since the livechat system uses jsjac (javascript interface to xmpp) I can craft my own presence packets. When a client connects to an operator I set the clients' presence to 'chat' and status to 'talking to <operator jid>'.

When a new client connects I can query the status of all other clients to see who they are chatting to and choose the operator with the least active chats.

If anyone knows a better/easier way I'm happy to hear it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.