Why write your dialplan using Lua?

Home » Asterisk Users » Why write your dialplan using Lua?
Asterisk Users 4 Comments


Reading through the Wiki:

“Asterisk supports the ability to write dialplan instructions in the Lua
programming language. This method can be used as an alternative to or in
combination with extensions.conf and/or AEL. PBX lua allows users to use
the full power of lua to develop telephony applications using Asterisk”

My question is, what is the benefit of using Lua? I recently noticed that
OpenSIPS added a compatibility module to use Lua as well. However, where is
the real advantage here?

I mean, you have all these pieces in Asterisk like Lego blocks: AGI
Commands, AMI Actions, Dialplan Applications, Dialplan Functions which I
think are the ones that really limit what the PBX can do right?

What’s the difference between calling them out from extensions.conf or even
from extensions.ael and calling them from extensions.lua? What else can you
do writing you dialplan in Lua? Could I maybe program N-Way calling* with

Are we talking about expanding Asterisk capabilities a huge deal? Or just
performance wise during dialplan execution?

With OpenSIPS I understand its power because you may affect the SIP
behavior based on db queries performed by Lua scripts, or modify the next
message to be sent, but with Asterisk, you wouldn’t be able to modify an
ongoing session through Lua based on, e.g., an incoming INVITE to establish
a new conference room, would you? Or tell Asterisk to save the
Register-CallID of an endpoint as part of the sip peer settings in memory,
like the contact ID field.


*José Pablo Méndez

**By N-Way calling I mean having one party on hold, calling another party,
and immediate (ad-hoc) invoke a conference bridge to join the 3 parties.
Just like Cisco phone systems do. *

4 thoughts on - Why write your dialplan using Lua?

  • I’ve never used Lua, but I also have a curiosity about it.

    A couple of years ago, I wrote my first dialplan in AEL. Some bits were
    clumsy, minor syntax errors caused major parts of my dialplan to
    disappear, and I discovered a bunch of bugs*.

    But, many parts were elegant. Bits that would have been an ugly mess in
    ‘plain dialplan’ seemed obvious and clear.

    I would expect a similar experience with Lua. Kind of an opposite ‘1984**’

    If you take the jump, please post your experiences.

    *) This was in 1.2 so there was no benefit in reporting the bugs.

    **) In Orwell’s 1984, the ‘scope’ of language was reduced to eliminate the
    ability to express subversive thoughts.

  • I wouldn’t jump to a whole different language just to have an elegant
    script plan. There must be another reason why Lua is being so widely
    implemented than elegance and execution performance.


    *José Pablo Méndez

  • One of the advantages of Lua is that it is embedded in other applications
    so you can ‘leverage’ the learning investment.

    Kind of like why you write your AGIs in Perl and I do in C. It’s what we
    already know and we don’t have to overcome ‘yet another language’ inertia.

    AEL was a big win for me over ‘conf.’ I’m hoping that Lua will be a big
    win over AEL.

    One thing does concern me…

    Here we are all discussing something we don’t know anything about and
    nobody has chimed in with their experiences. If nobody is using it, how
    many ‘arrows’ will I get in my back when I blaze that trail?

  • Ok so its not a cosmetic thing only. I eases your administration. Do a
    point for performance.

    Now, what about my questions regarding extending the systems caps by
    building things asterisk could not build by itself. does it hold true?