| 1 |
; extensions.conf - the Asterisk dial plan |
| 2 |
; |
| 3 |
; Static extension configuration file, used by |
| 4 |
; the pbx_config module. This is where you configure all your |
| 5 |
; inbound and outbound calls in Asterisk. |
| 6 |
; |
| 7 |
; This configuration file is reloaded |
| 8 |
; - With the "dialplan reload" command in the CLI |
| 9 |
; - With the "reload" command (that reloads everything) in the CLI |
| 10 |
|
| 11 |
; |
| 12 |
; The "General" category is for certain variables. |
| 13 |
; |
| 14 |
[general] |
| 15 |
; |
| 16 |
; If static is set to no, or omitted, then the pbx_config will rewrite |
| 17 |
; this file when extensions are modified. Remember that all comments |
| 18 |
; made in the file will be lost when that happens. |
| 19 |
; |
| 20 |
; XXX Not yet implemented XXX |
| 21 |
; |
| 22 |
static=yes |
| 23 |
; |
| 24 |
; if static=yes and writeprotect=no, you can save dialplan by |
| 25 |
; CLI command "dialplan save" too |
| 26 |
; |
| 27 |
writeprotect=no |
| 28 |
; |
| 29 |
; If autofallthrough is set, then if an extension runs out of |
| 30 |
; things to do, it will terminate the call with BUSY, CONGESTION |
| 31 |
; or HANGUP depending on Asterisk's best guess. This is the default. |
| 32 |
; |
| 33 |
; If autofallthrough is not set, then if an extension runs out of |
| 34 |
; things to do, Asterisk will wait for a new extension to be dialed |
| 35 |
; (this is the original behavior of Asterisk 1.0 and earlier). |
| 36 |
; |
| 37 |
;autofallthrough=no |
| 38 |
; |
| 39 |
; |
| 40 |
; |
| 41 |
; If extenpatternmatchnew is set (true, yes, etc), then a new algorithm that uses |
| 42 |
; a Trie to find the best matching pattern is used. In dialplans |
| 43 |
; with more than about 20-40 extensions in a single context, this |
| 44 |
; new algorithm can provide a noticeable speedup. |
| 45 |
; With 50 extensions, the speedup is 1.32x |
| 46 |
; with 88 extensions, the speedup is 2.23x |
| 47 |
; with 138 extensions, the speedup is 3.44x |
| 48 |
; with 238 extensions, the speedup is 5.8x |
| 49 |
; with 438 extensions, the speedup is 10.4x |
| 50 |
; With 1000 extensions, the speedup is ~25x |
| 51 |
; with 10,000 extensions, the speedup is 374x |
| 52 |
; Basically, the new algorithm provides a flat response |
| 53 |
; time, no matter the number of extensions. |
| 54 |
; |
| 55 |
; By default, the old pattern matcher is used. |
| 56 |
; |
| 57 |
; ****This is a new feature! ********************* |
| 58 |
; The new pattern matcher is for the brave, the bold, and |
| 59 |
; the desperate. If you have large dialplans (more than about 50 extensions |
| 60 |
; in a context), and/or high call volume, you might consider setting |
| 61 |
; this value to "yes" !! |
| 62 |
; Please, if you try this out, and are forced to return to the |
| 63 |
; old pattern matcher, please report your reasons in a bug report |
| 64 |
; on https://github.com/asterisk/asterisk/issues. We have made good |
| 65 |
; progress in providing something compatible with the old matcher; help us |
| 66 |
; finish the job! |
| 67 |
; |
| 68 |
; This value can be switched at runtime using the cli command "dialplan set extenpatternmatchnew true" |
| 69 |
; or "dialplan set extenpatternmatchnew false", so you can experiment to your hearts content. |
| 70 |
; |
| 71 |
;extenpatternmatchnew=no |
| 72 |
; |
| 73 |
; If clearglobalvars is set, global variables will be cleared |
| 74 |
; and reparsed on a dialplan reload, or Asterisk reload. |
| 75 |
; |
| 76 |
; If clearglobalvars is not set, then global variables will persist |
| 77 |
; through reloads, and even if deleted from the extensions.conf or |
| 78 |
; one of its included files, will remain set to the previous value. |
| 79 |
; |
| 80 |
; NOTE: A complication sets in, if you put your global variables into |
| 81 |
; the AEL file, instead of the extensions.conf file. With clearglobalvars |
| 82 |
; set, a "reload" will often leave the globals vars cleared, because it |
| 83 |
; is not unusual to have extensions.conf (which will have no globals) |
| 84 |
; load after the extensions.ael file (where the global vars are stored). |
| 85 |
; So, with "reload" in this particular situation, first the AEL file will |
| 86 |
; clear and then set all the global vars, then, later, when the extensions.conf |
| 87 |
; file is loaded, the global vars are all cleared, and then not set, because |
| 88 |
; they are not stored in the extensions.conf file. |
| 89 |
; |
| 90 |
clearglobalvars=no |
| 91 |
; |
| 92 |
; User context is where entries from users.conf are registered. The |
| 93 |
; default value is 'default' |
| 94 |
; |
| 95 |
;userscontext=default |
| 96 |
; |
| 97 |
; You can include other config files, use the #include command |
| 98 |
; (without the ';'). Note that this is different from the "include" command |
| 99 |
; that includes contexts within other contexts. The #include command works |
| 100 |
; in all asterisk configuration files. |
| 101 |
;#include "filename.conf" |
| 102 |
;#include <filename.conf> |
| 103 |
;#include filename.conf |
| 104 |
; |
| 105 |
; You can execute a program or script that produces config files, and they |
| 106 |
; will be inserted where you insert the #exec command. The #exec command |
| 107 |
; works on all asterisk configuration files. However, you will need to |
| 108 |
; activate them within asterisk.conf with the "execincludes" option. They |
| 109 |
; are otherwise considered a security risk. |
| 110 |
;#exec /opt/bin/build-extra-contexts.sh |
| 111 |
;#exec /opt/bin/build-extra-contexts.sh --foo="bar" |
| 112 |
;#exec </opt/bin/build-extra-contexts.sh --foo="bar"> |
| 113 |
;#exec "/opt/bin/build-extra-contexts.sh --foo=\"bar\"" |
| 114 |
; |
| 115 |
|
| 116 |
; The "Globals" category contains global variables that can be referenced |
| 117 |
; in the dialplan with the GLOBAL dialplan function: |
| 118 |
; ${GLOBAL(VARIABLE)} |
| 119 |
; ${${GLOBAL(VARIABLE)}} or ${text${GLOBAL(VARIABLE)}} or any hybrid |
| 120 |
; Unix/Linux environmental variables can be reached with the ENV dialplan |
| 121 |
; function: ${ENV(VARIABLE)} |
| 122 |
; |
| 123 |
[globals] |
| 124 |
CONSOLE=Console/dsp ; Console interface for demo |
| 125 |
;CONSOLE=DAHDI/1 |
| 126 |
;CONSOLE=Phone/phone0 |
| 127 |
TRUNK=DAHDI/G2 ; Trunk interface |
| 128 |
; |
| 129 |
; Note the 'G2' in the TRUNK variable above. It specifies which group (defined |
| 130 |
; in chan_dahdi.conf) to dial, i.e. group 2, and how to choose a channel to use |
| 131 |
; in the specified group. The four possible options are: |
| 132 |
; |
| 133 |
; g: select the lowest-numbered non-busy DAHDI channel |
| 134 |
; (aka. ascending sequential hunt group). |
| 135 |
; G: select the highest-numbered non-busy DAHDI channel |
| 136 |
; (aka. descending sequential hunt group). |
| 137 |
; r: use a round-robin search, starting at the next highest channel than last |
| 138 |
; time (aka. ascending rotary hunt group). |
| 139 |
; R: use a round-robin search, starting at the next lowest channel than last |
| 140 |
; time (aka. descending rotary hunt group). |
| 141 |
; |
| 142 |
TRUNKMSD=1 ; MSD digits to strip (usually 1 or 0) |
| 143 |
;TRUNK=IAX2/user:pass@provider |
| 144 |
|
| 145 |
;FREENUMDOMAIN=mydomain.com ; domain to send on outbound |
| 146 |
; freenum calls (uses outbound-freenum |
| 147 |
; context) |
| 148 |
|
| 149 |
; |
| 150 |
; WARNING WARNING WARNING WARNING |
| 151 |
; If you load any other extension configuration engine, such as pbx_ael.so, |
| 152 |
; your global variables may be overridden by that file. Please take care to |
| 153 |
; use only one location to set global variables, and you will likely save |
| 154 |
; yourself a ton of grief. |
| 155 |
; WARNING WARNING WARNING WARNING |
| 156 |
; |
| 157 |
; Any category other than "General" and "Globals" represent |
| 158 |
; extension contexts, which are collections of extensions. |
| 159 |
; |
| 160 |
; Extension names may be numbers, letters, or combinations |
| 161 |
; thereof. If an extension name is prefixed by a '_' |
| 162 |
; character, it is interpreted as a pattern rather than a |
| 163 |
; literal. In patterns, some characters have special meanings: |
| 164 |
; |
| 165 |
; X - any digit from 0-9 |
| 166 |
; Z - any digit from 1-9 |
| 167 |
; N - any digit from 2-9 |
| 168 |
; [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9) |
| 169 |
; . - wildcard, matches anything remaining (e.g. _9011. matches |
| 170 |
; anything starting with 9011 excluding 9011 itself) |
| 171 |
; ! - wildcard, causes the matching process to complete as soon as |
| 172 |
; it can unambiguously determine that no other matches are possible |
| 173 |
; |
| 174 |
; For example, the extension _NXXXXXX would match normal 7 digit dialings, |
| 175 |
; while _1NXXNXXXXXX would represent an area code plus phone number |
| 176 |
; preceded by a one. |
| 177 |
; |
| 178 |
; Each step of an extension is ordered by priority, which must always start |
| 179 |
; with 1 to be considered a valid extension. The priority "next" or "n" means |
| 180 |
; the previous priority plus one, regardless of whether the previous priority |
| 181 |
; was associated with the current extension or not. The priority "same" or "s" |
| 182 |
; means the same as the previously specified priority, again regardless of |
| 183 |
; whether the previous entry was for the same extension. Priorities may be |
| 184 |
; immediately followed by a plus sign and another integer to add that amount |
| 185 |
; (most useful with 's' or 'n'). Priorities may then also have an alias, or |
| 186 |
; label, in parentheses after their name which can be used in goto situations. |
| 187 |
; |
| 188 |
; Contexts contain several lines, one for each step of each extension. One may |
| 189 |
; include another context in the current one as well, optionally with a date |
| 190 |
; and time. Included contexts are included in the order they are listed. |
| 191 |
; Switches may also be included within a context. The order of matching within |
| 192 |
; a context is always exact extensions, pattern match extensions, includes, and |
| 193 |
; switches. Includes are always processed depth-first. So for example, if you |
| 194 |
; would like a switch "A" to match before context "B", simply put switch "A" in |
| 195 |
; an included context "C", where "C" is included in your original context |
| 196 |
; before "B". |
| 197 |
; |
| 198 |
;[context] |
| 199 |
; |
| 200 |
;autohints = yes |
| 201 |
; If enabled for a context, a device state hint will be automatically created in |
| 202 |
; the context with the name of the device and updated with device state changes. |
| 203 |
; |
| 204 |
;exten => someexten,{priority|label{+|-}offset}[(alias)],application(arg1,arg2,...) |
| 205 |
; |
| 206 |
; Timing list for includes is |
| 207 |
; |
| 208 |
; <time range>,<days of week>,<days of month>,<months>[,<timezone>] |
| 209 |
; |
| 210 |
; Note that ranges may be specified to wrap around the ends. Also, minutes are |
| 211 |
; fine-grained only down to the closest even minute. |
| 212 |
; |
| 213 |
;include => daytime,9:00-17:00,mon-fri,*,* |
| 214 |
;include => weekend,*,sat-sun,*,* |
| 215 |
;include => weeknights,17:02-8:58,mon-fri,*,* |
| 216 |
; |
| 217 |
; ignorepat can be used to instruct drivers to not cancel dialtone upon receipt |
| 218 |
; of a particular pattern. The most commonly used example is of course '9' |
| 219 |
; like this: |
| 220 |
; |
| 221 |
;ignorepat => 9 |
| 222 |
; |
| 223 |
; so that dialtone remains even after dialing a 9. Please note that ignorepat |
| 224 |
; only works with channels which receive dialtone from the PBX, such as DAHDI, |
| 225 |
; Phone, and VPB. Other channels, such as IAX2, PJSIP, and SIP, which generate |
| 226 |
; generate their own dialtone and converse with the PBX only after a number is |
| 227 |
; complete, are generally unaffected by ignorepat (unless DISA or another method |
| 228 |
; is used to generate a dialtone after answering the channel). |
| 229 |
; |
| 230 |
|
| 231 |
; |
| 232 |
; Sample entries for extensions.conf |
| 233 |
; |
| 234 |
; |
| 235 |
[dundi-e164-canonical] |
| 236 |
;include => stdexten |
| 237 |
; |
| 238 |
; List canonical entries here |
| 239 |
; |
| 240 |
;exten => 12564286000,1,Gosub(6000,stdexten(IAX2/foo)) |
| 241 |
;exten => 12564286000,n,Goto(default,s,1) ; exited Voicemail |
| 242 |
;exten => _125642860XX,1,Dial(IAX2/otherbox/${EXTEN:7}) |
| 243 |
;exten => _125642861XX,1,Dial(IAX2/[email protected]/${EXTEN:7}) |
| 244 |
;exten => _125642862XX,1,Dial(IAX2/user:[email protected]/${EXTEN:7}) |
| 245 |
;exten => _125642863XX,1,Dial(IAX2/user:secret:[outkey]@example.com/${EXTEN:7}) |
| 246 |
|
| 247 |
[dundi-e164-customers] |
| 248 |
; |
| 249 |
; If you are an ITSP or Reseller, list your customers here. |
| 250 |
; |
| 251 |
;exten => _12564286000,1,Dial(PJSIP/customer1) |
| 252 |
;exten => _12564286001,1,Dial(IAX2/customer2) |
| 253 |
|
| 254 |
[dundi-e164-via-pstn] |
| 255 |
; |
| 256 |
; If you are freely delivering calls to the PSTN, list them here |
| 257 |
; |
| 258 |
;exten => _1256428XXXX,1,Dial(DAHDI/G2/${EXTEN:7}) ; Expose all of 256-428 |
| 259 |
;exten => _1256325XXXX,1,Dial(DAHDI/G2/${EXTEN:7}) ; Ditto for 256-325 |
| 260 |
|
| 261 |
[dundi-e164-local] |
| 262 |
; |
| 263 |
; Context to put your dundi IAX2 or SIP user in for |
| 264 |
; full access |
| 265 |
; |
| 266 |
include => dundi-e164-canonical |
| 267 |
include => dundi-e164-customers |
| 268 |
include => dundi-e164-via-pstn |
| 269 |
|
| 270 |
[dundi-e164-switch] |
| 271 |
; |
| 272 |
; Just a wrapper for the switch |
| 273 |
; |
| 274 |
switch => DUNDi/e164 |
| 275 |
|
| 276 |
[dundi-e164-lookup] |
| 277 |
; |
| 278 |
; Locally to lookup, try looking for a local E.164 solution |
| 279 |
; then try DUNDi if we don't have one. |
| 280 |
; |
| 281 |
include => dundi-e164-local |
| 282 |
include => dundi-e164-switch |
| 283 |
; |
| 284 |
; DUNDi can also be implemented as a subroutine instead of using |
| 285 |
; the Local channel driver. |
| 286 |
; |
| 287 |
[dundi-e164] |
| 288 |
; |
| 289 |
; ARG1 is the extension to Dial |
| 290 |
; |
| 291 |
; Extension "s" is not a wildcard extension that matches "anything". |
| 292 |
; In most other cases, you have to goto "s" to execute that extension. |
| 293 |
; |
| 294 |
; Note: In old versions of Asterisk the PBX in some cases defaulted to |
| 295 |
; extension "s" when a given extension was wrong (like in AMI originate). |
| 296 |
; This is no longer the case. |
| 297 |
; |
| 298 |
; For wildcard matches, see above - all pattern matches start with |
| 299 |
; an underscore. |
| 300 |
exten => s,1,Goto(${ARG1},1) |
| 301 |
include => dundi-e164-lookup |
| 302 |
|
| 303 |
; |
| 304 |
; Here is how to make a call to another Asterisk server using the IAX2 protocol |
| 305 |
; |
| 306 |
[iax2-trunk] |
| 307 |
exten => _555XXXX,1,Dial(IAX2/username:[email protected]/${EXTEN}@some-dialplan-context) |
| 308 |
|
| 309 |
; |
| 310 |
; The SWITCH statement permits a server to share the dialplan with |
| 311 |
; another server. Use with care: Reciprocal switch statements are not |
| 312 |
; allowed (e.g. both A -> B and B -> A), and the switched server needs |
| 313 |
; to be on-line or else dialing can be severely delayed. |
| 314 |
; |
| 315 |
[iaxprovider] |
| 316 |
;switch => IAX2/user:[key]@myserver/mycontext |
| 317 |
|
| 318 |
[trunkint] |
| 319 |
; |
| 320 |
; International long distance through trunk |
| 321 |
; |
| 322 |
exten => _9011.,1,Gosub(dundi-e164,s,1(${EXTEN:4})) |
| 323 |
; same => n,Hangup() |
| 324 |
exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})}) |
| 325 |
|
| 326 |
[trunkld] |
| 327 |
; |
| 328 |
; Long distance context accessed through trunk |
| 329 |
; |
| 330 |
exten => _91NXXNXXXXXX,1,Gosub(dundi-e164,s,1(${EXTEN:1})) |
| 331 |
exten => _91NXXNXXXXXX,n,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}}) |
| 332 |
|
| 333 |
[trunklocal] |
| 334 |
; |
| 335 |
; Local seven-digit dialing accessed through trunk interface |
| 336 |
; |
| 337 |
exten => _9NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}}) |
| 338 |
|
| 339 |
[trunktollfree] |
| 340 |
; |
| 341 |
; Long distance context accessed through trunk interface |
| 342 |
; |
| 343 |
exten => _91800NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}}) |
| 344 |
exten => _91888NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}}) |
| 345 |
exten => _91877NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}}) |
| 346 |
exten => _91866NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}}) |
| 347 |
|
| 348 |
[international] |
| 349 |
; |
| 350 |
; Master context for international long distance |
| 351 |
; |
| 352 |
ignorepat => 9 |
| 353 |
include => longdistance |
| 354 |
include => trunkint |
| 355 |
|
| 356 |
[longdistance] |
| 357 |
; |
| 358 |
; Master context for long distance |
| 359 |
; |
| 360 |
ignorepat => 9 |
| 361 |
include => local |
| 362 |
include => trunkld |
| 363 |
|
| 364 |
[local] |
| 365 |
; |
| 366 |
; Master context for local and toll-free calls only |
| 367 |
; |
| 368 |
ignorepat => 9 |
| 369 |
include => default |
| 370 |
include => trunklocal |
| 371 |
include => iax2-trunk |
| 372 |
include => trunktollfree |
| 373 |
include => iaxprovider |
| 374 |
|
| 375 |
;Include parkedcalls (or the context you define in features conf) |
| 376 |
;to enable call parking. |
| 377 |
include => parkedcalls |
| 378 |
; |
| 379 |
; You can use an alternative switch type as well, to resolve |
| 380 |
; extensions that are not known here, for example with remote |
| 381 |
; IAX switching you transparently get access to the remote |
| 382 |
; Asterisk PBX |
| 383 |
; |
| 384 |
; switch => IAX2/user:password@bigserver/local |
| 385 |
; |
| 386 |
; An "lswitch" is like a switch but is literal, in that |
| 387 |
; variable substitution is not performed at load time |
| 388 |
; but is passed to the switch directly (presumably to |
| 389 |
; be substituted in the switch routine itself) |
| 390 |
; |
| 391 |
; lswitch => Loopback/12${EXTEN}@othercontext |
| 392 |
; |
| 393 |
; An "eswitch" is like a switch but the evaluation of |
| 394 |
; variable substitution is performed at runtime before |
| 395 |
; being passed to the switch routine. |
| 396 |
; |
| 397 |
; eswitch => IAX2/context@${CURSERVER} |
| 398 |
|
| 399 |
; The following two contexts are a template to enable the ability to dial |
| 400 |
; ISN numbers. For more information about what an ISN number is, please see |
| 401 |
; http://www.freenum.org. |
| 402 |
; |
| 403 |
; This is the dialing hook. use: |
| 404 |
; include => outbound-freenum |
| 405 |
|
| 406 |
[outbound-freenum] |
| 407 |
; We'll add more digits as needed. The purpose is to dial things |
| 408 |
; like extension numbers at domains (ITAD number) so we're matching |
| 409 |
; on lengths of 1 through 6 prior to the separator (the asterisk [*]) |
| 410 |
; |
| 411 |
exten => _X*X!,1,Goto(outbound-freenum2,${EXTEN},1) |
| 412 |
exten => _XX*X!,1,Goto(outbound-freenum2,${EXTEN},1) |
| 413 |
exten => _XXX*X!,1,Goto(outbound-freenum2,${EXTEN},1) |
| 414 |
exten => _XXXX*X!,1,Goto(outbound-freenum2,${EXTEN},1) |
| 415 |
exten => _XXXXX*X!,1,Goto(outbound-freenum2,${EXTEN},1) |
| 416 |
exten => _XXXXXX*X!,1,Goto(outbound-freenum2,${EXTEN},1) |
| 417 |
|
| 418 |
[outbound-freenum2] |
| 419 |
; This is the handler which performs the dialing logic. It is called |
| 420 |
; from the [outbound-freenum] context |
| 421 |
; |
| 422 |
exten => _X!,1,Verbose(2,Performing ISN lookup for ${EXTEN}) |
| 423 |
same => n,Set(SUFFIX=${CUT(EXTEN,*,2-)}) ; make sure the suffix is all digits as well |
| 424 |
same => n,GotoIf($["${FILTER(0-9,${SUFFIX})}" != "${SUFFIX}"]?fn-CONGESTION,1) |
| 425 |
; filter out bad characters per the README-SERIOUSLY.best-practices.txt document |
| 426 |
same => n,Set(TIMEOUT(absolute)=10800) |
| 427 |
same => n,Set(isnresult=${ENUMLOOKUP(${EXTEN},pjsip,,1,freenum.org)}) ; perform our lookup with freenum.org |
| 428 |
same => n,GotoIf($["${isnresult}" != ""]?from) |
| 429 |
same => n,Set(DIALSTATUS=CONGESTION) |
| 430 |
same => n,Goto(fn-CONGESTION,1) |
| 431 |
same => n(from),Set(__SIPFROMUSER=${CALLERID(num)}) |
| 432 |
same => n,GotoIf($["${GLOBAL(FREENUMDOMAIN)}" = ""]?dial) ; check if we set the FREENUMDOMAIN global variable in [global] |
| 433 |
same => n,Set(__SIPFROMDOMAIN=${GLOBAL(FREENUMDOMAIN)}) ; if we did set it, then we'll use it for our outbound dialing domain |
| 434 |
same => n(dial),Dial(PJSIP/${isnresult},40) |
| 435 |
same => n,Goto(fn-${DIALSTATUS},1) |
| 436 |
|
| 437 |
exten => fn-BUSY,1,Busy() |
| 438 |
|
| 439 |
exten => _f[n]-.,1,NoOp(ISN: ${DIALSTATUS}) |
| 440 |
same => n,Congestion() |
| 441 |
|
| 442 |
[trunkdial] |
| 443 |
; |
| 444 |
; Standard trunk dial subroutine (hangs up on a dialstatus that should |
| 445 |
; terminate call) |
| 446 |
; ${ARG1} - What to dial |
| 447 |
; |
| 448 |
exten => s,1,StackPop() |
| 449 |
same => n,Dial(${ARG1}) |
| 450 |
exten => s,n,Goto(s-${DIALSTATUS},1) |
| 451 |
exten => s-NOANSWER,1,Hangup() |
| 452 |
exten => s-BUSY,1,PlayTones(busy) |
| 453 |
same => n,Wait(60) |
| 454 |
same => n,Hangup() |
| 455 |
exten => s-CHANUNAVAIL,1,PlayTones(congestion) |
| 456 |
same => n,Wait(60) |
| 457 |
same => n,Hangup() |
| 458 |
exten => s-CONGESTION,1,PlayTones(congestion) |
| 459 |
same => n,Wait(60) |
| 460 |
same => n,Hangup() |
| 461 |
exten => _s-.,1,NoOp(${DIALSTATUS}) |
| 462 |
same => n,Hangup() |
| 463 |
|
| 464 |
[stdexten] |
| 465 |
; |
| 466 |
; Standard extension subroutine: |
| 467 |
; ${EXTEN} - Extension |
| 468 |
; ${ARG1} - Device(s) to ring |
| 469 |
; ${ARG2} - Optional context in Voicemail |
| 470 |
; |
| 471 |
; Note that the current version will drop through to the next priority in the |
| 472 |
; case of their pressing '#'. This gives more flexibility in what do to next: |
| 473 |
; you can prompt for a new extension, or drop the call, or send them to a |
| 474 |
; general delivery mailbox, or... |
| 475 |
; |
| 476 |
; The use of the LOCAL() function is purely for convenience. Any variable |
| 477 |
; initially declared as LOCAL() will disappear when the innermost Gosub context |
| 478 |
; in which it was declared returns. Note also that you can declare a LOCAL() |
| 479 |
; variable on top of an existing variable, and its value will revert to its |
| 480 |
; previous value (before being declared as LOCAL()) upon Return. |
| 481 |
; |
| 482 |
exten => _X.,50000(stdexten),NoOp(Start stdexten) |
| 483 |
same => n,Set(LOCAL(ext)=${EXTEN}) |
| 484 |
same => n,Set(LOCAL(dev)=${ARG1}) |
| 485 |
same => n,Set(LOCAL(cntx)=${ARG2}) |
| 486 |
same => n,Set(LOCAL(mbx)=${ext}${IF($[!${ISNULL(${cntx})}]?@${cntx})}) |
| 487 |
same => n,Dial(${dev},20) ; Ring the interface, 20 seconds maximum |
| 488 |
same => n,Goto(stdexten-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER) |
| 489 |
|
| 490 |
exten => stdexten-NOANSWER,1,VoiceMail(${mbx},u) ; If unavailable, send to voicemail w/ unavail announce |
| 491 |
same => n,Return() ; If they press #, return to start |
| 492 |
|
| 493 |
exten => stdexten-BUSY,1,VoiceMail(${mbx},b) ; If busy, send to voicemail w/ busy announce |
| 494 |
same => n,Return() ; If they press #, return to start |
| 495 |
|
| 496 |
exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) ; Treat anything else as no answer |
| 497 |
|
| 498 |
exten => a,1,VoiceMailMain(${mbx}) ; If they press *, send the user into VoicemailMain |
| 499 |
exten => a,n,Return() |
| 500 |
|
| 501 |
[stdPrivacyexten] |
| 502 |
; |
| 503 |
; Standard extension subroutine: |
| 504 |
; ${ARG1} - Extension |
| 505 |
; ${ARG2} - Device(s) to ring |
| 506 |
; ${ARG3} - Optional DONTCALL context name to jump to (assumes the s,1 extension-priority) |
| 507 |
; ${ARG4} - Optional TORTURE context name to jump to (assumes the s,1 extension-priority)` |
| 508 |
; ${ARG5} - Context in voicemail (if empty, then "default") |
| 509 |
; |
| 510 |
; See above note in stdexten about priority handling on exit. |
| 511 |
; |
| 512 |
exten => _X.,60000(stdPrivacyexten),NoOp(Start stdPrivacyexten) |
| 513 |
same => n,Set(LOCAL(ext)=${ARG1}) |
| 514 |
same => n,Set(LOCAL(dev)=${ARG2}) |
| 515 |
same => n,Set(LOCAL(dontcntx)=${ARG3}) |
| 516 |
same => n,Set(LOCAL(tortcntx)=${ARG4}) |
| 517 |
same => n,Set(LOCAL(cntx)=${ARG5}) |
| 518 |
|
| 519 |
exten => _X.,n,Set(LOCAL(mbx)="${ext}"$["${cntx}" ? "@${cntx}" :: ""]) |
| 520 |
same => n,Dial(${dev},20,p) ; Ring the interface, 20 seconds maximum, call screening |
| 521 |
; option (or use P for databased call _X.screening) |
| 522 |
same => n,Goto(stdexten-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER) |
| 523 |
|
| 524 |
exten => stdexten-NOANSWER,1,VoiceMail(${mbx},u) ; If unavailable, send to voicemail w/ unavail announce |
| 525 |
same => n,NoOp(Finish stdPrivacyexten NOANSWER) |
| 526 |
same => n,Return() ; If they press #, return to start |
| 527 |
|
| 528 |
exten => stdexten-BUSY,1,VoiceMail(${mbx},b) ; If busy, send to voicemail w/ busy announce |
| 529 |
same => n,NoOp(Finish stdPrivacyexten BUSY) |
| 530 |
same => n,Return() ; If they press #, return to start |
| 531 |
|
| 532 |
exten => stdexten-DONTCALL,1,Goto(${dontcntx},s,1) ; Callee chose to send this call to a polite "Don't call again" script. |
| 533 |
|
| 534 |
exten => stdexten-TORTURE,1,Goto(${tortcntx},s,1) ; Callee chose to send this call to a telemarketer torture script. |
| 535 |
|
| 536 |
exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) ; Treat anything else as no answer |
| 537 |
|
| 538 |
exten => a,1,VoiceMailMain(${mbx}) ; If they press *, send the user into VoicemailMain |
| 539 |
same => n,Return() |
| 540 |
|
| 541 |
[sub-page] |
| 542 |
; |
| 543 |
; Paging subroutine: |
| 544 |
; |
| 545 |
; Check to see if SIP device is in use and DO NOT PAGE if they are |
| 546 |
; |
| 547 |
; ${ARG1} - Device to page |
| 548 |
exten => s,1,ChanIsAvail(${ARG1},s) ; s is for ANY call |
| 549 |
same => n,GotoIf($["${AVAILSTATUS}" = "1"]?autoanswer:fail) |
| 550 |
same => n(autoanswer),Set(_ALERT_INFO="RA") ; This is for the PolyComs |
| 551 |
same => n,SIPAddHeader(Call-Info: Answer-After=0) ; This is for the Grandstream, Snoms, and Others |
| 552 |
same => n,NoOp() ; Add others here and Post on the Docs!!!! |
| 553 |
same => n,Dial(${ARG1}) |
| 554 |
same => n(fail),Hangup() |
| 555 |
|
| 556 |
[demo] |
| 557 |
include => stdexten |
| 558 |
; |
| 559 |
; We start with what to do when a call first comes in. |
| 560 |
; |
| 561 |
exten => s,1,Wait(1) ; Wait a second, just for fun |
| 562 |
same => n,Answer() ; Answer the line |
| 563 |
same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds |
| 564 |
same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds |
| 565 |
same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message |
| 566 |
same => n(instruct),BackGround(demo-instruct) ; Play some instructions |
| 567 |
same => n,WaitExten() ; Wait for an extension to be dialed. |
| 568 |
|
| 569 |
exten => 2,1,BackGround(demo-moreinfo) ; Give some more information. |
| 570 |
exten => 2,n,Goto(s,instruct) |
| 571 |
|
| 572 |
exten => 3,1,Set(CHANNEL(language)=fr) ; Set language to french |
| 573 |
same => n,Goto(s,restart) ; Start with the congratulations |
| 574 |
|
| 575 |
exten => 1000,1,Goto(default,s,1) |
| 576 |
; |
| 577 |
; We also create an example user, 1234, who is on the console and has |
| 578 |
; voicemail, etc. |
| 579 |
; |
| 580 |
exten => 1234,1,Playback(transfer,skip) ; "Please hold while..." |
| 581 |
; (but skip if channel is not up) |
| 582 |
same => n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)})) |
| 583 |
same => n,Goto(default,s,1) ; exited Voicemail |
| 584 |
|
| 585 |
exten => 1235,1,VoiceMail(1234,u) ; Right to voicemail |
| 586 |
|
| 587 |
exten => 1236,1,Dial(Console/dsp) ; Ring forever |
| 588 |
same => n,VoiceMail(1234,b) ; Unless busy |
| 589 |
|
| 590 |
; |
| 591 |
; # for when they're done with the demo |
| 592 |
; |
| 593 |
exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo" |
| 594 |
same => n,Hangup() ; Hang them up. |
| 595 |
|
| 596 |
; |
| 597 |
; A timeout and "invalid extension rule" |
| 598 |
; |
| 599 |
exten => t,1,Goto(#,1) ; If they take too long, give up |
| 600 |
exten => i,1,Playback(invalid) ; "That's not valid, try again" |
| 601 |
|
| 602 |
; |
| 603 |
; Create an extension, 600, for evaluating echo latency. |
| 604 |
; |
| 605 |
exten => 600,1,Playback(demo-echotest) ; Let them know what's going on |
| 606 |
same => n,Echo() ; Do the echo test |
| 607 |
same => n,Playback(demo-echodone) ; Let them know it's over |
| 608 |
same => n,Goto(s,6) ; Start over |
| 609 |
|
| 610 |
; |
| 611 |
; You can use the page subroutine to intercom a individual user |
| 612 |
exten => 76245,1,Gosub(page,s,1(SIP/Grandstream1)) |
| 613 |
; or if your peernames are the same as extensions |
| 614 |
exten => _7XXX,1,Gosub(page,s,1(SIP/${EXTEN})) |
| 615 |
; |
| 616 |
; |
| 617 |
; System Wide Page at extension 7999 |
| 618 |
; |
| 619 |
exten => 7999,1,Set(TIMEOUT(absolute)=60) |
| 620 |
same => n,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d) |
| 621 |
|
| 622 |
; Give voicemail at extension 8500 |
| 623 |
; |
| 624 |
exten => 8500,1,VoiceMailMain() |
| 625 |
same => n,Goto(s,6) |
| 626 |
; |
| 627 |
; Here's what a phone entry would look like (IXJ for example) |
| 628 |
; |
| 629 |
;exten => 1265,1,Dial(Phone/phone0,15) |
| 630 |
; same => n,Goto(s,5) |
| 631 |
|
| 632 |
; |
| 633 |
; The page context calls up the sub-page subroutine that sets variables needed for auto-answer |
| 634 |
; It is in is own context to make calling it from the Page() application as simple as |
| 635 |
; Local/{peername}@page |
| 636 |
; |
| 637 |
[page] |
| 638 |
exten => _X.,1,Gosub(sub-page,s,1(SIP/${EXTEN})) |
| 639 |
same => n,Hangup() |
| 640 |
|
| 641 |
;[mainmenu] |
| 642 |
; |
| 643 |
; Example "main menu" context with submenu |
| 644 |
; |
| 645 |
;exten => s,1,Answer |
| 646 |
; same => n,Background(thanks) ; "Thanks for calling press 1 for sales, 2 for support, ..." |
| 647 |
; same => n,WaitExten |
| 648 |
;exten => 1,1,Goto(submenu,s,1) |
| 649 |
;exten => 2,1,Hangup |
| 650 |
;include => default |
| 651 |
; |
| 652 |
;[submenu] |
| 653 |
;exten => s,1,Ringing ; Make them comfortable with 2 seconds of ringback |
| 654 |
; same => n,Wait,2 |
| 655 |
; same => n,Background(submenuopts) ; "Thanks for calling the sales department. Press 1 for steve, 2 for..." |
| 656 |
; same => n,WaitExten |
| 657 |
;exten => 1,1,Goto(default,steve,1) |
| 658 |
;exten => 2,1,Goto(default,mark,2) |
| 659 |
|
| 660 |
[public] |
| 661 |
; |
| 662 |
; ATTENTION: If your Asterisk is connected to the internet, |
| 663 |
; double check which services you offer to the world. |
| 664 |
; |
| 665 |
include => demo |
| 666 |
|
| 667 |
[default] |
| 668 |
; |
| 669 |
; By default we include the demo. In a production system, you |
| 670 |
; probably don't want to have the demo there. |
| 671 |
; |
| 672 |
include => demo |
| 673 |
|
| 674 |
; Real extensions would go here. Generally you want real extensions to be |
| 675 |
; 4 or 5 digits long (although there is no such requirement) and start with a |
| 676 |
; single digit that is fairly large (like 6 or 7) so that you have plenty of |
| 677 |
; room to overlap extensions and menu options without conflict. You can alias |
| 678 |
; them with names, too, and use global variables |
| 679 |
|
| 680 |
;exten => 6245,hint,PJSIP/Grandstream1&PJSIP/Xlite1(Joe Schmoe) ; Channel hints for presence |
| 681 |
;exten => 6245,1,Dial(PJSIP/Grandstream1,20,rt) ; permit transfer |
| 682 |
;exten => 6245,n(dial),Dial(${HINT},20,rtT) ; Use hint as listed |
| 683 |
;exten => 6245,n,VoiceMail(6245,u) ; Voicemail (unavailable) |
| 684 |
;exten => 6245,s+1,Hangup ; s+1, same as n |
| 685 |
;exten => 6245,dial+101,VoiceMail(6245,b) ; Voicemail (busy) |
| 686 |
;exten => 6361,1,Dial(IAX2/JaneDoe,,rm) ; ring without time limit |
| 687 |
;exten => 6390,1,Dial(JINGLE/caller/callee) ; Dial via jingle using labels |
| 688 |
;exten => 6391,1,Dial(JINGLE/[email protected]/[email protected]) ;Dial via jingle using asterisk as the transport and calling mogorman. |
| 689 |
;exten => 6394,1,Dial(Local/6275/n) ; this will dial ${MARK} |
| 690 |
|
| 691 |
;exten => 6275,1,Gosub(${EXTEN},stdexten(${MARK})) |
| 692 |
; assuming ${MARK} is something like DAHDI/2 |
| 693 |
;exten => 6275,n,Goto(default,s,1) ; exited Voicemail |
| 694 |
;exten => mark,1,Goto(6275,1) ; alias mark to 6275 |
| 695 |
;exten => 6536,1,Gosub(${EXTEN},stdexten(${WIL})) |
| 696 |
; Ditto for wil |
| 697 |
; same => n,Goto(default,s,1) ; exited Voicemail |
| 698 |
;exten => wil,1,Goto(6236,1) |
| 699 |
|
| 700 |
;If you want to subscribe to the status of a parking space, this is |
| 701 |
;how you do it. Subscribe to extension 6600, and you will see |
| 702 |
;the status of the first parking lot with this extensions' help |
| 703 |
;exten => 6600,hint,park:701@parkedcalls |
| 704 |
;exten => 6600,1,noop |
| 705 |
; |
| 706 |
;To subscribe to the availability of a free member in the 'markq' queue. |
| 707 |
;Note: '_avail' is added to the QueueName |
| 708 |
;exten => 8501,hint,Queue:markq_avail |
| 709 |
;exten => 8501,1,Queue(markq) |
| 710 |
; |
| 711 |
; You can also monitor the status of a queue by providing a hint for a |
| 712 |
; particular queue name. |
| 713 |
;exten => 8502,hint,Queue:markq |
| 714 |
;exten => 8502,1,Queue(markq) |
| 715 |
; |
| 716 |
; Some other handy things are an extension for checking voicemail via |
| 717 |
; voicemailmain |
| 718 |
; |
| 719 |
;exten => 8500,1,VoicemailMain |
| 720 |
; same => n,Hangup |
| 721 |
; |
| 722 |
; Or a conference room (you'll need to edit meetme.conf to enable this room) |
| 723 |
; |
| 724 |
;exten => 8600,1,Meetme(1234) |
| 725 |
; |
| 726 |
; Or playing an announcement to the called party, as soon it answers |
| 727 |
; |
| 728 |
;exten = 8700,1,Dial(${MARK},30,A(/path/to/my/announcemsg)) |
| 729 |
; |
| 730 |
|
| 731 |
; example of a compartmentalized company called "acme" |
| 732 |
; |
| 733 |
; this is the context that your incoming IAX/SIP trunk dumps you in... |
| 734 |
;[acme-incoming] |
| 735 |
;exten => s,1,Wait(1) |
| 736 |
; same => n,Answer() ; "same" allows you to continue an extension more |
| 737 |
; concisely without having to repeat the extension or pattern |
| 738 |
; same => n(menu),Playback(acme/vm-brief-menu) |
| 739 |
; same => n(exten),Background(vm-enter-num-to-call) |
| 740 |
; same => n,WaitExten(5) |
| 741 |
; same => n(goodbye),Playback(vm-goodbye) |
| 742 |
; same => n(end),Hangup() |
| 743 |
; |
| 744 |
;include => acme-extens |
| 745 |
; |
| 746 |
;exten => i,1,Playback(vm-invalid) |
| 747 |
; same => n,Goto(s,exten) ; optionally, transfer to operator |
| 748 |
; |
| 749 |
;exten => t,1,Goto(s,goodbye) |
| 750 |
; |
| 751 |
; this is the context our internal SIP hardphones use |
| 752 |
; |
| 753 |
;[acme-internal] |
| 754 |
;exten => s,1,Answer() |
| 755 |
; same => n(exten),Background(vm-enter-num-to-call) |
| 756 |
; same => n,WaitExten(5) |
| 757 |
; same => n(goodbye),Playback(vm-goodbye) |
| 758 |
; same => n(end),Hangup() |
| 759 |
; |
| 760 |
;include => trunkint |
| 761 |
;include => trunkld |
| 762 |
;include => trunklocal |
| 763 |
; |
| 764 |
;include => acme-extens |
| 765 |
; |
| 766 |
; you can test what your system sounds like to outside callers by dialing this |
| 767 |
;exten => 777,1,DISA(no-password,acme-incoming) |
| 768 |
; |
| 769 |
; grouping of acme's extensions... never used directly, always included. |
| 770 |
; |
| 771 |
;[acme-extens] |
| 772 |
;include => stdexten |
| 773 |
;exten => 111,1,Gosub(111,stdexten(SIP/pete_1,acme)) |
| 774 |
; same => n,Goto(s,exten) |
| 775 |
; |
| 776 |
;exten => 112,1,Gosub(112,stdexten(SIP/nancy_1,acme)) |
| 777 |
; same => n,Goto(s,end) |
| 778 |
; |
| 779 |
; end of acme example |
| 780 |
|
| 781 |
; |
| 782 |
; Time context: you can patch this in via the following. |
| 783 |
; |
| 784 |
; [acme-internal] |
| 785 |
; ... |
| 786 |
; exten => 777,1,Gosub(time) |
| 787 |
; exten => 777,n,Hangup() |
| 788 |
; |
| 789 |
; ... |
| 790 |
; include => time |
| 791 |
; |
| 792 |
|
| 793 |
[time] |
| 794 |
exten => _X.,30000(time),NoOp(Time: ${EXTEN} ${timezone}) |
| 795 |
same => n,Wait(0.25) |
| 796 |
same => n,Answer() |
| 797 |
; the amount of delay is set for English; you may need to adjust this time |
| 798 |
; for other languages if there's no pause before the synchronizing beep. |
| 799 |
same => n,Set(FUTURETIME=$[${EPOCH} + 12]) |
| 800 |
same => n,SayUnixTime(${FUTURETIME},Zulu,HNS) |
| 801 |
same => n,SayPhonetic(z) |
| 802 |
; default if one hasn't been set. |
| 803 |
same => n,SayUnixTime(${FUTURETIME},${timezone},HNS) |
| 804 |
same => n,Playback(spy-local) |
| 805 |
same => n,WaitUntil(${FUTURETIME}) |
| 806 |
same => n,Playback(beep) |
| 807 |
same => n,Return() |
| 808 |
|
| 809 |
; |
| 810 |
; ANI context: use in the same way as "time" above |
| 811 |
; |
| 812 |
|
| 813 |
[ani] |
| 814 |
exten => _X.,40000(ani),NoOp(ANI: ${EXTEN}) |
| 815 |
same => n,Wait(0.25) |
| 816 |
same => n,Answer() |
| 817 |
same => n,Playback(vm-from) |
| 818 |
same => n,SayDigits(${CALLERID(ani)}) |
| 819 |
same => n,Wait(1.25) |
| 820 |
same => n,SayDigits(${CALLERID(ani)}) ; playback again in case of missed digit |
| 821 |
same => n,Return() |
| 822 |
|
| 823 |
; For more information on applications, just type "core show applications" at your |
| 824 |
; friendly Asterisk CLI prompt. |
| 825 |
; |
| 826 |
; "core show application <command>" will show details of how you |
| 827 |
; use that particular application in this file, the dial plan. |
| 828 |
; "core show functions" will list all dialplan functions |
| 829 |
; "core show function <COMMAND>" will show you more information about |
| 830 |
; one function. Remember that function names are UPPER CASE. |
| 831 |
|
| 832 |
; Examples using PJSIPNotify application. |
| 833 |
;[generate-notify] |
| 834 |
; |
| 835 |
; Send a NOTIFY with the following headers inside the SIP dialog for the current channel: |
| 836 |
; |
| 837 |
; Event: Test |
| 838 |
; X-Data: Fun |
| 839 |
; |
| 840 |
;exten => 6880,1,noOp() |
| 841 |
; same => n,Answer() |
| 842 |
; same => n,PJSIPNotify(,&Event=Test&X-Data=Fun) |
| 843 |
; same => n,Wait(1) |
| 844 |
; same => n,Hangup() |
| 845 |
; |
| 846 |
; Send a NOTIFY with the following headers to bob's custom uri. This requries a |
| 847 |
; default outbound endpoint to be configured in pjsip.conf. |
| 848 |
; |
| 849 |
; Event: Test |
| 850 |
; X-Data: Over |
| 851 |
; |
| 852 |
;exten => 6881,1,noOp() |
| 853 |
; same => n,Answer() |
| 854 |
; same => n,PJSIPNotify(<sip:[email protected]:5260>,&Event=Test&X-Data=Over) |
| 855 |
; same => n,Wait(1) |
| 856 |
; same => n,Hangup() |
| 857 |
; |
| 858 |
; Send a NOTIFY with the the custom headers defined in pjsip_notify.conf under |
| 859 |
; 'custom-notify-1' inside the SIP dialog for the current channel. |
| 860 |
; |
| 861 |
;exten => 6882,1,noOp() |
| 862 |
; same => n,Answer() |
| 863 |
; same => n,PJSIPNotify(,custom-notify-1) |
| 864 |
; same => n,Wait(1) |
| 865 |
; same => n,Hangup() |
| 866 |
; Send a NOTIFY with the following headers and body to bob's custom uri. This |
| 867 |
; requries a default outbound endpoint to be configured in pjsip.conf. |
| 868 |
; |
| 869 |
; Event: Custom |
| 870 |
; |
| 871 |
; Content-Type: application/voicemail |
| 872 |
; Content-Length: 14 |
| 873 |
; |
| 874 |
; check-messages |
| 875 |
; |
| 876 |
;exten => 6882,1,noOp() |
| 877 |
; same => n,Answer() |
| 878 |
; same => n,PJSIPNotify(,&Event=Custom&Content-type=application/voicemail&Content=check-messages&Content=) |
| 879 |
; same => n,Wait(1) |
| 880 |
; same => n,Hangup() |