3 CONSOLE = "Console/dsp" -- Console interface for demo
5 --CONSOLE = "Phone/phone0"
7 IAXINFO = "guest" -- IAXtel username/password
8 --IAXINFO = "myuser:mypass"
12 -- TRUNK = "IAX2/user:pass@provider"
16 -- Extensions are expected to be defined in a global table named 'extensions'.
17 -- The 'extensions' table should have a group of tables in it, each
18 -- representing a context. Extensions are defined in each context. See below
21 -- Extension names may be numbers, letters, or combinations thereof. If
22 -- an extension name is prefixed by a '_' character, it is interpreted as
23 -- a pattern rather than a literal. In patterns, some characters have
26 -- X - any digit from 0-9
27 -- Z - any digit from 1-9
28 -- N - any digit from 2-9
29 -- [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
30 -- . - wildcard, matches anything remaining (e.g. _9011. matches
31 -- anything starting with 9011 excluding 9011 itself)
32 -- ! - wildcard, causes the matching process to complete as soon as
33 -- it can unambiguously determine that no other matches are possible
35 -- For example the extension _NXXXXXX would match normal 7 digit
36 -- dialings, while _1NXXNXXXXXX would represent an area code plus phone
37 -- number preceded by a one.
39 -- If your extension has special characters in it such as '.' and '!' you must
40 -- explicitly make it a string in the tabale definition:
42 -- ["_special."] = function;
43 -- ["_special!"] = function;
45 -- There are no priorities. All extensions to asterisk appear to have a single
46 -- priority as if they consist of a single priority.
48 -- Each context is defined as a table in the extensions table. The
49 -- context names should be strings.
51 -- One context may be included in another context using the 'includes'
52 -- extension. This extension should be set to a table containing a list
53 -- of context names. Do not put references to tables in the includes
56 -- include = {"a", "b", "c"};
58 -- Channel variables can be accessed thorugh the global 'channel' table.
60 -- v = channel.var_name
61 -- v = channel["var_name"]
65 -- channel.var_name = "value"
66 -- channel["var_name"] = "value"
69 -- channel.func_name(1,2,3):set("value")
70 -- value = channel.func_name(1,2,3):get()
72 -- channel["func_name(1,2,3)"]:set("value")
73 -- channel["func_name(1,2,3)"] = "value"
74 -- value = channel["func_name(1,2,3)"]:get()
76 -- Note the use of the ':' operator to access the get() and set()
79 -- Also notice the absence of the following constructs from the examples above:
80 -- channel.func_name(1,2,3) = "value" -- this will NOT work
81 -- value = channel.func_name(1,2,3) -- this will NOT work as expected
84 -- Dialplan applications can be accessed through the global 'app' table.
86 -- app.Dial("DAHDI/1")
87 -- app.dial("DAHDI/1")
89 -- More examples can be found below.
91 -- Before starting long running operations, an autoservice should be started
92 -- using the autoservice_start() function. This autoservice will automatically
93 -- be stopped before executing applications and dialplan functions and will be
94 -- restarted afterwards. The autoservice can be stopped using
95 -- autoservice_stop() and the autoservice_status() function will return true if
96 -- an autoservice is currently running.
99 function outgoing_local(c, e)
100 app.dial("DAHDI/1/" .. e, "", "")
103 function demo_instruct()
104 app.background("demo-instruct")
108 function demo_congrats()
109 app.background("demo-congrats")
113 -- Answer the chanel and play the demo sound files
114 function demo_start(context, exten)
118 channel.TIMEOUT("digit"):set(5)
119 channel.TIMEOUT("response"):set(10)
120 -- app.set("TIMEOUT(digit)=5")
121 -- app.set("TIMEOUT(response)=10")
123 demo_congrats(context, exten)
126 function demo_hangup()
127 app.playback("demo-thanks")
136 app.background("demo-moreinfo")
140 channel.LANGUAGE():set("fr") -- set the language to french
144 ["1000"] = function()
145 app.goto("default", "s", 1)
148 ["1234"] = function()
149 app.playback("transfer", "skip")
153 ["1235"] = function()
154 app.voicemail("1234", "u")
157 ["1236"] = function()
158 app.dial("Console/dsp")
159 app.voicemail(1234, "b")
165 app.playback("invalid")
170 app.playback("demo-abouttotry")
171 app.dial("IAX2/guest@misery.digium.com/s@default")
172 app.playback("demo-nogo")
177 app.playback("demo-echotest")
179 app.playback("demo-echodone")
183 ["8500"] = function()
191 -- by default, do the demo
196 ["_NXXXXXX"] = outgoing_local;