493: Undecipherable

-Blog-

-Projects-

-Urlaub-

-About me-

-RSS-

Asterisk using LUA: How to pre-dial and macro (incl. parameters)

Dennis Guse

Asterisk allows to implement a dialplan in Lua.

It works quite well, if you are aware that the parser is very nitpicking againt indentation: always use either spaces or tabs. The Asterisk documentation gives a a nice overview how to use Lua.

Macros and Pre-Dial-Handler are missing there, but they are quite useful... Here is the syntax example:

 1 extensions = {
 2  ["macro-mhandler"] = {
 3      ["s"] = function(c, e)
 4          app.verbose("Hello Macro!")
 5          app.verbose("Got parameter: " .. channel["ARG1"]:get())
 6      end;
 7  };
 8 
 9  predial = {
10      ["phandler"] = function(c, e)
11          app.verbose("Hello Pre-dial!")
12      end;
13  };
14 
15  default = {
16      ["_X"] = function(c, e)
17          app.dial("SIP/" .. e, nil, "B(predial,phandler,1)M(mhandler^Put your parameter here)")
18      end;
19  };
20 }