| Subcribe via RSS

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.

MySQL ErrorNo 121

December 29th, 2009 | No Comments | Posted in MySQL, Web Development

MySQL has a helpful error “Can’t create table (errno: 121)” which doesn’t seem to be documented anywhere except in forums.

Turns out this error is caused by InnoDB tables throwing an error when it detects duplicate foreign key names.

Basically, every foreign key has to have a unique name for InnoDB to function correctly.

Badger Badger Badger

December 9th, 2009 | No Comments | Posted in Uncategorized

It’s A SNAAAAKKKKEEE!!!

Palm snake

A neighbour knocked on the door and told us that there was a snake on our roof. By the time we found it it had changed from a roof snake to a palm snake.

Palm Snake 2

Tree Snake 1

Tree Snake 2

Close up

Breakfast

Breakfast was tasty.

Longish, but not too long

Spot the Python

Spot the Python.

Digesting breakfast


Skin

This skin may be from the same python. But it looks too long for it to me. We have had bigger pythons in the back yard in the past.


Drawing Development

December 2nd, 2009 | No Comments | Posted in Uncategorized

I have no idea how kids are supposed to develop but in the past 6 months Liam has gone from potatoes with arms to full stick figures.

Liam the potatoe

12th Nov

Liam playing golf

30th Nov

Beer

December 2nd, 2009 | No Comments | Posted in Uncategorized

A client recently sent me some of my own branded beer.

The bottle

The label

Apparently I’m fantastic enough to get my  own beer.