extensions.ael 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. //
  2. // Example AEL config file
  3. //
  4. //
  5. // Static extension configuration file, used by
  6. // the pbx_ael module. This is where you configure all your
  7. // inbound and outbound calls in Asterisk.
  8. //
  9. // This configuration file is reloaded
  10. // - With the "ael reload" command in the CLI
  11. // - With the "reload" command (that reloads everything) in the CLI
  12. // The "Globals" category contains global variables that can be referenced
  13. // in the dialplan by using the GLOBAL dialplan function:
  14. // ${GLOBAL(VARIABLE)}
  15. // ${${GLOBAL(VARIABLE)}} or ${text${GLOBAL(VARIABLE)}} or any hybrid
  16. // Unix/Linux environmental variables are reached with the ENV dialplan
  17. // function: ${ENV(VARIABLE)}
  18. //
  19. globals {
  20. CONSOLE="Console/dsp"; // Console interface for demo
  21. //CONSOLE=Zap/1
  22. //CONSOLE=Phone/phone0
  23. IAXINFO=guest; // IAXtel username/password
  24. //IAXINFO="myuser:mypass";
  25. TRUNK="DAHDI/g2"; // Trunk interface
  26. //
  27. // Note the 'g2' in the TRUNK variable above. It specifies which group (defined
  28. // in zapata.conf) to dial, i.e. group 2, and how to choose a channel to use in
  29. // the specified group. The four possible options are:
  30. //
  31. // g: select the lowest-numbered non-busy Zap channel
  32. // (aka. ascending sequential hunt group).
  33. // G: select the highest-numbered non-busy Zap channel
  34. // (aka. descending sequential hunt group).
  35. // r: use a round-robin search, starting at the next highest channel than last
  36. // time (aka. ascending rotary hunt group).
  37. // R: use a round-robin search, starting at the next lowest channel than last
  38. // time (aka. descending rotary hunt group).
  39. //
  40. TRUNKMSD=1; // MSD digits to strip (usually 1 or 0)
  41. //TRUNK=IAX2/user:pass@provider
  42. };
  43. //
  44. // Any category other than "General" and "Globals" represent
  45. // extension contexts, which are collections of extensions.
  46. //
  47. // Extension names may be numbers, letters, or combinations
  48. // thereof. If an extension name is prefixed by a '_'
  49. // character, it is interpreted as a pattern rather than a
  50. // literal. In patterns, some characters have special meanings:
  51. //
  52. // X - any digit from 0-9
  53. // Z - any digit from 1-9
  54. // N - any digit from 2-9
  55. // [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
  56. // . - wildcard, matches anything remaining (e.g. _9011. matches
  57. // anything starting with 9011 excluding 9011 itself)
  58. // ! - wildcard, causes the matching process to complete as soon as
  59. // it can unambiguously determine that no other matches are possible
  60. //
  61. // For example the extension _NXXXXXX would match normal 7 digit dialings,
  62. // while _1NXXNXXXXXX would represent an area code plus phone number
  63. // preceded by a one.
  64. //
  65. // Each step of an extension is ordered by priority, which must
  66. // always start with 1 to be considered a valid extension. The priority
  67. // "next" or "n" means the previous priority plus one, regardless of whether
  68. // the previous priority was associated with the current extension or not.
  69. // The priority "same" or "s" means the same as the previously specified
  70. // priority, again regardless of whether the previous entry was for the
  71. // same extension. Priorities may be immediately followed by a plus sign
  72. // and another integer to add that amount (most useful with 's' or 'n').
  73. // Priorities may then also have an alias, or label, in
  74. // parenthesis after their name which can be used in goto situations
  75. //
  76. // Contexts contain several lines, one for each step of each
  77. // extension, which can take one of two forms as listed below,
  78. // with the first form being preferred. One may include another
  79. // context in the current one as well, optionally with a
  80. // date and time. Included contexts are included in the order
  81. // they are listed.
  82. //
  83. //context name {
  84. // exten-name => {
  85. // application(arg1,arg2,...);
  86. //
  87. // Timing list for includes is
  88. //
  89. // <time range>|<days of week>|<days of month>|<months>
  90. //
  91. // includes {
  92. // daytime|9:00-17:00|mon-fri|*|*;
  93. // };
  94. //
  95. // ignorepat can be used to instruct drivers to not cancel dialtone upon
  96. // receipt of a particular pattern. The most commonly used example is
  97. // of course '9' like this:
  98. //
  99. // ignorepat => 9;
  100. //
  101. // so that dialtone remains even after dialing a 9.
  102. //};
  103. //
  104. // Sample entries for extensions.conf
  105. //
  106. //
  107. context ael-dundi-e164-canonical {
  108. //
  109. // List canonical entries here
  110. //
  111. // 12564286000 => &ael-std-exten(6000,IAX2/foo);
  112. // _125642860XX => Dial(IAX2/otherbox/${EXTEN:7});
  113. };
  114. context ael-dundi-e164-customers {
  115. //
  116. // If you are an ITSP or Reseller, list your customers here.
  117. //
  118. //_12564286000 => Dial(SIP/customer1);
  119. //_12564286001 => Dial(IAX2/customer2);
  120. };
  121. context ael-dundi-e164-via-pstn {
  122. //
  123. // If you are freely delivering calls to the PSTN, list them here
  124. //
  125. //_1256428XXXX => Dial(Zap/g2/${EXTEN:7}); // Expose all of 256-428
  126. //_1256325XXXX => Dial(Zap/g2/${EXTEN:7}); // Ditto for 256-325
  127. };
  128. context ael-dundi-e164-local {
  129. //
  130. // Context to put your dundi IAX2 or SIP user in for
  131. // full access
  132. //
  133. includes {
  134. ael-dundi-e164-canonical;
  135. ael-dundi-e164-customers;
  136. ael-dundi-e164-via-pstn;
  137. };
  138. };
  139. context ael-dundi-e164-switch {
  140. //
  141. // Just a wrapper for the switch
  142. //
  143. switches {
  144. DUNDi/e164;
  145. };
  146. };
  147. context ael-dundi-e164-lookup {
  148. //
  149. // Locally to lookup, try looking for a local E.164 solution
  150. // then try DUNDi if we don't have one.
  151. //
  152. includes {
  153. ael-dundi-e164-local;
  154. ael-dundi-e164-switch;
  155. };
  156. //
  157. };
  158. //
  159. // DUNDi can also be implemented as a Macro instead of using
  160. // the Local channel driver.
  161. //
  162. macro ael-dundi-e164(exten) {
  163. //
  164. // ARG1 is the extension to Dial
  165. //
  166. goto ${exten}|1;
  167. return;
  168. };
  169. //
  170. // Here are the entries you need to participate in the IAXTEL
  171. // call routing system. Most IAXTEL numbers begin with 1-700, but
  172. // there are exceptions. For more information, and to sign
  173. // up, please go to www.gnophone.com or www.iaxtel.com
  174. //
  175. context ael-iaxtel700 {
  176. _91700XXXXXXX => Dial(IAX2/${IAXINFO}@iaxtel.com/${EXTEN:1}@iaxtel);
  177. };
  178. //
  179. // The SWITCH statement permits a server to share the dialplan with
  180. // another server. Use with care: Reciprocal switch statements are not
  181. // allowed (e.g. both A -> B and B -> A), and the switched server needs
  182. // to be on-line or else dialing can be severly delayed.
  183. //
  184. context ael-iaxprovider {
  185. switches {
  186. // IAX2/user:[key]@myserver/mycontext;
  187. };
  188. };
  189. context ael-trunkint {
  190. //
  191. // International long distance through trunk
  192. //
  193. includes {
  194. ael-dundi-e164-lookup;
  195. };
  196. _9011. => {
  197. &ael-dundi-e164(${EXTEN:4});
  198. Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  199. };
  200. };
  201. context ael-trunkld {
  202. //
  203. // Long distance context accessed through trunk
  204. //
  205. includes {
  206. ael-dundi-e164-lookup;
  207. };
  208. _91NXXNXXXXXX => {
  209. &ael-dundi-e164(${EXTEN:1});
  210. Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  211. };
  212. };
  213. context ael-trunklocal {
  214. //
  215. // Local seven-digit dialing accessed through trunk interface
  216. //
  217. _9NXXXXXX => {
  218. Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  219. };
  220. };
  221. context ael-trunktollfree {
  222. //
  223. // Long distance context accessed through trunk interface
  224. //
  225. _91800NXXXXXX => Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  226. _91888NXXXXXX => Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  227. _91877NXXXXXX => Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  228. _91866NXXXXXX => Dial(${TRUNK}/${EXTEN:${TRUNKMSD}});
  229. };
  230. context ael-international {
  231. //
  232. // Master context for international long distance
  233. //
  234. ignorepat => 9;
  235. includes {
  236. ael-longdistance;
  237. ael-trunkint;
  238. };
  239. };
  240. context ael-longdistance {
  241. //
  242. // Master context for long distance
  243. //
  244. ignorepat => 9;
  245. includes {
  246. ael-local;
  247. ael-trunkld;
  248. };
  249. };
  250. context ael-local {
  251. //
  252. // Master context for local, toll-free, and iaxtel calls only
  253. //
  254. ignorepat => 9;
  255. includes {
  256. ael-default;
  257. ael-trunklocal;
  258. ael-iaxtel700;
  259. ael-trunktollfree;
  260. ael-iaxprovider;
  261. };
  262. };
  263. //
  264. // You can use an alternative switch type as well, to resolve
  265. // extensions that are not known here, for example with remote
  266. // IAX switching you transparently get access to the remote
  267. // Asterisk PBX
  268. //
  269. // switch => IAX2/user:password@bigserver/local
  270. //
  271. // An "lswitch" is like a switch but is literal, in that
  272. // variable substitution is not performed at load time
  273. // but is passed to the switch directly (presumably to
  274. // be substituted in the switch routine itself)
  275. //
  276. // lswitch => Loopback/12${EXTEN}@othercontext
  277. //
  278. // An "eswitch" is like a switch but the evaluation of
  279. // variable substitution is performed at runtime before
  280. // being passed to the switch routine.
  281. //
  282. // eswitch => IAX2/context@${CURSERVER}
  283. macro ael-std-exten-ael( ext , dev ) {
  284. Dial(${dev}/${ext},20);
  285. switch(${DIALSTATUS}) {
  286. case BUSY:
  287. Voicemail(${ext},b);
  288. break;
  289. default:
  290. Voicemail(${ext},u);
  291. };
  292. catch a {
  293. VoiceMailMain(${ext});
  294. return;
  295. };
  296. return;
  297. };
  298. context ael-demo {
  299. s => {
  300. Wait(1);
  301. Answer();
  302. Set(TIMEOUT(digit)=5);
  303. Set(TIMEOUT(response)=10);
  304. restart:
  305. Background(demo-congrats);
  306. instructions:
  307. for (x=0; ${x} < 3; x=${x} + 1) {
  308. Background(demo-instruct);
  309. WaitExten();
  310. };
  311. };
  312. 2 => {
  313. Background(demo-moreinfo);
  314. goto s|instructions;
  315. };
  316. 3 => {
  317. Set(LANGUAGE()=fr);
  318. goto s|restart;
  319. };
  320. 1000 => {
  321. goto ael-default|s|1;
  322. };
  323. 500 => {
  324. Playback(demo-abouttotry);
  325. Dial(IAX2/guest@misery.digium.com/s@default);
  326. Playback(demo-nogo);
  327. goto s|instructions;
  328. };
  329. 600 => {
  330. Playback(demo-echotest);
  331. Echo();
  332. Playback(demo-echodone);
  333. goto s|instructions;
  334. };
  335. _1234 => &ael-std-exten-ael(${EXTEN}, "IAX2");
  336. 8500 => {
  337. VoicemailMain();
  338. goto s|instructions;
  339. };
  340. # => {
  341. Playback(demo-thanks);
  342. Hangup();
  343. };
  344. t => goto #|1;
  345. i => Playback(invalid);
  346. };
  347. //
  348. // If you wish to use AEL for your default context, remove it
  349. // from extensions.conf (or change its name or comment it out)
  350. // and then uncomment the one here.
  351. //
  352. context ael-default {
  353. // By default we include the demo. In a production system, you
  354. // probably don't want to have the demo there.
  355. includes {
  356. ael-demo;
  357. };
  358. //
  359. // Extensions like the two below can be used for FWD, Nikotel, sipgate etc.
  360. // Note that you must have a [sipprovider] section in sip.conf whereas
  361. // the otherprovider.net example does not require such a peer definition
  362. //
  363. //_41X. => Dial(SIP/${EXTEN:2}@sipprovider,,r);
  364. //_42X. => Dial(SIP/user:passwd@${EXTEN:2}@otherprovider.net,30,rT);
  365. // Real extensions would go here. Generally you want real extensions to be
  366. // 4 or 5 digits long (although there is no such requirement) and start with a
  367. // single digit that is fairly large (like 6 or 7) so that you have plenty of
  368. // room to overlap extensions and menu options without conflict. You can alias
  369. // them with names, too, and use global variables
  370. // 6245 => {
  371. // hint(SIP/Grandstream1&SIP/Xlite1,Joe Schmoe); // Channel hints for presence
  372. // Dial(SIP/Grandstream1,20,rt); // permit transfer
  373. // Dial(${HINT}/5245},20,rtT); // Use hint as listed
  374. // switch(${DIALSTATUS}) {
  375. // case BUSY:
  376. // Voicemail(6245,b);
  377. // return;
  378. // default:
  379. // Voicemail(6245,u);
  380. // return;
  381. // };
  382. // };
  383. // 6361 => Dial(IAX2/JaneDoe,,rm); // ring without time limit
  384. // 6389 => Dial(MGCP/aaln/1@192.168.0.14);
  385. // 6394 => Dial(Local/6275/n); // this will dial ${MARK}
  386. // 6275 => &ael-stdexten(6275,${MARK}); // assuming ${MARK} is something like Zap/2
  387. // mark => goto 6275|1; // alias mark to 6275
  388. // 6536 => &ael-stdexten(6236,${WIL}); // Ditto for wil
  389. // wil => goto 6236|1;
  390. //
  391. // Some other handy things are an extension for checking voicemail via
  392. // voicemailmain
  393. //
  394. // 8500 => {
  395. // VoicemailMain();
  396. // Hangup();
  397. // };
  398. //
  399. // Or a conference room (you'll need to edit meetme.conf to enable this room)
  400. //
  401. // 8600 => Meetme(1234);
  402. //
  403. // Or playing an announcement to the called party, as soon it answers
  404. //
  405. // 8700 => Dial(${MARK},30,A(/path/to/my/announcemsg))
  406. //
  407. // For more information on applications, just type "show applications" at your
  408. // friendly Asterisk CLI prompt.
  409. //
  410. // 'show application <command>' will show details of how you
  411. // use that particular application in this file, the dial plan.
  412. //
  413. }