493: Undecipherable

-Blog-

-Projects-

-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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extensions = {
	["macro-mhandler"] = {
		["s"] = function(c, e)
			app.verbose("Hello Macro!")
			app.verbose("Got parameter: " .. channel["ARG1"]:get())
		end;
	};

	predial = {
		["phandler"] = function(c, e)
			app.verbose("Hello Pre-dial!")
		end;
	};

	default = {
		["_X"] = function(c, e)
			app.dial("SIP/" .. e, nil, "B(predial,phandler,1)M(mhandler^Put your parameter here)")
		end;
	};
}