Integrating Jabber into Asterisk with 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.