| Subcribe via RSS

Openfire/Jabber/FreePBX integration #2

January 6th, 2010 Posted in Asterisk, FreePBX, Openfire, VoIP

Having played some more I’ve come up with the following solution – I’m not overly happy with it but it allows me to get what I wanted.
All of the following occurs in extensions_override_freepbx.conf
NOTE: This assumes you have gotten the Openfire Asterisk-IM plugin working and that you have jabber.conf configured correctly to talk to your openfire server.

Asterisk obeying Openfire Status

eg. When you mark yourself as away/DND inbound calls will be directed to Voicemail.

This inserts itself into the standard FreePBX call queue for internal calls. I haven’t got an inbound link setup yet so I haven’t figured out how to get that bit working.

The jabber-notify block must contain every extension in the system this is to work on. It could be altered to return to the normal call path if a desired extension isn’t in the list – but I haven’t implemented that.

Basically a call to an extension picks up the appropriate jabber information and runs the macro “reach_user_with_presence”. There is probably some way to hook this into a db/ldap server so you don’t have to enter everyone in manually.

This then checks the users jabber status and if they are not available it jumps to their voicemail. Else it returns to the normal call path.

[from-internal]
include => jabber-notify

[jabber-notify]
;include => macro-reach_user_with_presence
exten => 10,1,Macro(reach_user_with_presence,user10@jabber.kayosdesign.com,${EXTEN})
exten => 11,1,Macro(reach_user_with_presence,user20@jabber.kayosdesign.com,${EXTEN})
exten => 12,1,Macro(reach_user_with_presence,user30@jabber.kayosdesign.com,${EXTEN})
exten => 13,1,Macro(reach_user_with_presence,user40@jabber.kayosdesign.com,${EXTEN})

[from-internal-original]
include => from-internal-xfer
include => bad-number

[macro-reach_user_with_presence]
; ${ARG1} is a jabber address such as test@jabber.server
; ${ARG2} is the voicemail box of the user

exten => s,1,jabberstatus(asterisk,${ARG1},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(available),Goto(from-internal-original,${ARG2},1)
exten => s,n(unavailable),VoiceMail(${ARG2},u)
exten => s,1,Goto(from-internal-original,s,1)
exten => h,1,Macro(hangupcall)

Call groups being notified by jabber for inbound calls.

We utilise the Counterpath Bria softphone. It’s a bit stupid and does not follow ALERT notifications such as  different ring tones.  As such there is no way for a user to know if an inbound call is implicitely for them or if it is coming in on the call group.

As such I hooked Asterisk into jabber to broadcast a message to all people in the call group. I don’t particularly like this as you cannot create call groups dynamically using the FreePBX interface. If you do create one you MUST rebuild this section appropriately. Basically all it does is override the default settings and sends out an IM to everyone listed (you have to add each individual in the group to the ext-group section), after that it returns to the setup created by FreePBX.

[ext-group]
exten => 330,1,jabbersend(asterisk,user10@jabber.kayosdesign.com,"Group call")
exten => 330,n,jabbersend(asterisk,user20@jabber.kayosdesign.com,"Group call")

exten => 330,n,Goto(ext-group-original,330,1)

[ext-group-original]
exten => 330,1,Macro(user-callerid,)
exten => 330,n,GotoIf($["foo${BLKVM_OVERRIDE}" = "foo"]?skipdb)
exten => 330,n,GotoIf($["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]?skipov)
exten => 330,n(skipdb),Set(__NODEST=)
exten => 330,n,Set(__BLKVM_OVERRIDE=BLKVM/${EXTEN}/${CHANNEL})
exten => 330,n,Set(__BLKVM_BASE=${EXTEN})
exten => 330,n,Set(DB(${BLKVM_OVERRIDE})=TRUE)
exten => 330,n(skipov),Set(RRNODEST=${NODEST})
exten => 330,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 330,n,Set(RecordMethod=Group)
exten => 330,n,Macro(record-enable,11-13,${RecordMethod})
exten => 330,n,Set(RingGroupMethod=ringall)
exten => 330,n,Set(__ALERT_INFO='\\;info=ring_two')

exten => 330,n(DIALGRP),Macro(dial,20,${DIAL_OPTIONS},11-13)
exten => 330,n,Set(RingGroupMethod=)
exten => 330,n,GotoIf($["foo${RRNODEST}" != "foo"]?nodest)
exten => 330,n,Set(__NODEST=)
exten => 330,n,dbDel(${BLKVM_OVERRIDE})
exten => 330,n,Hangup
exten => 330,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})

Leave a Reply