| Subcribe via RSS

Asterisk – Jabber integration

December 31st, 2009 Posted in Asterisk, FreePBX, Openfire, VoIP

I have a test server running Asterisk & Openfire. Integrating Openfire to Asterisk was pretty simple using the Asterisk-IM plugin.

It is configured and working using the documentation provided by Openfire. No when someone receives/makes a call Openfire updates their IM status to “On the phone”.

However, it does not appear to be bi-directional eg. Setting jabber status to DND does not tell Asterisk to send your calls to voicemail.

Having played with the config I now have bi directional communication between asterisk/openfire working within the FreePBX framework.

The code below will check extensions to see what their status is in jabber before passing the call on to them.

If they are flagged as available, the server will send them an IM telling them about the incoming call & then pass the call through.

If they are not available, the server will direct the incoming call to voicemail.

editing extensions_custom.conf you need the following

[from-internal-custom]
include => macro-reach_user_with_presence
exten => 10,1,Macro(reach_user_with_presence,SIP/10,test@jabber.server,${EXTEN})
[macro-reach_user_with_presence]
; ${ARG1} is a destination such as SIP/10
; ${ARG2} is a jabber address such as test@jabber.server
; ${ARG3} is the voicemail box of the user

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,n,gotoif($[$[${STATUS}]<3]?available:unavailable)
;GotoIf(condition?label_if_true:label_if_false)
exten => s,n(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,n,Goto(from-trunk,${ARG3},1)
exten => s,n(unavailable),VoiceMail(${ARG3},u)

Leave a Reply