Asterisk Call Notification over XMPP

Recently I was asked how I get notification messages when a call is made to my VoIP number and extension. It’s only a few lines of configuration, but worth noting down for future reference. This all applies to Asterisk 1.4, on Debian Lenny

Step one: Set up appropriate Jabber integration.

This requires the res_jabber resource, which is provided by default when installing Asterisk on Debian.

Next up, set up /etc/asterisk/jabber.conf as follows…

 [general]
debug=yes ;;Turn on debugging by default.
autoprune=no ;;Auto remove users from buddy list.
autoregister=yes ;;Auto register users from buddy list.

[gtalk_account]

type=client
serverhost=talk.google.com ;; Your server
username=yourusername@gmail.com/Talk   ;; This is your full username, with the domain name and service name
secret=yourpass ;; Your password
port=5222
usetls=yes  ;; TLS is required by talk.google.com, you’ll get a ‘socket read error’ without
usesasl=yes
buddy=yourmate@googlemail.com ;; A friend
buddy=yourothermate@jabberserver.org ;; Another friend
statusmessage=”VoIP calls only”  ;; This can be anything, but it would be useful to let people know that you probably won’t respond to text chat
timeout=100

Once all this is configured, restart Asterisk, and check the channel status with jabber show connected. All being well, you will see the following entry

  User: yourusername@gmail.com/Talk  – Connected

This indicates that Asterisk has successfully connected to the Jabber/XMPP server. If you are interested in using Google Talk too, then continue faffing with iksemel and gtalk.conf. More info on that nature can be found over here.

Step 2: Tweak your extensions

This part is relatively simple, assuming you’re not bothered about checking for presence. Simply insert the following line into your dialplan, in /etc/asterisk/extensions.conf.

   exten => 2000,1,JABBERSend(gtalk_account,kyle@lodge.glasgownet.com, Call from “${CALLERID(name)}” at number <${CALLERID(num)}> on ${STRFTIME(,GMT0BST,%A %B %d %G at%l:%M:%S %p)} )

This is the crucial part. In this case, it’s the first action for extension 2000. Equally, it could be anywhere on the list. It uses the JabberSend function to send a message using XMPP to my Jabber account, kyle@lodge.glasgownet.com. The account it uses to send is gtalk_account as defined earlier in jabber.conf. It simply takes various callerid parameters, such as the name and number, and ties it in with a representation of the date. STRFTIME will format the date to a layout that you request, and localize it according to your timezone. In this case, GMT0BST is the timezone notation for the United Kingdom, and you can pick your own from this list. A full list of STRFTIME options can be found over here.

I hope this helps out someone. I’ve certainly found it useful to be notified when someone is calling me and I’m away, and also to have a call log that’s easily accessable (I connect to my Jabber server using irssi inside screen). Some day soon, I hope to write about how to divert a call based on Jabber/GoogleTalk presence. In the meantime, I highly recommend the book Asterisk: The Future of Telephony, shown below.

One comment

  • [...] I busied myself with tweaking Asterisk to do some more geeky things. One such item was where I configured it to send a message to my Jabber account every time there was a call to a particular extension. Great for call logging, integration, and [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Go to Top