On Mon, Jul 7, 2008 at 1:21 PM, Douglas Garstang <[EMAIL PROTECTED]> wrote: > So, I need to build a complicated IVR with Asterisk, with a lot of back end > hooks. The dial plan itself has a lot of limitations, not the least of which > is that the dial plan is ugly, hard to maintain, and full of gotchas like > all variables being global etc etc. > > I've been involved with Asterisk for a couple of years now and this is a > problem I have yet to see a good solution for.
We're using asterisk-1.4, with AGI scripts written in Perl. We find it maintainable, we find the overhead minimal, and we have back-end hooks, primarily in a MySQL database. The code is maintainable because it's well-structured, containing subroutines, comments, and the code does no more than is needed at any given moment. We've also modded asterisk code in C, which was also a relatively straightforward task. I found that variable and function names are well-chosen and that the code worked in predictable ways. Perl can be written with or without everything being global variables. We make the variables we need in most of the plan to be global, and everything else is a local variable, with limited scope, in a subroutine. We also built our own Perl module which we call from the dial plan. This gave us great encapsulation between private data / only passing the exact data you need to accomplish the task. The Perl module came in very handy. Dialplans that are not related to each other are stored in completely separate AGI scripts, and never need to know anything about each other. They get to use the nifty Perl module for things that most of our AGI scripts need to do, like read / update MySQL, transfer a call, dial out, etc. I would say that a "good solution" can be met dozens of ways, including studying your dial plan and deciding whether making everything a global variable was a good idea. How about a main menu that jumps to three separate dial plans, each of which are actually maintainable? You can accomplish great things with structured programming. With or without asterisk, bad code is bad code. It may be time to have somebody with fresh eyes look over your dialplan. _______________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- AstriCon 2008 - September 22 - 25 Phoenix, Arizona Register Now: http://www.astricon.net asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
