| Subcribe via RSS

Openfire/Jabber/FreePBX integration #2

January 6th, 2010 | No Comments | 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})

Asterisk – Jabber integration

December 31st, 2009 | No Comments | 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)

Integrating Jabber into Asterisk with FreePBX

December 31st, 2009 | No Comments | Posted in Asterisk, FreePBX

I was poking around with Asterisk trying to hook it into an Openfire XMPP server and get Asterisk to send IMs when various events happen.

I have Asterisk set up as a Jabber client by setting the following in jabber.conf

[asterisk]
type=client
serverhost=jabber.server
username=asterisk@jabber.server/AsteriskServer
secret=password
port=5222
usetls=yes
usesasl=yes
statusmessage="Asterisk Test Server"

The more interesting part came when trying to get Asterisk to send messages to Jabber clients for incoming calls. I found a lot of information on the web on how to do it, but not where to put the config when you’re using FreePBX.  It turned out to be fairly simple in the end.

Editing the extensions_custom.conf put int he following code.

[from-internal-custom]
exten => 10,1,jabbersend(asterisk,user@jabber.server,"Call from ${CALLERID(name)} at number ${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}")
exten => _X!,n,Goto(from-trunk,${EXTEN},1)

This sends an IM to user@jabber.server whenever they get an incoming call.

It could probably be improved to look up the appropriate user for the extension with a DB lookup (which means you’d only need one bit of code for all extensions) but I wouldn’t have a clue how to go about it.

The next step is to identify when an incoming call is for that extension in particular or if it’s a ring group.

Billion 7404VGP Optimisation

February 8th, 2008 | No Comments | Posted in Asterisk, Billion, VoIP

I have myself aBillion 7404VGP dsl2+ modem. I find it quite nice and full featured. Also, I’ve never had an isssue with a Billion after using them for about 8 years.

I recently decided to optimise the settings on the modem to improve call quality on the inbuilt SIP client and for various other needs. In searching for a solution to the problem I stumbled across a word doc by an unknown author. I found it quite good at explaining how things can work and since doing what was suggested in it I have had no problems with calls.

I’ve included the word doc with this post and if anyone knows who wrote it i’ll happily attribute them.

Billion QoS optimisation

GoTalk SIP Configuration

August 4th, 2007 | 2 Comments | Posted in Asterisk, VoIP

In setting up Asterisk to use GoTalks VoIP product. The SIP connection is specified as using dtmfmode RFC2833. However when you explicitly use that value you cannot use dtmf.

Trial and error found that it needs to be set to auto.

Tags: