Interactive Screen Pops with Asterisk & XMPP

I’ve got a thing about screen pops.
Asterisk
I’ve written before about using Asterisk and XMPP to enable IM-based screen pops, but the recent release of Asterisk 1.8 creates a whole new reason to be excited about this topic.

The new version of Asterisk includes a new dialplan function called JABBER_RECEIVE.

This new function nicely compliments the existing JabberSend() dialplan application and lets you read incoming XMPP messages into dialplan variables (via Set()).

Now that you can both send and receive XMPP messages via the dialplan, it is possible to build sophisticated CTI applications using standards-based XMPP servers and clients with nothing but extensions.conf. Here’s how.

You’ll need an XMPP server with (at least) two accounts. One for you, as a user. One for Asterisk. You’ll also want to fire up your XMPP client and add the Asterisk user to your buddy list.

Set up jabber.conf with the details of the Asterisk account on your XMPP server (make sure you run jabber reload in the Asterisk CLI after modifying the file):

Once you’ve done that, you’ll need to add some dialplan logic to use both JabberSend() and JABBER_RECEIVE (run dialplan reload in the Asterisk CLI after adding this logic):

In this simple example, anytime a call comes into the default context, a set of IM messages are sent to the XMPP account user@xxx.xxx.xxx.xxx (where xxx.xxx.xxx.xxx represents the host name/IP for your XMPP server). The following line in the dialplan will cause Asterisk to wait 10 seconds to receive a response from user@xxx.xxx.xxx.xxx.

exten => _XXXX,n,Set(OPTION = ${JABBER_RECEIVE(asterisk,user@xxx.xxx.xxx.xxx,10)})

When a response is received, it is read into the variable OPTION. Subsequent dialplan logic will either send the call to the extention that was dialed, or simply hang up (you could just as easily add options and logic to route the call to one of several different phone numbers or to voicemail).

That’s it!

This powerful new addition to Asterisk makes building sophisticated, interactive XMPP-based screen pops easy. Just imagine what other juicy little nuggets await in the new version of Asterisk.

Happy screen popping!

Getting Conferency With Asterisk

A good indicator of just how powerful and useful Asterisk can be is demonstrated by the amount of effort that is required to build a feature rich conference call application. What if I told you it can be done in 6 lines of code?

(Yes, extensions.conf is software – when you work with it, you are writing software code. See “When You Write extensions.conf, You Are Writing Software” by @jicksta in this post for more on this.)

Create a conference room by editing meetme.conf:

$ echo "conf => 1234,2345,5678" >> /etc/asterisk/meetme.conf

Or you can open the file with your favorite editor and add the new line at the bottom. This will create a conference numbered 1234, with a user PIN of 2345 and an administrator PIN of 5678. Next create a dialplan context and rule set for the conference room

[MyFirstConferenceRoom]
exten => 9000,1,Answer()
exten => 9000,n,Meetme(1234,ips)
exten => 9000,n,Hangup()

The parameters passed into the Meetme() application are the number of our conference room (just created in meetme.conf) and a set of options. The i option enables an announcement each time someone enters or leaves the room. The p option allows a user to exit the conference by pressing the ‘#’ key. The s option allows a user (regular or admin) to hear a menu of options when the ‘*’ key is pressed.

Now, include the conference room context in your primary dialplan context:

include => MyFirstConferenceRoom

That’s it – to test it out, make sure you reload your dialplan, and then dial 9000.

You’ve got to love how easy it is to get conferency with Asterisk!

Book Review: Asterisk 1.6

The folks at Packt Publishing recently sent me a copy of Asterisk 1.6 by David Merel, Barrie Dempster and David Gomillion and I’ve been using it for the past week or so to set up a fresh instance of Asterisk 1.6 on Ubuntu 8.04.

(Note – like many Asterisk books, this one is very CentOS focused, but I found the installation and configuration steps described in it – as well as some of the larger Asterisk management concepts – easily applied to Debian-based distros like Ubuntu.)

This is a solid, well-written book for anyone that wants to start building and managing an Asterisk-based telephony system. I found this book to be very well focused on concepts that would appeal to someone who wants to manage an Asterisk system professionally, and is probably less well suited for someone interested in tinkering with Asterisk as a hobby.

There is a good discussion of some of the key concepts that someone who aspires to be (or already is) an Asterisk professional should have a handle on. It has a very good discussion on hardening an Asterisk server in the chapter on “Maintenance and Security”, and the book begins (very appropriately) with an exercise in developing a deployment plan – again, probably not well suited for an Asterisk or VoIP tinkerer, but critical for someone who is going to deploy an Asterisk server in a production environment and assume responsibility for managing it.

I didn’t see any discussion of some of the more cutting edge features of Asterisk 1.6 that might be of interest to someone wanting in exploring alternative communication protocols (Jabber/Jingle) or some of the less mainstream channel drivers (GTalk, Skype, etc.) There is no mention at all (that I could see) of how to connect Asterisk to Google Talk via Jingle, or to the Skype network via Skype for Asterisk. Nor is there any mention of some of the IM-focused dialplan applications like JabberSend().

This book appears to be designed for someone who wants to set up and manage a more traditional Asterisk-based system. And for that purpose it is very well suited.

VoiceGlue 0.10 Released

For those that don’t know, Voiceglue is an open source project that links Asterisk (the open source PBX) with OpenVXI (an open source VoiceXML platform currently under the stewardship of Vocalocity). Voiceglue makes it possible for Asterisk users to deploy a completely open source VoiceXML platform for building IVRs and other useful applications.

The Voiceglue project recently announced the release of version 0.10 – there are several new features in this release:

  • Improved audio caching
  • Cookie passing on audio fetching
  • Handles maxage and audiomaxage of 0 properly
  • Uses HTTP Content-Type for audio content when available
  • Defaults to not requiring access-control directive in returned data from data tag
  • New transfer method, new config file param “blind_xfer_method”
  • Auto-install support for Ubuntu 9.04 (Jaunty)

I’m especially interested in the last item – I’ve been meaning to set up a VM to play around with Ubuntu 9.04 for a few weeks now, and this is yet another good reason for doing so.

The new version of Voiceglue can be downloaded here.

Shoring up Asterisk Security

Found out today that an external host had been scanning my Asterisk server looking for valid SIP extensions. Turned out the IP belonged to some German hacking site that was probably using some brute force tools to scan my server (and lots of others) for valid SIP extensions. The ultimate goal was more than likely to try and exploit any live extensions for some free phone calls.

Fortunately, in anticipation of moving my in-house Asterisk server out to the cloud I had recently done some work to become better educated on Asterisk security and to shore up the security of the CentOS machine my Asterisk instance is running on. As a result, my intrusion detection system slammed the door to the external scans pretty quick, and I’ve since added the IP address to my iptables rule set to to drop any requests from the IP used for the scan.

It was a little unnerving to find out that my box was getting scanned, but I’m glad I took the time recently to get things working more securely. This incident reminds me that one can never be too careful about security, and that there is always more to learn about running Asterisk more securely. To underscore this last point, here are some great links I’ve come across lately for Asterisk and Linux security:

Some general Linux security reading:

Happy reading!

Book Review: AGI 1.4 and 1.6 Programming

Have you been working with Asterisk for a bit and want to use it to build some more sophisticated applications? Are you looking to build and IVR solution, but are a bit wary of what you will be able to accomplish with the Asterisk dialplan alone? Are you comfortable on the Linux command line and with using PHP-based scripts in a Linux environment?

If you answered yes to any of these questions, then you will want to check out the book “Asterisk Gateway Interface 1.4 and 1.6 Programming” by Nir Simionovich. There is a lot to like in this book for Asterisk programmers.

One of my favorite quotes from this book is:

Many IVR developers do not regard themselves as programmers. That is a shame as programming an efficient IVR environment using any type of telephony engine requires skill, and when done right can be regarded as a work of art.

Truer words were never spoken. I personally have never suffered from the affliction of thinking that voice applications developers are not “programmers” – voice application developers are programming Rocks Stars, pure and simple. So if you are a Rock Star (or aspire to be one), you should check this book out.

I like that this book spends some time talking about developing IVRs using the Asterisk dialplan, even though the limitations of building IVRs using the dialplan itself is probably what leads most developers to explore alternatives like PHPAGI or Adhearsion.

There is a great section in this book outlining the “ten rules of AGI development” – things every developer should know before starting AGI programming of any flavor. This book starts with the basics and moves quickly (but comfortably) on to advanced topics.

If you are an Asterisk guru, or a hobbiest that is just getting started, this book is worth having in your collection. My copy is on my bookshelf, within arms reach, right next to my dogeared copy of O’Reilly’s “Asterisk: The Future of Telephony.”

Now, if only they’d put IVR development into the next edition of Guitar Hero

VoiceGlue Up And Running

I now have VoiceGlue up and running on Ubuntu 8.10. (Actually, the Ubuntu server is running as a virtual machine under Sun’s VirtualBox 2.1.)

For those that don’t know, VoiceGlue is an open source project that links Asterisk (the open source PBX) with OpenVXI (an open source VoiceXML platform currently under the stewardship of Vocalocity). VoiceGlue makes it possible for Asterisk users to deploy a completely open source VoiceXML platform for building IVRs and other useful applications.

The VoiceGlue install on Ubuntu 8.10 went smoothly — I did run into an issue with one of the services not starting, but that was easily identified and fixed thanks to a speedy response from the VoiceGlue folks. (This issue was really my own fault — use the pgrep command to make sure you have specific services running. And when in doubt, check the logs people!)

Based on my experience with the install and my initial testing I am extremely impressed with VoiceGlue. Its well documented and there is an active community of users offering tips and troubleshooting advice.

Hats off to the people behind VoiceGlue — Doug Campbell and Steve Smith. Well done!