Routing Asterisk calls using Jabber presence status
Since version 1.4, a Jabber module is available in Asterisk. If you know me, then you probably wonder why it took me that long to discover it. I began playing with it tonight and the short story is that it works, it is simple to configure and it makes telephony aware of presence.
Of course this is still far from the holy grail of a presence-centered converged synchronous communications platform, but it is a start and anything is better than today’s stupid mass-market telephony.
Here is my /etc/asterisk/jabber.conf :
[general] ;Auto register users from buddy list autoregister=yes
;Jabber service label [asterisk] type=client serverhost=jabber.grabeuh.com username=asterisk@jabber.grabeuh.com/kisangani secret=my_password port=5222 usetls=yes statusmessage="Watching the telephone"
Yes, that’s it : Asterisk is now registered as a Jabber client. There are other ways to do it using external modules, but this one is the simplest – and since it is now part of the main trunk it is probably the most stable. In particular you should be careful with class.jabber.php which is not maintained anymore and in the process of being replaced with the much more modern XMPPHP.
Now let’s declare a macro for taking full advantage of that. This one takes a look at the user’s presence and routes the call accordingly : if he is online or chatty the call goes to his desk phone – otherwise it goes his mobile phone.
[macro-reach_user] ; ${ARG3} is a destination such as SIP/whatever exten => s,1,jabberstatus(asterisk,${ARG2},STATUS) ; presence in will be 1-6. ; In order : Online, Chatty, Away, XAway, DND, Offline ; If not in roster variable will = 7 exten => s,2,gotoif($[$[${STATUS}]<3]?available:unavailable) ; GotoIf(condition?label_if_true:label_if_false) exten => s,3(available),jabbersend(asterisk,${ARG2},"Call from ${CALLERID(name)} at number${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}") exten => s,4,Dial(${ARG1}) exten => s,5(unavailable),Dial(${ARG3})
Since we have declared a macro, we have to call it in the context of our choice and assign the relevant values to the macro’s variables :
[whatever_context] ; ${ARG1} is the destination when at desk ; ${ARG2} is a jabber address used at desk ; ${ARG3} is the destination when not at desk exten => 05600047590,1,Macro(reach_user,SIP/jml-desk, jim@jabber.grabeuh.com, SIP/freephonie-out/0666758747); ; repeat last line for each user
That’s all folks ! That is all it takes to have your calls routed to the right phone according to your presence status. It is really that easy.
Why no service provider is offering that is beyond me. The big ones are all waiting for the IMS systems they are going to deploy with a five years roadmap. But if you want the future right now there is no need to wait : all the technology is here today waiting for you to play with it ! And of course it is 100% Free software…
5 responses to “Routing Asterisk calls using Jabber presence status”
Leave a Reply
You must be logged in to post a comment.
That configuration exemple is now copied to http://www.voip-info.org/wiki/view/Asterisk+Jabber so that more people stumble on it.
Good stuff — thanks for posting this!
i read it twice but still have a question.
is this only.(i never used astersk before)
thus this mean you can only call out to jabber buddys. or also able to reseve incoming calls from jabber budys desktop client softphones?
This has nothing to do with XMPP or Jingle telephony. This trick uses Jabber only for testing presence. Then Asterisk establishes a plain old telephony session using his usual protocols.
It’s a well written article.It is really booming these days.Hence,we must try it out….