SHARE
TWEET

Untitled

a guest Apr 12th, 2010 273 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;--------------------------------------------------------------------------------;
  2. ; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
  3. ; this file must be done via the web gui. There are alternative files to make    ;
  4. ; custom modifications, details at: http://freepbx.org/configuration_files       ;
  5. ;--------------------------------------------------------------------------------;
  6. ;
  7.  
  8. ; FreePBX
  9. ; Copyright (C) 2004 Coalescent Systems Inc (Canada)
  10. ; Copyright (C) 2006 Why Pay More 4 Less Pty Ltd (Australia)
  11. ; Copyright (C) 2007 Astrogen LLC (USA)
  12. ; Released under the GNU GPL Licence version 2.
  13.  
  14. ; dialparties.agi (http://www.sprackett.com/asterisk/)
  15. ; Asterisk::AGI (http://asterisk.gnuinter.net/)
  16. ; gsm (http://www.ibiblio.org/pub/Linux/utils/compress/!INDEX.short.html)
  17. ; loligo sounds (http://www.loligo.com/asterisk/sounds/)
  18. ; mpg123 (http://voip-info.org/wiki-Asterisk+config+musiconhold.conf)
  19.  
  20. ;**************************  -WARNING-  ****************************************
  21. ;                                                                              *
  22. ; This include file is to be used with extreme caution. In almost all cases    *
  23. ; any custom dialplan SHOULD be put in extensions_custom.conf which will       *
  24. ; not hurt a FreePBX generated dialplan. In some very rare and custom          *
  25. ; situations users may have a need to override what FreePBX automatically      *
  26. ; generates. If so anything in this file will do that.  If you come up with a  *
  27. ; situation where you need to modify the existing dialplan or macro, please    *
  28. ; put it here and also notify the FreePBX development team so they can take it *
  29. ; into account in the future.                                                  *
  30. ;                                                                              *
  31. #include extensions_override_freepbx.conf
  32. ;                                                                              *
  33. ;**************************  -WARNING-  ****************************************
  34.  
  35. ; include extension contexts generated from AMP
  36. #include extensions_additional.conf
  37.  
  38. ; Customizations to this dialplan should be made in extensions_custom.conf
  39. ; See extensions_custom.conf.sample for an example.
  40. ; If you need to use [macro-dialout-trunk-predial-hook], [ext-did-custom], or
  41. ; [from-internal-custom] for example, place these in this file or they will get overwritten.
  42. ;
  43. #include extensions_custom.conf
  44.  
  45. [from-trunk]                            ; just an alias since VoIP shouldn't be called PSTN
  46. include => from-pstn
  47.  
  48. [from-pstn]
  49. include => from-pstn-custom             ; create this context in extensions_custom.conf to include customizations
  50. include => ext-did
  51. include => ext-did-post-custom
  52. include => from-did-direct              ; MODIFICATION (PL) for findmefollow if enabled, should be before ext-local
  53. include => ext-did-catchall             ; THIS MUST COME AFTER ext-did
  54. exten => fax,1,Goto(ext-fax,in_fax,1)
  55.  
  56. ; MODIFICATION (PL)
  57. ;
  58. ; Required to assure that direct dids go to personal ring group before local extension.
  59. ; This could be auto-generated however I it is preferred to be put here and hard coded
  60. ; so that it can be modified if ext-local should take precedence in certain situations.
  61. ; will have to decide what to do later.
  62. ;
  63. [from-did-direct]
  64. include => ext-findmefollow
  65. include => ext-local
  66.  
  67.  
  68.  
  69. ; ############################################################################
  70. ; Macros [macro]
  71. ; ############################################################################
  72.  
  73. ; Rings one or more extensions.  Handles things like call forwarding and DND
  74. ; We don't call dial directly for anything internal anymore.
  75. ; ARGS: $TIMER, $OPTIONS, $EXT1, $EXT2, $EXT3, ...
  76. ; Use a Macro call such as the following:
  77. ;  Macro(dial,$DIAL_TIMER,$DIAL_OPTIONS,$EXT1,$EXT2,$EXT3,...)
  78. [macro-dial]
  79. exten => s,1,GotoIf($["${MOHCLASS}" = ""]?dial)
  80. exten => s,n,SetMusicOnHold(${MOHCLASS})
  81. exten => s,n(dial),AGI(dialparties.agi)
  82. exten => s,n,NoOp(Returned from dialparties with no extensions to call and DIALSTATUS: ${DIALSTATUS})
  83.  
  84. exten => s,n+2(normdial),Dial(${ds})                               ; dialparties will set the priority to 10 if $ds is not null
  85. exten => s,n,Set(DIALSTATUS=${IF($["${DIALSTATUS_CW}"!="" ]?${DIALSTATUS_CW}:${DIALSTATUS})})
  86. exten => s,n,GosubIf($["${SCREEN}" != ""]?${DIALSTATUS},1)
  87.  
  88. exten => s,20(huntdial),NoOp(Returned from dialparties with hunt groups to dial )
  89. exten => s,n,Set(HuntLoop=0)
  90. exten => s,n(a22),GotoIf($[${HuntMembers} >= 1]?a30)  ; if this is from rg-group, don't strip prefix
  91. exten => s,n,NoOp(Returning there are no members left in the hunt group to ring)
  92.  
  93. ; dialparties.agi has setup the dialstring for each hunt member in a variable labeled HuntMember0, HuntMember1 etc for each iteration
  94. ; and The total number in HuntMembers. So for each iteration, we will update the CALLTRACE Data.
  95. ;
  96. exten => s,n+2(a30),Set(HuntMember=HuntMember${HuntLoop})
  97. exten => s,n,GotoIf($[$["${CALLTRACE_HUNT}" != "" ] & $[$["${RingGroupMethod}" = "hunt" ] | $["${RingGroupMethod}" = "firstavailable"] | $["${RingGroupMethod}" = "firstnotonphone"]]]?a32:a35)
  98.  
  99. exten => s,n(a32),Set(CT_EXTEN=${CUT(FILTERED_DIAL,,$[${HuntLoop} + 1])})
  100. exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
  101. exten => s,n,Goto(s,a42)
  102.  
  103. ;Set Call Trace for each hunt member we are going to call "Memory groups have multiple members to set CALL TRACE For" hence the loop
  104. ;
  105. exten => s,n(a35),GotoIf($[$["${CALLTRACE_HUNT}" != "" ] & $["${RingGroupMethod}" = "memoryhunt" ]]?a36:a50)  
  106. exten => s,n(a36),Set(CTLoop=0)
  107. exten => s,n(a37),GotoIf($[${CTLoop} > ${HuntLoop}]?a42)  ; if this is from rg-group, don't strip prefix
  108. exten => s,n,Set(CT_EXTEN=${CUT(FILTERED_DIAL,,$[${CTLoop} + 1])})
  109. exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
  110. exten => s,n,Set(CTLoop=$[1 + ${CTLoop}])
  111. exten => s,n,Goto(s,a37)
  112.        
  113. exten => s,n(a42),Dial(${${HuntMember}}${ds})
  114. exten => s,n,Set(HuntLoop=$[1 + ${HuntLoop}])
  115. exten => s,n,GotoIf($[$[$["foo${RingGroupMethod}" != "foofirstavailable"] & $["foo${RingGroupMethod}" != "foofirstnotonphone"]] | $["foo${DialStatus}" = "fooBUSY"]]?a46)
  116. exten => s,n,Set(HuntMembers=0)
  117. exten => s,n(a46),Set(HuntMembers=$[${HuntMembers} - 1])
  118. exten => s,n,Goto(s,a22)
  119.  
  120. exten => s,n(a50),DBdel(CALLTRACE/${CT_EXTEN})
  121. exten => s,n,Goto(s,a42)
  122.  
  123. ; For call screening
  124. exten => NOANSWER,1,Macro(vm,${SCREEN_EXTEN},BUSY,${IVR_RETVM})
  125. exten => NOANSWER,n,GotoIf($["${IVR_RETVM}" != "RETURN" | "${IVR_CONTEXT}" = ""]?bye)
  126. exten => NOANSWER,n,Return
  127. exten => NOANSWER,n(bye),Macro(hangupcall)
  128. exten => TORTURE,1,Goto(app-blackhole,musiconhold,1)
  129. exten => TORTURE,n,Macro(hangupcall)
  130. exten => DONTCALL,1,Answer
  131. exten => DONTCALL,n,Wait(1)
  132. exten => DONTCALL,n,Zapateller()
  133. exten => DONTCALL,n,Playback(ss-noservice)
  134. exten => DONTCALL,n,Macro(hangupcall)
  135.  
  136. ; make sure hungup calls go here so that proper cleanup occurs from call confirmed calls and the like
  137. ;
  138. exten => h,1,Macro(hangupcall)
  139.  
  140. ; Ring an extension, if the extension is busy or there is no answer send it
  141. ; to voicemail
  142. ; ARGS: $VMBOX, $EXT
  143. [macro-exten-vm]
  144. exten => s,1,Macro(user-callerid)
  145.  
  146. exten => s,n,Set(RingGroupMethod=none)
  147. exten => s,n,Set(VMBOX=${ARG1})
  148. exten => s,n,Set(EXTTOCALL=${ARG2})
  149. exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})})
  150. exten => s,n,Set(CFBEXT=${DB(CFB/${EXTTOCALL})})
  151. exten => s,n,Set(RT=${IF($[$["${VMBOX}"!="novm"] | $["foo${CFUEXT}"!="foo"]]?${RINGTIMER}:"")})
  152. exten => s,n,Macro(record-enable,${EXTTOCALL},IN)
  153. exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL})
  154. exten => s,n,GotoIf($[ $["${VMBOX}" != "novm"] & $["${SCREEN}" != ""] & $["${DIALSTATUS}" = "NOANSWER"] ]?exit,return)
  155. exten => s,n,Set(SV_DIALSTATUS=${DIALSTATUS})
  156. exten => s,n,GosubIf($[$["${SV_DIALSTATUS}"="NOANSWER"] & $["${CFUEXT}"!=""] & $["${SCREEN}" = ""]]?docfu,1) ; check for CFU in use on no answer
  157. exten => s,n,GosubIf($[$["${SV_DIALSTATUS}"="BUSY"] & $["${CFBEXT}"!=""]]?docfb,1) ; check for CFB in use on busy
  158. exten => s,n,Set(DIALSTATUS=${SV_DIALSTATUS})
  159. exten => s,n,NoOp(Voicemail is '${VMBOX}')
  160. exten => s,n,GotoIf($["${VMBOX}" = "novm"]?s-${DIALSTATUS},1) ; no voicemail in use for this extension
  161. exten => s,n,NoOp(Sending to Voicemail box ${EXTTOCALL})
  162. exten => s,n,Macro(vm,${VMBOX},${DIALSTATUS},${IVR_RETVM})
  163.  
  164. ; Try the Call Forward on No Answer / Unavailable number
  165. exten => docfu,1,Set(RTCFU=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")})
  166. exten => docfu,n,Dial(Local/${CFUEXT}@from-internal/n,${RTCFU},${DIAL_OPTIONS})
  167. exten => docfu,n,Return
  168.  
  169. ; Try the Call Forward on Busy number
  170. exten => docfb,1,Set(RTCFB=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")})
  171. exten => docfb,n,Dial(Local/${CFBEXT}@from-internal/n,${RTCFB},${DIAL_OPTIONS})
  172. exten => docfb,n,Return
  173.  
  174. ; Extensions with no Voicemail box reporting BUSY come here
  175. exten => s-BUSY,1,NoOp(Extension is reporting BUSY and not passing to Voicemail)
  176. exten => s-BUSY,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?exit,1)
  177. exten => s-BUSY,n,Playtones(busy)
  178. exten => s-BUSY,n,Busy(20)
  179.  
  180. ; Anything but BUSY comes here
  181. exten => _s-.,1,Noop(IVR_RETVM: ${IVR_RETVM} IVR_CONTEXT: ${IVR_CONTEXT})
  182. exten => _s-.,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?exit,1)
  183. exten => _s-.,n,Playtones(congestion)
  184. exten => _s-.,n,Congestion(10)
  185.  
  186. ; Short burst of tones then return
  187. exten => exit,1,Playback(beep&line-busy-transfer-menu&silence/1)
  188. exten => exit,n(return),MacroExit()
  189.  
  190. ;------------------------------------------------------------------------
  191. ; [macro-simple-dial]
  192. ;------------------------------------------------------------------------
  193. ; This macro was derived from macro-exten-vm, which is what is normally used to
  194. ; ring an extension. It has been simplified and designed to never go to voicemail
  195. ; and always return regardless of the DIALSTATUS for any incomplete call.
  196. ;
  197. ; It's current primary purpose is to allow findmefollow ring an extension prior
  198. ; to trying the follow-me ringgroup that is provided.
  199. ;
  200. ; Ring an extension, if the extension is busy or there is no answer, return
  201. ; ARGS: $EXTENSION, $RINGTIME
  202. ;------------------------------------------------------------------------
  203. [macro-simple-dial]
  204. exten => s,1,Set(EXTTOCALL=${ARG1})
  205. exten => s,n,Set(RT=${ARG2})
  206. exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})})
  207. exten => s,n,Set(CFBEXT=${DB(CFB/${EXTTOCALL})})
  208.  
  209. exten => s,n,Set(CWI_TMP=${CWIGNORE})
  210. exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL})
  211. exten => s,n,Set(__CWIGNORE=${CWI_TMP})
  212.  
  213. exten => s,n,Set(PR_DIALSTATUS=${DIALSTATUS})
  214.  
  215. ; if we return, thus no answer, and they have a CFU setting, then  we try that next
  216. ;
  217. exten => s,n,GosubIf($[$["${PR_DIALSTATUS}"="NOANSWER"] & $["foo${CFUEXT}"!="foo"]]?docfu,1) ; check for CFU in use on no answer
  218. exten => s,n,GosubIf($[$["${PR_DIALSTATUS}"="BUSY"] & $["foo${CFBEXT}"!="foo"]]?docfb,1) ; check for CFB in use on busy
  219. exten => s,n,Set(DIALSTATUS=${PR_DIALSTATUS})
  220.  
  221. ; Nothing yet, then go to the end (which will just return, but in case we decide to do something with certain
  222. ; return situations, this is left in.
  223. ;
  224. exten => s,n,Goto(s-${DIALSTATUS},1)
  225.  
  226. ; Try the Call Forward on No Answer / Unavailable number.
  227. ; We want to try CFU if set, but we want the same ring timer as was set to our call (or do we want the
  228. ; system ringtimer? - probably not). Then if no answer there (assuming it doesn't drop into their vm or
  229. ; something we return, which will have the net effect of returning to the followme setup.)
  230. ;
  231. ; want to avoid going to other follow-me settings here. So check if the CFUEXT is a user and if it is
  232. ; then direct it straight to ext-local (to avoid getting intercepted by findmefollow) otherwise send it
  233. ; to from-internal since it may be an outside line.
  234. ;
  235. exten => docfu,1,GotoIf( $[ "foo${DB(AMPUSER/${CFUEXT}/device)}" = "foo" ]?chlocal)
  236. exten => docfu,n,Dial(Local/${CFUEXT}@ext-local,${RT},${DIAL_OPTIONS})
  237. exten => docfu,n,Return
  238. exten => docfu,n(chlocal),Dial(Local/${CFUEXT}@from-internal/n,${RT},${DIAL_OPTIONS})
  239. exten => docfu,n,Return
  240.  
  241. ; Try the Call Forward on Busy number
  242. exten => docfb,1,GotoIf( $[ "foo${DB(AMPUSER/${CFBEXT}/device)}" = "foo" ]?chlocal)
  243. exten => docfb,n,Dial(Local/${CFBEXT}@ext-local,${RT},${DIAL_OPTIONS})
  244. exten => docfb,n,Return
  245. exten => docfb,n(chlocal),Dial(Local/${CFBEXT}@from-internal/n,${RT},${DIAL_OPTIONS})
  246. exten => docfb,n,Return
  247.  
  248. ; In all cases of no connection, come here and simply return, since the calling dialplan will
  249. ; decide what to do next
  250. exten => _s-.,1,NoOp(Extension is reporting ${EXTEN})
  251. ;------------------------------------------------------------------------
  252.  
  253.  
  254. ; get the voicemail context for the user in ARG1
  255. [macro-get-vmcontext]
  256. exten => s,1,Set(VMCONTEXT=${DB(AMPUSER/${ARG1}/voicemail)})
  257. exten => s,2,GotoIf($["foo${VMCONTEXT}" = "foo"]?200:300)
  258. exten => s,200,Set(VMCONTEXT=default)
  259. exten => s,300,NoOp()
  260.  
  261. ; For some reason, if I don't run setCIDname, CALLERID(name) will be blank in my AGI
  262. ; ARGS: none
  263. [macro-fixcid]
  264. exten => s,1,Set(CALLERID(name)=${CALLERID(name)})
  265.  
  266. ; Ring groups of phones
  267. ; ARGS: comma separated extension list
  268. ; 1 - Ring Group Strategy
  269. ; 2 - ringtimer
  270. ; 3 - prefix
  271. ; 4 - extension list
  272. [macro-rg-group]
  273. exten => s,1,Macro(user-callerid,SKIPTTL) ; already called from ringgroup
  274. exten => s,2,GotoIf($["${CALLERID(name):0:${LEN(${RGPREFIX})}}" != "${RGPREFIX}"]?4:3)  ; check for old prefix
  275. exten => s,3,Set(CALLERID(name)=${CALLERID(name):${LEN(${RGPREFIX})}}) ; strip off old prefix
  276. exten => s,4,Set(RGPREFIX=${ARG3})  ; set new prefix
  277. exten => s,5,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)})  ; add prefix to callerid name
  278. exten => s,6,Set(RecordMethod=Group)  ; set new prefix
  279. exten => s,7,Macro(record-enable,${MACRO_EXTEN},${RecordMethod})
  280. exten => s,8,Set(RingGroupMethod=${ARG1})     ;
  281. exten => s,9,Macro(dial,${ARG2},${DIAL_OPTIONS},${ARG4})
  282. exten => s,10,Set(RingGroupMethod='')     ;
  283.  
  284.  
  285. ;
  286. ; Outgoing channel(s) are busy ... inform the client
  287. ; but use noanswer features like ringgroups don't break by being answered
  288. ; just to play the message.
  289. ;
  290. [macro-outisbusy]
  291. exten => s,1,Playback(all-circuits-busy-now,noanswer)
  292. exten => s,n,Playback(pls-try-call-later,noanswer)
  293. exten => s,n,Macro(hangupcall)
  294.  
  295. ; What to do on hangup.                                        
  296. [macro-hangupcall]
  297. ; Cleanup any remaining RG flag
  298. ;
  299. exten => s,1,GotoIf($[ "x${USE_CONFIRMATION}" = "x" | "x${RINGGROUP_INDEX}" = "x" | "${CHANNEL}" != "${UNIQCHAN}"]?skiprg)
  300. exten => s,n,Noop(Cleaning Up Confirmation Flag: RG/${RINGGROUP_INDEX}/${CHANNEL})
  301. exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL})
  302.  
  303. ; Cleanup any remaining BLKVM flag
  304. ;
  305. exten => s,n(skiprg),GotoIf($[ "x${BLKVM_BASE}" = "x" | "BLKVM/${BLKVM_BASE}/${CHANNEL}" != "${BLKVM_OVERRIDE}" ]?skipblkvm)
  306. exten => s,n,Noop(Cleaning Up Block VM Flag: ${BLKVM_OVERRIDE})
  307. exten => s,n,DBDel(${BLKVM_OVERRIDE})
  308.  
  309. ; Cleanup any remaining FollowMe DND flags
  310. ;
  311. exten => s,n(skipblkvm),GotoIf($[ "x${FMGRP}" = "x" | "x${FMUNIQUE}" = "x" | "${CHANNEL}" != "${FMUNIQUE}" ]?theend)
  312. exten => s,n,DBDel(FM/DND/${FMGRP}/${CHANNEL})
  313.  
  314. exten => s,n(theend),Hangup
  315.  
  316. [macro-faxreceive]
  317. exten => s,1,Set(FAXFILE=${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)
  318. exten => s,2,Set(EMAILADDR=${FAX_RX_EMAIL})
  319. exten => s,3,rxfax(${FAXFILE})
  320. exten => s,103,Set(EMAILADDR=${FAX_RX_EMAIL})
  321. exten => s,104,Goto(3)
  322.  
  323. ; dialout and strip the prefix
  324. [macro-dialout]
  325. exten => s,1,Macro(user-callerid,SKIPTTL)
  326. exten => s,2,GotoIf($["${ECID${CALLERID(number)}}" = ""]?5)     ;check for CID override for exten
  327. exten => s,3,Set(CALLERID(all)=${ECID${CALLERID(number)}})
  328. exten => s,4,Goto(7)
  329. exten => s,5,GotoIf($["${OUTCID_${ARG1}}" = ""]?7)              ;check for CID override for trunk
  330. exten => s,6,Set(CALLERID(all)=${OUTCID_${ARG1}})
  331. exten => s,7,Set(length=${LEN(${DIAL_OUT_${ARG1}})})
  332. exten => s,8,Dial(${OUT_${ARG1}}/${ARG2:${length}})
  333. exten => s,9,Playtones(congestion)
  334. exten => s,10,Congestion(5)
  335. exten => s,109,Macro(outisbusy)
  336.  
  337.  
  338. ; dialout using default OUT trunk - no prefix
  339. [macro-dialout-default]
  340. exten => s,1,Macro(user-callerid,SKIPTTL)
  341. exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)
  342. exten => s,3,Macro(outbound-callerid,${ARG1})
  343. exten => s,4,Dial(${OUT}/${ARG1})
  344. exten => s,5,Playtones(congestion)
  345. exten => s,6,Congestion(5)
  346. exten => s,105,Macro(outisbusy)
  347.  
  348. [macro-dialout-trunk-predial-hook]
  349. ; this macro intentionally left blank so it may be safely overwritten for any custom
  350. ; requirements that an installation may have.
  351. ;
  352. ; MACRO RETURN CODE: ${PREDIAL_HOOK_RET}
  353. ;                    if set to "BYPASS" then this trunk will be skipped
  354. ;
  355. exten => s,1,MacroExit()
  356.  
  357. ; This macro is for dev purposes and just dumps channel/app variables.  Useful when designing new contexts.
  358. [macro-dumpvars]
  359. exten => s,1,Noop(ACCOUNTCODE=${ACCOUNTCODE})
  360. exten => s,2,Noop(ANSWEREDTIME=${ANSWEREDTIME})
  361. exten => s,3,Noop(BLINDTRANSFER=${BLINDTRANSFER})
  362. exten => s,4,Noop(CALLERID=${CALLERID(all)})
  363. exten => s,5,Noop(CALLERID(name)=${CALLERID(name)})
  364. exten => s,6,Noop(CALLERID(number)=${CALLERID(number)})
  365. exten => s,7,Noop(CALLINGPRES=${CALLINGPRES})
  366. exten => s,8,Noop(CHANNEL=${CHANNEL})
  367. exten => s,9,Noop(CONTEXT=${CONTEXT})
  368. exten => s,10,Noop(DATETIME=${DATETIME})
  369. exten => s,11,Noop(DIALEDPEERNAME=${DIALEDPEERNAME})
  370. exten => s,12,Noop(DIALEDPEERNUMBER=${DIALEDPEERNUMBER})
  371. exten => s,13,Noop(DIALEDTIME=${DIALEDTIME})
  372. exten => s,14,Noop(DIALSTATUS=${DIALSTATUS})
  373. exten => s,15,Noop(DNID=${DNID})
  374. exten => s,16,Noop(EPOCH=${EPOCH})
  375. exten => s,17,Noop(EXTEN=${EXTEN})
  376. exten => s,18,Noop(HANGUPCAUSE=${HANGUPCAUSE})
  377. exten => s,19,Noop(INVALID_EXTEN=${INVALID_EXTEN})
  378. exten => s,20,Noop(LANGUAGE=${LANGUAGE})
  379. exten => s,21,Noop(MEETMESECS=${MEETMESECS})
  380. exten => s,22,Noop(PRIORITY=${PRIORITY})
  381. exten => s,23,Noop(RDNIS=${RDNIS})
  382. exten => s,24,Noop(SIPDOMAIN=${SIPDOMAIN})
  383. exten => s,25,Noop(SIP_CODEC=${SIP_CODEC})
  384. exten => s,26,Noop(SIPCALLID=${SIPCALLID})
  385. exten => s,27,Noop(SIPUSERAGENT=${SIPUSERAGENT})
  386. exten => s,29,Noop(TXTCIDNAME=${TXTCIDNAME})
  387. exten => s,30,Noop(UNIQUEID=${UNIQUEID})
  388. exten => s,31,Noop(TOUCH_MONITOR=${TOUCH_MONITOR})
  389. exten => s,32,Noop(MACRO_CONTEXT=${MACRO_CONTEXT})
  390. exten => s,33,Noop(MACRO_EXTEN=${MACRO_EXTEN})
  391. exten => s,34,Noop(MACRO_PRIORITY=${MACRO_PRIORITY})
  392.  
  393. [macro-user-logon]
  394. ; check device type
  395. ;
  396. exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
  397. exten => s,n,Answer()
  398. exten => s,n,Wait(1)
  399. exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
  400. ; get user's extension
  401. ;
  402. exten => s,n,Set(AMPUSER=${ARG1})
  403. exten => s,n,GotoIf($["${AMPUSER}" != ""]?gotpass)
  404. exten => s,n(playagain),Read(AMPUSER,please-enter-your-extension-then-press-pound,,,4)
  405. ; get user's password and authenticate
  406. ;
  407. exten => s,n,GotoIf($["${AMPUSER}" = ""]?s-MAXATTEMPTS,1)
  408. exten => s,n(gotpass),GotoIf($["${DB_EXISTS(AMPUSER/${AMPUSER}/password)}" = "0"]?s-NOUSER,1)
  409. exten => s,n,Set(AMPUSERPASS=${DB_RESULT})
  410. exten => s,n,GotoIf($[${LEN(${AMPUSERPASS})} = 0]?s-NOPASSWORD,1)
  411. ; do not continue if the user has already logged onto this device
  412. ;
  413. exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
  414. exten => s,n,GotoIf($["${DEVICEUSER}" = "${AMPUSER}"]?s-ALREADYLOGGEDON,1)
  415. exten => s,n,Authenticate(${AMPUSERPASS})
  416. exten => s,n,DeadAGI(user_login_out.agi,login,${CALLERID(number)},${AMPUSER})
  417. exten => s,n,Playback(vm-goodbye)
  418.  
  419. exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into)
  420. exten => s-FIXED,n,Playback(ha/phone)
  421. exten => s-FIXED,n,SayDigits(${CALLERID(number)})
  422. exten => s-FIXED,n,Playback(is-curntly-unavail&vm-goodbye)
  423. exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into
  424.  
  425. exten => s-ALREADYLOGGEDON,1,NoOp(This device has already been logged into by this user)
  426. exten => s-ALREADYLOGGEDON,n,Playback(vm-goodbye)
  427. exten => s-ALREADYLOGGEDON,n,Hangup ;TODO should play msg indicated device is already logged into
  428.  
  429. exten => s-NOPASSWORD,1,NoOp(This extension does not exist or no password is set)
  430. exten => s-NOPASSWORD,n,Playback(pbx-invalid)
  431. exten => s-NOPASSWORD,n,Goto(s,playagain)
  432.  
  433. exten => s-MAXATTEMPTS,1,NoOp(Too many login attempts)
  434. exten => s-MAXATTEMPTS,n,Playback(vm-goodbye)
  435. exten => s-MAXATTEMPTS,n,Hangup
  436.  
  437. exten => s-NOUSER,1,NoOp(Invalid extension ${AMPUSER} entered)
  438. exten => s-NOUSER,n,Playback(pbx-invalid)
  439. exten => s-NOUSER,n,Goto(s,playagain)
  440.  
  441. [macro-user-logoff]
  442. ; check device type
  443. ;
  444. exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
  445. exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
  446. exten => s,n,DeadAGI(user_login_out.agi,logout,${CALLERID(number)})
  447. exten => s,n(done),Playback(vm-goodbye)
  448.  
  449. exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of)
  450. exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye)
  451. exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into
  452.  
  453.  
  454.  
  455. ; Privacy Manager Macro makes sure that any calls that don't pass the privacy manager are presented
  456. ; with congestion since there have been observed cases of the call continuing if not stopped with a
  457. ; congestion, and this provides a slightly more friendly 'sorry' message in case the user is
  458. ; legitimately trying to be cooperative.
  459. ;
  460. ; Note: the following options are configurable in privacy.conf:
  461. ;
  462. ;       maxretries = 3 ; default value, number of retries before failing
  463. ;       minlength = 10 ; default value, number of digits to be accepted as valid CID
  464. ;
  465. [macro-privacy-mgr]
  466. exten => s,1,Set(KEEPCID=${CALLERID(num)})
  467. exten => s,n,GotoIf($["foo${CALLERID(num):0:1}"="foo+"]?CIDTEST2:CIDTEST1)
  468. exten => s,n(CIDTEST1),Set(TESTCID=${MATH(1+${CALLERID(num)})})
  469. exten => s,n,Goto(TESTRESULT)
  470. exten => s,n(CIDTEST2),Set(TESTCID=${MATH(1+${CALLERID(num):1})})
  471. exten => s,n(TESTRESULT),GotoIf($["foo${TESTCID}"="foo"]?CLEARCID:PRIVMGR)
  472. exten => s,n(CLEARCID),Set(CALLERID(num)=)
  473. exten => s,n(PRIVMGR),PrivacyManager()
  474. exten => s,n,GotoIf($["${PRIVACYMGRSTATUS}"="FAILED"]?fail)
  475. exten => s,n,SetCallerPres(allowed_passed_screen); stop gap until app_privacy.c clears unavailable bit
  476. exten => s,PRIVMGR+101(fail),Noop(STATUS: ${PRIVACYMGRSTATUS} CID: ${CALLERID(num)} ${CALLERID(name)} CALLPRES: ${CALLLINGPRES})
  477. exten => s,n,Playback(sorry-youre-having-problems)
  478. exten => s,n,Playback(goodbye)
  479. exten => s,n,Playtones(congestion)
  480. exten => s,n,Congestion(5)
  481.  
  482.  
  483.  
  484. ; Text-To-Speech related macros
  485. ; These all follow common actions.  First try to playback a file "tts/custom-md5"
  486. ; where "md5" is the md5() of whatever is going to be played. If that doesn't exist,
  487. ; try to playback using macro-tts-sayXXXXX (where XXXXX is text/digits/etc, same as
  488. ; the macro below). If that macro exits with MACRO_OFFSET=100, then it's done,
  489. ; otherwise, fallback to the default asterisk method.
  490. ;
  491. ; say text is purely for text-to-speech, there is no fallback
  492. [macro-saytext]
  493. exten => s,1,Noop(Trying custom SayText playback for "${ARG1}")
  494. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  495. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  496. ; call tts-saytext. This should set MACRO_OFFSET=101 if it was successful
  497. exten => s,n(tts),Macro(tts-saytext,${ARG1},${ARG2},${ARG3})
  498. exten => s,n,Noop(No text-to-speech handler for SayText, cannot say "${ARG1}")
  499. exten => s,n,Goto(done)
  500. exten => s,tts+101,Noop(tts handled saytext)
  501.  
  502. ; say name is for saying names typically, but fallsback to using SayAlpha
  503. ; (saying the word letter-by-letter)
  504. [macro-sayname]
  505. exten => s,1,Noop(Trying custom SayName playback for "${ARG1}")
  506. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  507. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  508. ; call tts-sayalpha. This should set MACRO_OFFSET=101 if it was successful
  509. exten => s,n(tts),Macro(tts-sayalpha,${ARG1},${ARG2},${ARG3})
  510. exten => s,n,SayAlpha(${ARG1})
  511. exten => s,n,Goto(done)
  512. exten => s,tts+101,Noop(tts handled sayname)
  513.  
  514. ; Say number is for saying numbers (eg "one thousand forty six")
  515. [macro-saynumber]
  516. exten => s,1,Noop(Trying custom SayNumber playback for "${ARG1}")
  517. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  518. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  519. ; call tts-saynumber. This should set MACRO_OFFSET=101 if it was successful
  520. exten => s,n(tts),Macro(tts-saynumber,${ARG1},${ARG2},${ARG3})
  521. exten => s,n,SayNumber(${ARG1})
  522. exten => s,n,Goto(done)
  523. exten => s,tts+101,Noop(tts handled saynumber)
  524.  
  525. ; Say digits is for saying digits one-by-one (eg, "one zero four six")
  526. [macro-saydigits]
  527. exten => s,1,Noop(Trying custom SayDigits playback for "${ARG1}")
  528. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  529. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  530. ; call tts-saydigits. This should set MACRO_OFFSET=101 if it was successful
  531. exten => s,n(tts),Macro(tts-saydigits,${ARG1},${ARG2},${ARG3})
  532. exten => s,n,SayDigits(${ARG1})
  533. exten => s,n,Goto(done)
  534.  
  535.  
  536. ;
  537. ; ############################################################################
  538. ; Inbound Contexts [from]
  539. ; ############################################################################
  540.  
  541. [from-sip-external]
  542. ;give external sip users congestion and hangup
  543. ; Yes. This is _really_ meant to be _. - I know asterisk whines about it, but
  544. ; I do know what I'm doing. This is correct.
  545. exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
  546. exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
  547. exten => _.,n,Goto(s,1)
  548. exten => s,1,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?from-trunk,${DID},1)
  549. exten => s,n,Set(TIMEOUT(absolute)=15)
  550. exten => s,n,Answer
  551. exten => s,n,Wait(2)
  552. exten => s,n,Playback(ss-noservice)
  553. exten => s,n,Playtones(congestion)
  554. exten => s,n,Congestion(5)
  555. exten => h,1,NoOp(Hangup)
  556. exten => i,1,NoOp(Invalid)
  557. exten => t,1,NoOp(Timeout)
  558.  
  559. [from-internal-xfer]
  560. ; applications are now mostly all found in from-internal-additional in _custom.conf
  561. include => from-internal-custom
  562. include => parkedcalls
  563. ;allow phones to dial other extensions
  564. include => ext-fax
  565. ;allow phones to access generated contexts
  566. ;
  567. ; MODIFIED (PL)
  568. ;
  569. ; Currently the include for findmefollow is being auto-generated before ext-local which is the desired behavior.
  570. ; However, I haven't been able to do anything that I know of to force this. We need to determine if it should
  571. ; be hardcoded into here to make sure it doesn't change with some configuration. For now I will leave it out
  572. ; until we can discuss this.
  573. ;
  574. include => ext-local-confirm
  575. include => findmefollow-ringallv2
  576. include => from-internal-additional
  577. ; This causes grief with '#' transfers, commenting out for the moment.
  578. ; include => bad-number
  579. exten => s,1,Macro(hangupcall)
  580. exten => h,1,Macro(hangupcall)
  581.  
  582. [from-internal]
  583. include => from-internal-xfer
  584. include => bad-number
  585.  
  586. ;------------------------------------------------------------------------
  587. ; [macro-setmusic]
  588. ;------------------------------------------------------------------------
  589. ; CONTEXT:      macro-setmusic
  590. ; PURPOSE:      to turn off moh on routes where it is not desired
  591. ;
  592. ;------------------------------------------------------------------------
  593. [macro-setmusic]
  594. exten => s,1,NoOp(Setting Outbound Route MoH To: ${ARG1})
  595. exten => s,2,SetMusicOnHold(${ARG1})
  596. ;------------------------------------------------------------------------
  597.  
  598. ; ##########################################
  599. ; ## Ring Groups with Confirmation macros ##
  600. ; ##########################################
  601. ; Used by followme and ringgroups
  602.  
  603. ;------------------------------------------------------------------------
  604. ; [macro-dial-confirm]
  605. ;------------------------------------------------------------------------
  606. ; This has now been incorporated into dialparties. It still only works with ringall
  607. ; and ringall-prim strategies. Have not investigated why it doesn't work with
  608. ; hunt and memory hunt.
  609. ;
  610. ;------------------------------------------------------------------------
  611. [macro-dial-confirm]
  612. ; This was written to make it easy to use macro-dial-confirm instead of macro-dial in generated dialplans.
  613. ; This takes the same parameters, with an additional parameter of the ring group Number
  614. ; ARG1 is the timeout
  615. ; ARG2 is the DIAL_OPTIONS
  616. ; ARG3 is a list of xtns to call - 203-222-240-123123123#-211
  617. ; ARG4 is the ring group number
  618.  
  619. ; This sets a unique value to indicate that the channel is ringing. This is used for warning slow
  620. ; users that the call has already been picked up.
  621. ;
  622. exten => s,1,Set(DB(RG/${ARG4}/${CHANNEL})=RINGING)
  623.  
  624. ; We need to keep that channel variable, because it'll change when we do this dial, so set it to
  625. ; fallthrough to every sibling.
  626. ;
  627. exten => s,n,Set(__UNIQCHAN=${CHANNEL})
  628.  
  629. ; The calling ringgroup should have set RingGroupMethod appropriately. We need to set two
  630. ; additional parameters:
  631. ;
  632. ; USE_CONFIRMATION, RINGGROUP_INDEX
  633. ;
  634. ; These are passed to inform dialparties to place external calls through the [grps] context
  635. ;
  636. exten => s,n,Set(USE_CONFIRMATION=TRUE)
  637. exten => s,n,Set(RINGGROUP_INDEX=${ARG4})
  638. exten => s,n,Set(ARG4=) ; otherwise it gets passed to dialparties.agi which processes it (prob bug)
  639.  
  640. exten => s,n,Macro(dial,${ARG1},${ARG2},${ARG3})
  641.  
  642. ; delete the variable, if we are here, we are done trying to dial and it may have been left around
  643. ;
  644. exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL})
  645. exten => s,n,Set(USE_CONFIRMATION=)
  646. exten => s,n,Set(RINGGROUP_INDEX=)
  647. ;------------------------------------------------------------------------
  648.  
  649.  
  650. ;------------------------------------------------------------------------
  651. ; [ext-local-confirm]
  652. ;------------------------------------------------------------------------
  653. ; If call confirm is being used in a ringgroup, then calls that do not require confirmation are sent
  654. ; to this extension instead of straight to the device.
  655. ;
  656. ; The sole purpose of sending them here is to make sure we run Macro(auto-confirm) if this
  657. ; extension answers the line. This takes care of clearing the database key that is used to inform
  658. ; other potential late comers that the extension has been answered by someone else.
  659. ;
  660. ; ALERT_INFO is deprecated in Asterisk 1.4 but still used throughout the FreePBX dialplan and
  661. ; usually set by dialparties.agi. This allows inheritance. Since no dialparties.agi here, set the
  662. ; header if it is set.
  663. ;
  664. ;------------------------------------------------------------------------
  665. [ext-local-confirm]
  666. exten => _LC-.,1,Noop(IN ext-local-confirm with - RT: ${RT}, RG_IDX: ${RG_IDX})
  667. exten => _LC-.,n,GotoIf($["x${ALERT_INFO}"="x"]?godial)
  668. exten => _LC-.,n,SIPAddHeader(Alert-Info: ${ALERT_INFO})
  669. exten => _LC-.,n(godial),dial(${DB(DEVICE/${EXTEN:3}/dial)},${RT},M(auto-confirm^${RG_IDX})${DIAL_OPTIONS})
  670.  
  671. ;------------------------------------------------------------------------
  672. ; [findmefollow-ringallv2]
  673. ;------------------------------------------------------------------------
  674. ; This context, to be included in from-internal, implements the PreRing part of findmefollow
  675. ; as well as the GroupRing part. It also communicates between the two so that if DND is set
  676. ; on the primary extension, and mastermode is enabled, then the other extensions will not ring
  677. ;
  678. ;------------------------------------------------------------------------
  679. [findmefollow-ringallv2]
  680. exten => _FMPR-.,1,Noop(In FMPR ${FMGRP} with ${EXTEN:5})
  681. exten => _FMPR-.,n,Set(RingGroupMethod=)
  682. exten => _FMPR-.,n,Set(USE_CONFIRMATION=)
  683. exten => _FMPR-.,n,Set(RINGGROUP_INDEX=)
  684. exten => _FMPR-.,n,Macro(simple-dial,${EXTEN:5},${FMREALPRERING})
  685. exten => _FMPR-.,n,GotoIf($["${DIALSTATUS}" != "BUSY"]?nodnd)
  686. exten => _FMPR-.,n,Set(DB(FM/DND/${FMGRP}/${FMUNIQUE})=DND)
  687. exten => _FMPR-.,n(nodnd),Noop(Ending FMPR ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
  688. exten => _FMPR-.,n,Hangup()
  689.  
  690. exten => _FMGL-.,1,Noop(In FMGL ${FMGRP} with ${EXTEN:5})
  691. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  692. exten => _FMGL-.,n,Wait(1)
  693. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  694. exten => _FMGL-.,n,Wait(1)
  695. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  696. exten => _FMGL-.,n,Wait(${FMPRERING})
  697. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  698. exten => _FMGL-.,n,DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
  699. exten => _FMGL-.,n(dodial),Macro(dial,${FMGRPTIME},${DIAL_OPTIONS},${EXTEN:5})
  700. exten => _FMGL-.,n,Noop(Ending FMGL ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
  701. exten => _FMGL-.,n,Hangup()
  702. exten => _FMGL-.,n+10(dodnd),DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
  703. exten => _FMGL-.,n,GotoIf($["${FMPRIME}" = "FALSE"]?dodial)
  704. exten => _FMGL-.,n,Noop(Got DND in FMGL ${FMGRP} with ${EXTEN:5} in ${RingGroupMethod} mode, aborting)
  705. exten => _FMGL-.,n,Hangup()
  706.  
  707. ;------------------------------------------------------------------------
  708. ; [block-cf]
  709. ;------------------------------------------------------------------------
  710. ; This context is set as a target with FORWARD_CONTEXT when Call Forwarding is set to be
  711. ; ignored in a ringgroup or other features that may take advantage of this. Server side
  712. ; CF is done in dialparties.agi but if a client device forwards a call, it will be caught
  713. ; and blocked here.
  714. ;------------------------------------------------------------------------
  715. [block-cf]
  716. exten => _X.,1,Noop(Blocking callforward to ${EXTEN} because CF is blocked)
  717. exten => _X.,n,Hangup()
  718.  
  719. ;------------------------------------------------------------------------
  720.  
  721. ; ############################################################################
  722. ; Extension Contexts [ext]
  723. ; ############################################################################
  724.  
  725. [ext-fax]
  726. exten => s,1,Answer
  727. exten => s,2,Goto(in_fax,1)
  728. exten => in_fax,1,StopPlayTones  
  729. exten => in_fax,2,GotoIf($["${FAX_RX}" = "system"]?3:analog_fax,1)
  730. exten => in_fax,3,Macro(faxreceive)
  731. exten => in_fax,4,Hangup
  732. exten => analog_fax,1,GotoIf($["${FAX_RX}" = "disabled"]?4:2)  ;if fax is disabled, just hang up
  733. exten => analog_fax,2,Set(DIAL=${DB(DEVICE/${FAX_RX}/dial)});
  734. exten => analog_fax,3,Dial(${DIAL},20,d)
  735. exten => analog_fax,4,Hangup
  736. ;exten => out_fax,1,wait(7)
  737. exten => out_fax,1,txfax(${TXFAX_NAME},caller)
  738. exten => out_fax,2,Hangup
  739. exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --dest "${FROM_DID}" --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE});
  740. exten => h,2,Hangup()
  741.  
  742. ;this is where parked calls go if they time-out.  Should probably re-ring
  743. [default]
  744. include => ext-local
  745. exten => s,1,Playback(vm-goodbye)
  746. exten => s,2,Macro(hangupcall)
  747.  
  748. [a2billing]
  749. exten => _X.,1,Answer
  750. exten => _X.,2,Wait,2
  751. exten => _X.,3,DeadAGI,a2billing.php
  752. exten => _X.,4,Wait,2
  753. exten => _X.,5,Hangup
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top