Advertisement
Guest User

Asterisk1extensions.conf

a guest
Aug 26th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.01 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. ;
  228. ; Sample entries for extensions.conf
  229. ;
  230. ;
  231. [dundi-e164-canonical]
  232. ;include => stdexten
  233. ;
  234. ; List canonical entries here
  235. ;
  236. ;exten => 12564286000,1,Gosub(6000,stdexten(IAX2/foo))
  237. ;exten => 12564286000,n,Goto(default,s,1) ; exited Voicemail
  238. ;exten => _125642860XX,1,Dial(IAX2/otherbox/${EXTEN:7})
  239.  
  240. [dundi-e164-customers]
  241. ;
  242. ; If you are an ITSP or Reseller, list your customers here.
  243. ;
  244. ;exten => _12564286000,1,Dial(SIP/customer1)
  245. ;exten => _12564286001,1,Dial(IAX2/customer2)
  246.  
  247. [dundi-e164-via-pstn]
  248. ;
  249. ; If you are freely delivering calls to the PSTN, list them here
  250. ;
  251. ;exten => _1256428XXXX,1,Dial(DAHDI/G2/${EXTEN:7}) ; Expose all of 256-428
  252. ;exten => _1256325XXXX,1,Dial(DAHDI/G2/${EXTEN:7}) ; Ditto for 256-325
  253.  
  254. [dundi-e164-local]
  255. ;
  256. ; Context to put your dundi IAX2 or SIP user in for
  257. ; full access
  258. ;
  259. include => dundi-e164-canonical
  260. include => dundi-e164-customers
  261. include => dundi-e164-via-pstn
  262.  
  263. [dundi-e164-switch]
  264. ;
  265. ; Just a wrapper for the switch
  266. ;
  267. switch => DUNDi/e164
  268.  
  269. [dundi-e164-lookup]
  270. ;
  271. ; Locally to lookup, try looking for a local E.164 solution
  272. ; then try DUNDi if we don't have one.
  273. ;
  274. include => dundi-e164-local
  275. include => dundi-e164-switch
  276. ;
  277. ; DUNDi can also be implemented as a Macro instead of using
  278. ; the Local channel driver.
  279. ;
  280. [macro-dundi-e164]
  281. ;
  282. ; ARG1 is the extension to Dial
  283. ;
  284. ; Extension "s" is not a wildcard extension that matches "anything".
  285. ; In macros, it is the start extension. In most other cases,
  286. ; you have to goto "s" to execute that extension.
  287. ;
  288. ; Note: In old versions of Asterisk the PBX in some cases defaulted to
  289. ; extension "s" when a given extension was wrong (like in AMI originate).
  290. ; This is no longer the case.
  291. ;
  292. ; For wildcard matches, see above - all pattern matches start with
  293. ; an underscore.
  294. exten => s,1,Goto(${ARG1},1)
  295. include => dundi-e164-lookup
  296.  
  297. ;
  298. ; Here are the entries you need to participate in the IAXTEL
  299. ; call routing system. Most IAXTEL numbers begin with 1-700, but
  300. ; there are exceptions. For more information, and to sign
  301. ; up, please go to www.gnophone.com or www.iaxtel.com
  302. ;
  303. [iaxtel700]
  304. exten => _91700XXXXXXX,1,Dial(IAX2/${GLOBAL(IAXINFO)}@iaxtel.com/${EXTEN:1}@iaxtel)
  305.  
  306. ;
  307. ; The SWITCH statement permits a server to share the dialplan with
  308. ; another server. Use with care: Reciprocal switch statements are not
  309. ; allowed (e.g. both A -> B and B -> A), and the switched server needs
  310. ; to be on-line or else dialing can be severly delayed.
  311. ;
  312. [iaxprovider]
  313. ;switch => IAX2/user:[key]@myserver/mycontext
  314.  
  315. [trunkint]
  316. ;
  317. ; International long distance through trunk
  318. ;
  319. exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
  320. exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
  321.  
  322. [trunkld]
  323. ;
  324. ; Long distance context accessed through trunk
  325. ;
  326. exten => _91NXXNXXXXXX,1,Macro(dundi-e164,${EXTEN:1})
  327. exten => _91NXXNXXXXXX,n,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}})
  328.  
  329. [trunklocal]
  330. ;
  331. ; Local seven-digit dialing accessed through trunk interface
  332. ;
  333. exten => _9NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}})
  334.  
  335. [trunktollfree]
  336. ;
  337. ; Long distance context accessed through trunk interface
  338. ;
  339. exten => _91800NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}})
  340. exten => _91888NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}})
  341. exten => _91877NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}})
  342. exten => _91866NXXXXXX,1,Dial(${GLOBAL(TRUNK)}/${EXTEN:${GLOBAL(TRUNKMSD)}})
  343.  
  344. [international]
  345. ;
  346. ; Master context for international long distance
  347. ;
  348. ignorepat => 9
  349. include => longdistance
  350. include => trunkint
  351.  
  352. [longdistance]
  353. ;
  354. ; Master context for long distance
  355. ;
  356. ignorepat => 9
  357. include => local
  358. include => trunkld
  359.  
  360. [local]
  361. ;
  362. ; Master context for local, toll-free, and iaxtel calls only
  363. ;
  364. ignorepat => 9
  365. include => default
  366. include => trunklocal
  367. include => iaxtel700
  368. include => trunktollfree
  369. include => iaxprovider
  370.  
  371. ;Include parkedcalls (or the context you define in features conf)
  372. ;to enable call parking.
  373. include => parkedcalls
  374. ;
  375. ; You can use an alternative switch type as well, to resolve
  376. ; extensions that are not known here, for example with remote
  377. ; IAX switching you transparently get access to the remote
  378. ; Asterisk PBX
  379. ;
  380. ; switch => IAX2/user:password@bigserver/local
  381. ;
  382. ; An "lswitch" is like a switch but is literal, in that
  383. ; variable substitution is not performed at load time
  384. ; but is passed to the switch directly (presumably to
  385. ; be substituted in the switch routine itself)
  386. ;
  387. ; lswitch => Loopback/12${EXTEN}@othercontext
  388. ;
  389. ; An "eswitch" is like a switch but the evaluation of
  390. ; variable substitution is performed at runtime before
  391. ; being passed to the switch routine.
  392. ;
  393. ; eswitch => IAX2/context@${CURSERVER}
  394.  
  395. ; The following two contexts are a template to enable the ability to dial
  396. ; ISN numbers. For more information about what an ISN number is, please see
  397. ; http://www.freenum.org.
  398. ;
  399. ; This is the dialing hook. use:
  400. ; include => outbound-freenum
  401.  
  402. [outbound-freenum]
  403. ; We'll add more digits as needed. The purpose is to dial things
  404. ; like extension numbers at domains (ITAD number) so we're matching
  405. ; on lengths of 1 through 6 prior to the separator (the asterisk [*])
  406. ;
  407. exten => _X*X!,1,Goto(outbound-freenum2,${EXTEN},1)
  408. exten => _XX*X!,1,Goto(outbound-freenum2,${EXTEN},1)
  409. exten => _XXX*X!,1,Goto(outbound-freenum2,${EXTEN},1)
  410. exten => _XXXX*X!,1,Goto(outbound-freenum2,${EXTEN},1)
  411. exten => _XXXXX*X!,1,Goto(outbound-freenum2,${EXTEN},1)
  412. exten => _XXXXXX*X!,1,Goto(outbound-freenum2,${EXTEN},1)
  413.  
  414. [outbound-freenum2]
  415. ; This is the handler which performs the dialing logic. It is called
  416. ; from the [outbound-freenum] context
  417. ;
  418. exten => _X!,1,Verbose(2,Performing ISN lookup for ${EXTEN})
  419. same => n,Set(SUFFIX=${CUT(EXTEN,*,2-)}) ; make sure the suffix is all digits as well
  420. same => n,GotoIf($["${FILTER(0-9,${SUFFIX})}" != "${SUFFIX}"]?fn-CONGESTION,1)
  421. ; filter out bad characters per the README-SERIOUSLY.best-practices.txt document
  422. same => n,Set(TIMEOUT(absolute)=10800)
  423. same => n,Set(isnresult=${ENUMLOOKUP(${EXTEN},sip,,1,freenum.org)}) ; perform our lookup with freenum.org
  424. same => n,GotoIf($["${isnresult}" != ""]?from)
  425. same => n,Set(DIALSTATUS=CONGESTION)
  426. same => n,Goto(fn-CONGESTION,1)
  427. same => n(from),Set(__SIPFROMUSER=${CALLERID(num)})
  428. same => n,GotoIf($["${GLOBAL(FREENUMDOMAIN)}" = ""]?dial) ; check if we set the FREENUMDOMAIN global variable in [global]
  429. same => n,Set(__SIPFROMDOMAIN=${GLOBAL(FREENUMDOMAIN)}) ; if we did set it, then we'll use it for our outbound dialing domain
  430. same => n(dial),Dial(SIP/${isnresult},40)
  431. same => n,Goto(fn-${DIALSTATUS},1)
  432.  
  433. exten => fn-BUSY,1,Busy()
  434.  
  435. exten => _f[n]-.,1,NoOp(ISN: ${DIALSTATUS})
  436. same => n,Congestion()
  437.  
  438. [macro-trunkdial]
  439. ;
  440. ; Standard trunk dial macro (hangs up on a dialstatus that should
  441. ; terminate call)
  442. ; ${ARG1} - What to dial
  443. ;
  444. exten => s,1,Dial(${ARG1})
  445. exten => s,n,Goto(s-${DIALSTATUS},1)
  446. exten => s-NOANSWER,1,Hangup
  447. exten => s-BUSY,1,Hangup
  448. exten => _s-.,1,NoOp
  449.  
  450. [stdexten]
  451. ;
  452. ; Standard extension subroutine:
  453. ; ${EXTEN} - Extension
  454. ; ${ARG1} - Device(s) to ring
  455. ; ${ARG2} - Optional context in Voicemail
  456. ;
  457. ; Note that the current version will drop through to the next priority in the
  458. ; case of their pressing '#'. This gives more flexibility in what do to next:
  459. ; you can prompt for a new extension, or drop the call, or send them to a
  460. ; general delivery mailbox, or...
  461. ;
  462. ; The use of the LOCAL() function is purely for convenience. Any variable
  463. ; initially declared as LOCAL() will disappear when the innermost Gosub context
  464. ; in which it was declared returns. Note also that you can declare a LOCAL()
  465. ; variable on top of an existing variable, and its value will revert to its
  466. ; previous value (before being declared as LOCAL()) upon Return.
  467. ;
  468. exten => _X.,50000(stdexten),NoOp(Start stdexten)
  469. exten => _X.,n,Set(LOCAL(ext)=${EXTEN})
  470. exten => _X.,n,Set(LOCAL(dev)=${ARG1})
  471. exten => _X.,n,Set(LOCAL(cntx)=${ARG2})
  472. exten => _X.,n,Set(LOCAL(mbx)=${ext}${IF($[!${ISNULL(${cntx})}]?@${cntx})})
  473. exten => _X.,n,Dial(${dev},20) ; Ring the interface, 20 seconds maximum
  474. exten => _X.,n,Goto(stdexten-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
  475.  
  476. exten => stdexten-NOANSWER,1,Voicemail(${mbx},u) ; If unavailable, send to voicemail w/ unavail announce
  477. exten => stdexten-NOANSWER,n,Return() ; If they press #, return to start
  478.  
  479. exten => stdexten-BUSY,1,Voicemail(${mbx},b) ; If busy, send to voicemail w/ busy announce
  480. exten => stdexten-BUSY,n,Return() ; If they press #, return to start
  481.  
  482. exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) ; Treat anything else as no answer
  483.  
  484. exten => a,1,VoicemailMain(${mbx}) ; If they press *, send the user into VoicemailMain
  485. exten => a,n,Return()
  486.  
  487. [stdPrivacyexten]
  488. ;
  489. ; Standard extension subroutine:
  490. ; ${ARG1} - Extension
  491. ; ${ARG2} - Device(s) to ring
  492. ; ${ARG3} - Optional DONTCALL context name to jump to (assumes the s,1 extension-priority)
  493. ; ${ARG4} - Optional TORTURE context name to jump to (assumes the s,1 extension-priority)`
  494. ; ${ARG5} - Context in voicemail (if empty, then "default")
  495. ;
  496. ; See above note in stdexten about priority handling on exit.
  497. ;
  498. exten => _X.,60000(stdPrivacyexten),NoOp(Start stdPrivacyexten)
  499. exten => _X.,n,Set(LOCAL(ext)=${ARG1})
  500. exten => _X.,n,Set(LOCAL(dev)=${ARG2})
  501. exten => _X.,n,Set(LOCAL(dontcntx)=${ARG3})
  502. exten => _X.,n,Set(LOCAL(tortcntx)=${ARG4})
  503. exten => _X.,n,Set(LOCAL(cntx)=${ARG5})
  504.  
  505. exten => _X.,n,Set(LOCAL(mbx)="${ext}"$["${cntx}" ? "@${cntx}" :: ""])
  506. exten => _X.,n,Dial(${dev},20,p) ; Ring the interface, 20 seconds maximum, call screening
  507. ; option (or use P for databased call _X.creening)
  508. exten => _X.,n,Goto(stdexten-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
  509.  
  510. exten => stdexten-NOANSWER,1,Voicemail(${mbx},u) ; If unavailable, send to voicemail w/ unavail announce
  511. exten => stdexten-NOANSWER,n,NoOp(Finish stdPrivacyexten NOANSWER)
  512. exten => stdexten-NOANSWER,n,Return() ; If they press #, return to start
  513.  
  514. exten => stdexten-BUSY,1,Voicemail(${mbx},b) ; If busy, send to voicemail w/ busy announce
  515. exten => stdexten-BUSY,n,NoOp(Finish stdPrivacyexten BUSY)
  516. exten => stdexten-BUSY,n,Return() ; If they press #, return to start
  517.  
  518. exten => stdexten-DONTCALL,1,Goto(${dontcntx},s,1) ; Callee chose to send this call to a polite "Don't call again" script.
  519.  
  520. exten => stdexten-TORTURE,1,Goto(${tortcntx},s,1) ; Callee chose to send this call to a telemarketer torture script.
  521.  
  522. exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1) ; Treat anything else as no answer
  523.  
  524. exten => a,1,VoicemailMain(${mbx}) ; If they press *, send the user into VoicemailMain
  525. exten => a,n,Return
  526.  
  527. [macro-page];
  528. ;
  529. ; Paging macro:
  530. ;
  531. ; Check to see if SIP device is in use and DO NOT PAGE if they are
  532. ;
  533. ; ${ARG1} - Device to page
  534.  
  535. exten => s,1,ChanIsAvail(${ARG1},s) ; s is for ANY call
  536. exten => s,n,GoToIf($[${AVAILSTATUS} = "1"]?autoanswer:fail)
  537. exten => s,n(autoanswer),Set(_ALERT_INFO="RA") ; This is for the PolyComs
  538. exten => s,n,SIPAddHeader(Call-Info: Answer-After=0) ; This is for the Grandstream, Snoms, and Others
  539. exten => s,n,NoOp() ; Add others here and Post on the Wiki!!!!
  540. exten => s,n,Dial(${ARG1})
  541. exten => s,n(fail),Hangup
  542.  
  543.  
  544. [demo]
  545. include => stdexten
  546. ;
  547. ; We start with what to do when a call first comes in.
  548. ;
  549. exten => s,1,Wait(1) ; Wait a second, just for fun
  550. exten => s,n,Answer ; Answer the line
  551. exten => s,n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
  552. exten => s,n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
  553. exten => s,n(restart),BackGround(demo-congrats) ; Play a congratulatory message
  554. exten => s,n(instruct),BackGround(demo-instruct) ; Play some instructions
  555. exten => s,n,WaitExten ; Wait for an extension to be dialed.
  556.  
  557. exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
  558. exten => 2,n,Goto(s,instruct)
  559.  
  560. exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
  561. exten => 3,n,Goto(s,restart) ; Start with the congratulations
  562.  
  563. exten => 1000,1,Goto(default,s,1)
  564. ;
  565. ; We also create an example user, 1234, who is on the console and has
  566. ; voicemail, etc.
  567. ;
  568. exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
  569. ; (but skip if channel is not up)
  570. exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
  571. exten => 1234,n,Goto(default,s,1) ; exited Voicemail
  572.  
  573. exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
  574.  
  575. exten => 1236,1,Dial(Console/dsp) ; Ring forever
  576. exten => 1236,n,Voicemail(1234,b) ; Unless busy
  577.  
  578. ;
  579. ; # for when they're done with the demo
  580. ;
  581. exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
  582. exten => #,n,Hangup ; Hang them up.
  583.  
  584. ;
  585. ; A timeout and "invalid extension rule"
  586. ;
  587. exten => t,1,Goto(#,1) ; If they take too long, give up
  588. exten => i,1,Playback(invalid) ; "That's not valid, try again"
  589.  
  590. ;
  591. ; Create an extension, 500, for dialing the
  592. ; Asterisk demo.
  593. ;
  594. exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
  595. exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
  596. exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
  597. exten => 500,n,Goto(s,6) ; Return to the start over message.
  598.  
  599. ;
  600. ; Create an extension, 600, for evaluating echo latency.
  601. ;
  602. exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
  603. exten => 600,n,Echo ; Do the echo test
  604. exten => 600,n,Playback(demo-echodone) ; Let them know it's over
  605. exten => 600,n,Goto(s,6) ; Start over
  606.  
  607. ;
  608. ; You can use the Macro Page to intercom a individual user
  609. exten => 76245,1,Macro(page,SIP/Grandstream1)
  610. ; or if your peernames are the same as extensions
  611. exten => _7XXX,1,Macro(page,SIP/${EXTEN})
  612. ;
  613. ;
  614. ; System Wide Page at extension 7999
  615. ;
  616. exten => 7999,1,Set(TIMEOUT(absolute)=60)
  617. exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
  618.  
  619. ; Give voicemail at extension 8500
  620. ;
  621. exten => 8500,1,VoicemailMain
  622. exten => 8500,n,Goto(s,6)
  623. ;
  624. ; Here's what a phone entry would look like (IXJ for example)
  625. ;
  626. ;exten => 1265,1,Dial(Phone/phone0,15)
  627. ;exten => 1265,n,Goto(s,5)
  628.  
  629. ;
  630. ; The page context calls up the page macro that sets variables needed for auto-answer
  631. ; It is in is own context to make calling it from the Page() application as simple as
  632. ; Local/{peername}@page
  633. ;
  634. [page]
  635. exten => _X.,1,Macro(page,SIP/${EXTEN})
  636.  
  637. ;[mainmenu]
  638. ;
  639. ; Example "main menu" context with submenu
  640. ;
  641. ;exten => s,1,Answer
  642. ;exten => s,n,Background(thanks) ; "Thanks for calling press 1 for sales, 2 for support, ..."
  643. ;exten => s,n,WaitExten
  644. ;exten => 1,1,Goto(submenu,s,1)
  645. ;exten => 2,1,Hangup
  646. ;include => default
  647. ;
  648. ;[submenu]
  649. ;exten => s,1,Ringing ; Make them comfortable with 2 seconds of ringback
  650. ;exten => s,n,Wait,2
  651. ;exten => s,n,Background(submenuopts) ; "Thanks for calling the sales department. Press 1 for steve, 2 for..."
  652. ;exten => s,n,WaitExten
  653. ;exten => 1,1,Goto(default,steve,1)
  654. ;exten => 2,1,Goto(default,mark,2)
  655.  
  656. [public]
  657. ;
  658. ; ATTENTION: If your Asterisk is connected to the internet and you do
  659. ; not have allowguest=no in sip.conf, everybody out there may use your
  660. ; public context without authentication. In that case you want to
  661. ; double check which services you offer to the world.
  662. ;
  663. include => demo
  664.  
  665. [default]
  666. ;
  667. ; By default we include the demo. In a production system, you
  668. ; probably don't want to have the demo there.
  669. ;
  670. include => demo
  671.  
  672. ;
  673. ; An extension like the one below can be used for FWD, Nikotel, sipgate etc.
  674. ; Note that you must have a [sipprovider] section in sip.conf
  675. ;
  676. ;exten => _41X.,1,Dial(SIP/${FILTER(0-9,${EXTEN:2})}@sipprovider,,r)
  677.  
  678. ; Real extensions would go here. Generally you want real extensions to be
  679. ; 4 or 5 digits long (although there is no such requirement) and start with a
  680. ; single digit that is fairly large (like 6 or 7) so that you have plenty of
  681. ; room to overlap extensions and menu options without conflict. You can alias
  682. ; them with names, too, and use global variables
  683.  
  684. ;exten => 6245,hint,SIP/Grandstream1&SIP/Xlite1(Joe Schmoe) ; Channel hints for presence
  685. ;exten => 6245,1,Dial(SIP/Grandstream1,20,rt) ; permit transfer
  686. ;exten => 6245,n(dial),Dial(${HINT},20,rtT) ; Use hint as listed
  687. ;exten => 6245,n,Voicemail(6245,u) ; Voicemail (unavailable)
  688. ;exten => 6245,s+1,Hangup ; s+1, same as n
  689. ;exten => 6245,dial+101,Voicemail(6245,b) ; Voicemail (busy)
  690. ;exten => 6361,1,Dial(IAX2/JaneDoe,,rm) ; ring without time limit
  691. ;exten => 6389,1,Dial(MGCP/aaln/1@192.168.0.14)
  692. ;exten => 6390,1,Dial(JINGLE/caller/callee) ; Dial via jingle using labels
  693. ;exten => 6391,1,Dial(JINGLE/asterisk@digium.com/mogorman@astjab.org) ;Dial via jingle using asterisk as the transport and calling mogorman.
  694. ;exten => 6394,1,Dial(Local/6275/n) ; this will dial ${MARK}
  695.  
  696. ;exten => 6275,1,Gosub(${EXTEN},stdexten(${MARK}))
  697. ; assuming ${MARK} is something like DAHDI/2
  698. ;exten => 6275,n,Goto(default,s,1) ; exited Voicemail
  699. ;exten => mark,1,Goto(6275,1) ; alias mark to 6275
  700. ;exten => 6536,1,Gosub(${EXTEN},stdexten(${WIL}))
  701. ; Ditto for wil
  702. ;exten => 6536,n,Goto(default,s,1) ; exited Voicemail
  703. ;exten => wil,1,Goto(6236,1)
  704.  
  705. ;If you want to subscribe to the status of a parking space, this is
  706. ;how you do it. Subscribe to extension 6600 in sip, and you will see
  707. ;the status of the first parking lot with this extensions' help
  708. ;exten => 6600,hint,park:701@parkedcalls
  709. ;exten => 6600,1,noop
  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.  
  717. ;To subscribe to the availability of a free member in the 'markq' queue.
  718. ;Note: '_avail' is added to the QueueName
  719. ;exten => 8501,hint,Queue:markq_avail
  720. ;exten => 8501,1,Queue(markq)
  721.  
  722. ; Some other handy things are an extension for checking voicemail via
  723. ; voicemailmain
  724. ;
  725. ;exten => 8500,1,VoicemailMain
  726. ;exten => 8500,n,Hangup
  727. ;
  728. ; Or a conference room (you'll need to edit meetme.conf to enable this room)
  729. ;
  730. ;exten => 8600,1,Meetme(1234)
  731. ;
  732. ; Or playing an announcement to the called party, as soon it answers
  733. ;
  734. ;exten = 8700,1,Dial(${MARK},30,A(/path/to/my/announcemsg))
  735. ;
  736.  
  737. ; example of a compartmentalized company called "acme"
  738. ;
  739. ; this is the context that your incoming IAX/SIP trunk dumps you in...
  740. ;[acme-incoming]
  741. ;exten => s,1,Wait(1)
  742. ;exten => s,n,Answer()
  743. ;exten => s,n(menu),Playback(acme/vm-brief-menu)
  744. ;exten => s,n(exten),Background(vm-enter-num-to-call)
  745. ;exten => s,n,WaitExten(5)
  746. ;exten => s,n(goodbye),Playback(vm-goodbye)
  747. ;exten => s,n(end),Hangup()
  748. ;
  749. ;include => acme-extens
  750. ;
  751. ;exten => i,1,Playback(vm-invalid)
  752. ;exten => i,n,Goto(s,exten) ; optionally, transfer to operator
  753. ;
  754. ;exten => t,1,Goto(s,goodbye)
  755. ;
  756. ; this is the context our internal SIP hardphones use (see sip.conf)
  757. ;
  758. ;[acme-internal]
  759. ;exten => s,1,Answer()
  760. ;exten => s,n(exten),Background(vm-enter-num-to-call)
  761. ;exten => s,n,WaitExten(5)
  762. ;exten => s,n(goodbye),Playback(vm-goodbye)
  763. ;exten => s,n(end),Hangup()
  764. ;
  765. ;include => trunkint
  766. ;include => trunkld
  767. ;include => trunklocal
  768. ;
  769. ;include => acme-extens
  770. ;
  771. ; you can test what your system sounds like to outside callers by dialing this
  772. ;exten => 777,1,DISA(no-password,acme-incoming)
  773. ;
  774. ; grouping of acme's extensions... never used directly, always included.
  775. ;
  776. ;[acme-extens]
  777. ;include => stdexten
  778. ;exten => 111,1,Gosub(111,stdexten(SIP/pete_1,acme))
  779. ;exten => 111,n,Goto(s,exten)
  780. ;
  781. ;exten => 112,1,Gosub(112,stdexten(SIP/nancy_1,acme))
  782. ;exten => 112,n,Goto(s,end)
  783. ;
  784. ; end of acme example
  785.  
  786. ;
  787. ; Time context: you can patch this in via the following.
  788. ;
  789. ; [acme-internal]
  790. ; ...
  791. ; exten => 777,1,Gosub(time)
  792. ; exten => 777,n,Hangup()
  793. ;
  794. ; ...
  795. ; include => time
  796. ;
  797. ; Note: if you're geographically spread out, you can have SIP extensions
  798. ; specify their own local timezone in sip.conf as:
  799. ;
  800. ; [boi]
  801. ; type=friend
  802. ; context=acme-internal
  803. ; callerid="Boise Ofc. <2083451111>"
  804. ; ...
  805. ; ; use system-wide default timezone of MST7MDT
  806. ;
  807. ; [lws]
  808. ; type=friend
  809. ; context=acme-internal
  810. ; callerid="Lewiston Ofc. <2087431111>"
  811. ; ...
  812. ; setvar=timezone=PST8PDT
  813. ;
  814. ; "timezone" isn't a 'reserved' name in any way, and other places where
  815. ; the timezone is significant (e.g. calls to "SayUnixTime()", etc) will
  816. ; require modification as well. Note that voicemail.conf already has
  817. ; a mechanism for timezones.
  818. ;
  819.  
  820. [time]
  821. exten => _X.,30000(time),NoOp(Time: ${EXTEN} ${timezone})
  822. exten => _X.,n,Wait(0.25)
  823. exten => _X.,n,Answer()
  824. ; the amount of delay is set for English; you may need to adjust this time
  825. ; for other languages if there's no pause before the synchronizing beep.
  826. exten => _X.,n,Set(FUTURETIME=$[${EPOCH} + 12])
  827. exten => _X.,n,SayUnixTime(${FUTURETIME},Zulu,HNS)
  828. exten => _X.,n,SayPhonetic(z)
  829. ; use the timezone associated with the extension (sip only), or system-wide
  830. ; default if one hasn't been set.
  831. exten => _X.,n,SayUnixTime(${FUTURETIME},${timezone},HNS)
  832. exten => _X.,n,Playback(spy-local)
  833. exten => _X.,n,WaitUntil(${FUTURETIME})
  834. exten => _X.,n,Playback(beep)
  835. exten => _X.,n,Return()
  836.  
  837. ;
  838. ; ANI context: use in the same way as "time" above
  839. ;
  840.  
  841. [ani]
  842. exten => _X.,40000(ani),NoOp(ANI: ${EXTEN})
  843. exten => _X.,n,Wait(0.25)
  844. exten => _X.,n,Answer()
  845. exten => _X.,n,Playback(vm-from)
  846. exten => _X.,n,SayDigits(${CALLERID(ani)})
  847. exten => _X.,n,Wait(1.25)
  848. exten => _X.,n,SayDigits(${CALLERID(ani)}) ; playback again in case of missed digit
  849. exten => _X.,n,Return()
  850.  
  851. ; For more information on applications, just type "core show applications" at your
  852. ; friendly Asterisk CLI prompt.
  853. ;
  854. ; "core show application <command>" will show details of how you
  855. ; use that particular application in this file, the dial plan.
  856. ; "core show functions" will list all dialplan functions
  857. ; "core show function <COMMAND>" will show you more information about
  858. ; one function. Remember that function names are UPPER CASE.
  859.  
  860. [local]
  861. exten => _1XX, 1, Dial(SIP/${EXTEN}, 15) ; encomposant le 101 on appel John, 102 Johny, ect
  862. exten => _1XX, n, VoiceMail(${EXTEN}) ; apres 15 sec on tombe sur la messagerie
  863. exten => _002XX, 1, Dial(IAX2/Asterisk2/${EXTEN:2}, 15)
  864. exten => 90,1,VoicemailMain(&{CALLERIDNUM})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement