extensions.conf.sample 31 KB

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