aboutsummaryrefslogtreecommitdiffstats
path: root/configs/extensions.ael.sample
blob: 18de98fbc59fb0235a3da7396e43e8feeb1b11f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
//
// Example AEL config file
//
//
// Static extension configuration file, used by
// the pbx_ael module. This is where you configure all your 
// inbound and outbound calls in Asterisk. 
// 
// This configuration file is reloaded 
// - With the "ael reload" command in the CLI
// - With the "reload" command (that reloads everything) in the CLI

// The "Globals" category contains global variables that can be referenced
// in the dialplan by using the GLOBAL dialplan function:
//  ${GLOBAL(VARIABLE)} 
// ${${GLOBAL(VARIABLE)}} or ${text${GLOBAL(VARIABLE)}} or any hybrid
// Unix/Linux environmental variables are reached with the ENV dialplan
// function: ${ENV(VARIABLE)}
//

// NOTE! NOTE! NOTE!
// Asterisk by default will load both extensions.conf and extensions.ael files.
// Upon loading these files the dialplans generated from both with be merged,
// so you must make sure that you don't have any overlapping contexts or global
// variables. If you do, then unexpected behavior may result when the data is
// merged.
// NOTE! NOTE! NOTE!

globals {
	CONSOLE="Console/dsp"; 		// Console interface for demo
	//CONSOLE=Zap/1
	//CONSOLE=Phone/phone0
	IAXINFO=guest;				// IAXtel username/password
	//IAXINFO="myuser:mypass";
	OUTBOUND-TRUNK="Zap/g2";		// Trunk interface
	//
	// Note the 'g2' in the OUTBOUND-TRUNK variable above. It specifies which group (defined
	// in chan_dahdi.conf) to dial, i.e. group 2, and how to choose a channel to use in
	// the specified group. The four possible options are:
	//
	// g: select the lowest-numbered non-busy Zap channel
	//    (aka. ascending sequential hunt group).
	// G: select the highest-numbered non-busy Zap channel
	//    (aka. descending sequential hunt group).
	// r: use a round-robin search, starting at the next highest channel than last
	//    time (aka. ascending rotary hunt group).
	// R: use a round-robin search, starting at the next lowest channel than last
	//    time (aka. descending rotary hunt group).
	//
	OUTBOUND-TRUNKMSD=1;					// MSD digits to strip (usually 1 or 0)
	//TRUNK=IAX2/user:pass@provider
};

//
// Any category other than "General" and "Globals" represent 
// extension contexts, which are collections of extensions.  
//
// Extension names may be numbers, letters, or combinations
// thereof. If an extension name is prefixed by a '_'
// character, it is interpreted as a pattern rather than a
// literal.  In patterns, some characters have special meanings:
//
//   X - any digit from 0-9
//   Z - any digit from 1-9
//   N - any digit from 2-9
//   [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
//   . - wildcard, matches anything remaining (e.g. _9011. matches 
//	anything starting with 9011 excluding 9011 itself)
//   ! - wildcard, causes the matching process to complete as soon as
//       it can unambiguously determine that no other matches are possible
//
// For example the extension _NXXXXXX would match normal 7 digit dialings, 
// while _1NXXNXXXXXX would represent an area code plus phone number
// preceded by a one.
//
// Each step of an extension is ordered by priority, which must
// always start with 1 to be considered a valid extension.  The priority
// "next" or "n" means the previous priority plus one, regardless of whether
// the previous priority was associated with the current extension or not.
// The priority "same" or "s" means the same as the previously specified
// priority, again regardless of whether the previous entry was for the
// same extension.  Priorities may be immediately followed by a plus sign
// and another integer to add that amount (most useful with 's' or 'n').  
// Priorities may then also have an alias, or label, in 
// parenthesis after their name which can be used in goto situations
//
// Contexts contain several lines, one for each step of each
// extension, which can take one of two forms as listed below,
// with the first form being preferred.  One may include another
// context in the current one as well, optionally with a
// date and time.  Included contexts are included in the order
// they are listed.
//
//context name {
//	exten-name => {
//		application(arg1,arg2,...);
//
// 	Timing list for includes is 
//
//   <time range>|<days of week>|<days of month>|<months>
//
//	includes { 
//		daytime|9:00-17:00|mon-fri|*|*;
//      };
//
// 	ignorepat can be used to instruct drivers to not cancel dialtone upon
// 	receipt of a particular pattern.  The most commonly used example is
// 	of course '9' like this:
//
//	ignorepat => 9;
//
// 	so that dialtone remains even after dialing a 9.
//};


//
// Sample entries for extensions.conf
//
//
context ael-dundi-e164-canonical {
	//
	// List canonical entries here
	//
	// 12564286000 => &ael-std-exten(6000,IAX2/foo);
	// _125642860XX => Dial(IAX2/otherbox/${EXTEN:7});
};

context ael-dundi-e164-customers {
	//
	// If you are an ITSP or Reseller, list your customers here.
	//
	//_12564286000 => Dial(SIP/customer1);
	//_12564286001 => Dial(IAX2/customer2);
};

context ael-dundi-e164-via-pstn {
	//
	// If you are freely delivering calls to the PSTN, list them here
	//
	//_1256428XXXX => Dial(Zap/g2/${EXTEN:7}); // Expose all of 256-428 
	//_1256325XXXX => Dial(Zap/g2/${EXTEN:7}); // Ditto for 256-325
};

context ael-dundi-e164-local {
	//
	// Context to put your dundi IAX2 or SIP user in for
	// full access
	//
	includes {
	 ael-dundi-e164-canonical;
	 ael-dundi-e164-customers;
	 ael-dundi-e164-via-pstn;
	};
};

context ael-dundi-e164-switch {
	//
	// Just a wrapper for the switch
	//
	
	switches { 
		DUNDi/e164;
	};
};

context ael-dundi-e164-lookup {
	//
	// Locally to lookup, try looking for a local E.164 solution
	// then try DUNDi if we don't have one.
	//
	includes {
		ael-dundi-e164-local;
		ael-dundi-e164-switch;
	};
	//
};

//
// DUNDi can also be implemented as a Macro instead of using 
// the Local channel driver. 
//
macro ael-dundi-e164(exten) {
//
// ARG1 is the extension to Dial
//
	goto ${exten}|1;
	return;
};

//
// Here are the entries you need to participate in the IAXTEL
// call routing system.  Most IAXTEL numbers begin with 1-700, but
// there are exceptions.  For more information, and to sign
// up, please go to www.gnophone.com or www.iaxtel.com
//
context ael-iaxtel700 {
	_91700XXXXXXX => Dial(IAX2/${IAXINFO}@iaxtel.com/${EXTEN:1}@iaxtel);
};

//
// The SWITCH statement permits a server to share the dialplan with
// another server. Use with care: Reciprocal switch statements are not
// allowed (e.g. both A -> B and B -> A), and the switched server needs
// to be on-line or else dialing can be severly delayed.
//
context ael-iaxprovider {
	switches {
	// IAX2/user:[key]@myserver/mycontext;
	};
};

context ael-trunkint {
	//
	// International long distance through trunk
	//
	includes {
		ael-dundi-e164-lookup;
	};
	_9011. => {
		&ael-dundi-e164(${EXTEN:4});
		Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
	};
};

context ael-trunkld {
	//
	// Long distance context accessed through trunk
	//
	includes {
		ael-dundi-e164-lookup;
	};
	_91NXXNXXXXXX => {
		&ael-dundi-e164(${EXTEN:1});
		Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
	};
};

context ael-trunklocal {
	//
	// Local seven-digit dialing accessed through trunk interface
	//
	_9NXXXXXX => {
		Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
	};
};

context ael-trunktollfree {
	//
	// Long distance context accessed through trunk interface
	//
	
	_91800NXXXXXX => Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
	_91888NXXXXXX => Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
	_91877NXXXXXX => Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
	_91866NXXXXXX => Dial(${OUTBOUND-TRUNK}/${EXTEN:${OUTBOUND-TRUNKMSD}});
};

context ael-international {
	//
	// Master context for international long distance
	//
	ignorepat => 9;
	includes {
		ael-longdistance;
		ael-trunkint;
	};
};

context ael-longdistance {
	//
	// Master context for long distance
	//
	ignorepat => 9;
	includes {
		ael-local;
		ael-trunkld;
	};
};

context ael-local {
	//
	// Master context for local, toll-free, and iaxtel calls only
	//
	ignorepat => 9;
	includes {
		ael-default;
		ael-trunklocal;
		ael-iaxtel700;
		ael-trunktollfree;
		ael-iaxprovider;
	};
};

//
// You can use an alternative switch type as well, to resolve
// extensions that are not known here, for example with remote 
// IAX switching you transparently get access to the remote
// Asterisk PBX
// 
// switch => IAX2/user:password@bigserver/local
//
// An "lswitch" is like a switch but is literal, in that
// variable substitution is not performed at load time
// but is passed to the switch directly (presumably to
// be substituted in the switch routine itself)
//
// lswitch => Loopback/12${EXTEN}@othercontext
//
// An "eswitch" is like a switch but the evaluation of
// variable substitution is performed at runtime before
// being passed to the switch routine.
//
// eswitch => IAX2/context@${CURSERVER}


macro ael-std-exten-ael( ext , dev ) {
        Dial(${dev}/${ext},20);
        switch(${DIALSTATUS}) {
        case BUSY:
                Voicemail(${ext},b);
                break;
        default:
                Voicemail(${ext},u);
        };
        catch a {
                VoiceMailMain(${ext});
                return;
        };
	return;
};

context ael-demo {
	s => {
		Wait(1);
		Answer();
		Set(TIMEOUT(digit)=5);
		Set(TIMEOUT(response)=10);
restart:
		Background(demo-congrats);
instructions:
		for (x=0; ${x} < 3; x=${x} + 1) {
			Background(demo-instruct);
			WaitExten();
		};
	};
	2 => {
		Background(demo-moreinfo);
		goto s|instructions;
	};
	3 => {
		Set(LANGUAGE()=fr);
		goto s|restart;
	};
	1000 => {
		goto ael-default|s|1;
	};
	500 => {
		Playback(demo-abouttotry);
		Dial(IAX2/guest@misery.digium.com/s@default);
		Playback(demo-nogo);
		goto s|instructions;
	};
	600 => {
		Playback(demo-echotest);
		Echo();
		Playback(demo-echodone);
		goto s|instructions;
	};
	_1234 => &ael-std-exten-ael(${EXTEN}, "IAX2");
	8500 => {
		VoicemailMain();
		goto s|instructions;
	};
	# => {
		Playback(demo-thanks);
		Hangup();
	};
	t => goto #|1;
	i => Playback(invalid);
};


//
// If you wish to use AEL for your default context, remove it
// from extensions.conf (or change its name or comment it out)
// and then uncomment the one here.
//

context ael-default {

// By default we include the demo.  In a production system, you 
// probably don't want to have the demo there.

	includes {
		ael-demo;
	};
//
// Extensions like the two below can be used for FWD, Nikotel, sipgate etc.
// Note that you must have a [sipprovider] section in sip.conf whereas
// the otherprovider.net example does not require such a peer definition
//
//_41X. => Dial(SIP/${EXTEN:2}@sipprovider,,r);
//_42X. => Dial(SIP/user:passwd@${EXTEN:2}@otherprovider.net,30,rT);

// Real extensions would go here. Generally you want real extensions to be
// 4 or 5 digits long (although there is no such requirement) and start with a
// single digit that is fairly large (like 6 or 7) so that you have plenty of
// room to overlap extensions and menu options without conflict.  You can alias
// them with names, too, and use global variables

// 6245  => {
//		hint(SIP/Grandstream1&SIP/Xlite1,Joe Schmoe); // Channel hints for presence
// 		Dial(SIP/Grandstream1,20,rt);                 // permit transfer
//        Dial(${HINT}/5245},20,rtT);                    // Use hint as listed
//        switch(${DIALSTATUS}) {
//        case BUSY:
//                Voicemail(6245,b);
//				return;
//        default:
//                Voicemail(6245,u);
//				return;
//        };
//       };

// 6361 => Dial(IAX2/JaneDoe,,rm);                // ring without time limit
// 6389 => Dial(MGCP/aaln/1@192.168.0.14);
// 6394 => Dial(Local/6275/n);                    // this will dial ${MARK}

// 6275 => &ael-stdexten(6275,${MARK});           // assuming ${MARK} is something like Zap/2
// mark => goto 6275|1;                          // alias mark to 6275
// 6536 => &ael-stdexten(6236,${WIL});            // Ditto for wil
// wil  => goto 6236|1;
//
// Some other handy things are an extension for checking voicemail via
// voicemailmain
//
// 8500 => {
//			VoicemailMain();
//			Hangup();
//	       };
//
// Or a conference room (you'll need to edit meetme.conf to enable this room)
//
// 8600 => Meetme(1234);
//
// Or playing an announcement to the called party, as soon it answers
//
// 8700 => Dial(${MARK},30,A(/path/to/my/announcemsg))
//
// For more information on applications, just type "show applications" at your
// friendly Asterisk CLI prompt.
//
// 'show application <command>' will show details of how you
// use that particular application in this file, the dial plan. 
//
}