Guest User

asterisk extensions.conf

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