Advertisement
Guest User

Untitled

a guest
Dec 29th, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.91 KB | None | 0 0
  1. ;-------------------------------------------------------------------------------
  2. ; from-pstn-to-did
  3. ;
  4. ; The context is designed for providers who send the DID in the TO: SIP header
  5. ; only. The format of this header is:
  6. ;
  7. ; To: <sip:2125551212@172.31.74.25>
  8. ;
  9. ; So the DID must be extracted between the sip: and the @, which this does
  10. ;
  11. [from-pstn-toheader]
  12. exten => _.,1,Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
  13. ;-------------------------------------------------------------------------------
  14.  
  15.  
  16. ; MODIFICATION (PL)
  17. ;
  18. ; Required to assure that direct dids go to personal ring group before local extension.
  19. ; This could be auto-generated however I it is preferred to be put here and hard coded
  20. ; so that it can be modified if ext-local should take precedence in certain situations.
  21. ; will have to decide what to do later.
  22. ;
  23. [from-did-direct]
  24. include => ext-findmefollow
  25. include => ext-local
  26.  
  27.  
  28. ; ############################################################################
  29. ; Macros [macro]
  30. ; ############################################################################
  31.  
  32. ; Rings one or more extensions. Handles things like call forwarding and DND
  33. ; We don't call dial directly for anything internal anymore.
  34. ; ARGS: $TIMER, $OPTIONS, $EXT1, $EXT2, $EXT3, ...
  35. ; Use a Macro call such as the following:
  36. ; Macro(dial,$DIAL_TIMER,$DIAL_OPTIONS,$EXT1,$EXT2,$EXT3,...)
  37. [macro-dial]
  38. exten => s,1,GotoIf($["${MOHCLASS}" = ""]?dial)
  39. exten => s,n,SetMusicOnHold(${MOHCLASS})
  40. exten => s,n(dial),AGI(dialparties.agi)
  41. exten => s,n,NoOp(Returned from dialparties with no extensions to call and DIALSTATUS: ${DIALSTATUS})
  42.  
  43. exten => s,n+2(normdial),Dial(${ds}) ; dialparties will set the priority to 10 if $ds is not null
  44. exten => s,n,Set(DIALSTATUS=${IF($["${DIALSTATUS_CW}"!="" ]?${DIALSTATUS_CW}:${DIALSTATUS})})
  45. exten => s,n,GosubIf($["${SCREEN}" != "" | "${DIALSTATUS}" = "ANSWER"]?${DIALSTATUS},1)
  46.  
  47. exten => s,20(huntdial),NoOp(Returned from dialparties with hunt groups to dial )
  48. exten => s,n,Set(HuntLoop=0)
  49. exten => s,n(a22),GotoIf($[${HuntMembers} >= 1]?a30) ; if this is from rg-group, don't strip prefix
  50. exten => s,n,NoOp(Returning there are no members left in the hunt group to ring)
  51.  
  52. ; dialparties.agi has setup the dialstring for each hunt member in a variable labeled HuntMember0, HuntMember1 etc for each iteration
  53. ; and The total number in HuntMembers. So for each iteration, we will update the CALLTRACE Data.
  54. ;
  55. exten => s,n+2(a30),Set(HuntMember=HuntMember${HuntLoop})
  56. exten => s,n,GotoIf($[$["${CALLTRACE_HUNT}" != "" ] & $[$["${RingGroupMethod}" = "hunt" ] | $["${RingGroupMethod}" = "firstavailable"] | $["${RingGroupMethod}" = "firstnotonphone"]]]?a32:a35)
  57.  
  58. exten => s,n(a32),Set(CT_EXTEN=${CUT(FILTERED_DIAL,,$[${HuntLoop} + 1])})
  59. exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
  60. exten => s,n,Goto(s,a42)
  61.  
  62. ;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
  63. ;
  64. exten => s,n(a35),GotoIf($[$["${CALLTRACE_HUNT}" != "" ] & $["${RingGroupMethod}" = "memoryhunt" ]]?a36:a50)
  65. exten => s,n(a36),Set(CTLoop=0)
  66. exten => s,n(a37),GotoIf($[${CTLoop} > ${HuntLoop}]?a42) ; if this is from rg-group, don't strip prefix
  67. exten => s,n,Set(CT_EXTEN=${CUT(FILTERED_DIAL,,$[${CTLoop} + 1])})
  68. exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
  69. exten => s,n,Set(CTLoop=$[1 + ${CTLoop}])
  70. exten => s,n,Goto(s,a37)
  71.  
  72. exten => s,n(a42),Dial(${${HuntMember}}${ds})
  73. exten => s,n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?ANSWER,1)
  74. exten => s,n,Set(HuntLoop=$[1 + ${HuntLoop}])
  75. exten => s,n,GotoIf($[$[$["foo${RingGroupMethod}" != "foofirstavailable"] & $["foo${RingGroupMethod}" != "foofirstnotonphone"]] | $["foo${DialStatus}" = "fooBUSY"]]?a46)
  76. exten => s,n,Set(HuntMembers=0)
  77. exten => s,n(a46),Set(HuntMembers=$[${HuntMembers} - 1])
  78. exten => s,n,Goto(s,a22)
  79.  
  80. exten => s,n(a50),DBdel(CALLTRACE/${CT_EXTEN})
  81. exten => s,n,Goto(s,a42)
  82.  
  83. ; For call screening
  84. exten => NOANSWER,1,Macro(vm,${SCREEN_EXTEN},BUSY,${IVR_RETVM})
  85. exten => NOANSWER,n,GotoIf($["${IVR_RETVM}" != "RETURN" | "${IVR_CONTEXT}" = ""]?bye)
  86. exten => NOANSWER,n,Return
  87. exten => NOANSWER,n(bye),Macro(hangupcall)
  88. exten => TORTURE,1,Goto(app-blackhole,musiconhold,1)
  89. exten => TORTURE,n,Macro(hangupcall)
  90. exten => DONTCALL,1,Answer
  91. exten => DONTCALL,n,Wait(1)
  92. exten => DONTCALL,n,Zapateller()
  93. exten => DONTCALL,n,Playback(ss-noservice)
  94. exten => DONTCALL,n,Macro(hangupcall)
  95. exten => ANSWER,1,Noop(Call successfully answered - Hanging up now)
  96. exten => ANSWER,n,Macro(hangupcall,)
  97.  
  98. ; make sure hungup calls go here so that proper cleanup occurs from call confirmed calls and the like
  99. ;
  100. exten => h,1,Macro(hangupcall)
  101.  
  102. ; get the voicemail context for the user in ARG1
  103. [macro-get-vmcontext]
  104. exten => s,1,Set(VMCONTEXT=${DB(AMPUSER/${ARG1}/voicemail)})
  105. exten => s,2,GotoIf($["foo${VMCONTEXT}" = "foo"]?200:300)
  106. exten => s,200,Set(VMCONTEXT=default)
  107. exten => s,300,NoOp()
  108.  
  109. ; For some reason, if I don't run setCIDname, CALLERID(name) will be blank in my AGI
  110. ; ARGS: none
  111. [macro-fixcid]
  112. exten => s,1,Set(CALLERID(name)=${CALLERID(name)})
  113.  
  114. ; Ring groups of phones
  115. ; ARGS: comma separated extension list
  116. ; 1 - Ring Group Strategy
  117. ; 2 - ringtimer
  118. ; 3 - prefix
  119. ; 4 - extension list
  120. [macro-rg-group]
  121. exten => s,1,Macro(user-callerid,SKIPTTL) ; already called from ringgroup
  122. exten => s,2,GotoIf($["${CALLERID(name):0:${LEN(${RGPREFIX})}}" != "${RGPREFIX}"]?4:3) ; check for old prefix
  123. exten => s,3,Set(CALLERID(name)=${CALLERID(name):${LEN(${RGPREFIX})}}) ; strip off old prefix
  124. exten => s,4,Set(RGPREFIX=${ARG3}) ; set new prefix
  125. exten => s,5,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)}) ; add prefix to callerid name
  126. exten => s,6,Set(RecordMethod=Group) ; set new prefix
  127. exten => s,7,Macro(record-enable,${MACRO_EXTEN},${RecordMethod})
  128. exten => s,8,Set(RingGroupMethod=${ARG1}) ;
  129. exten => s,9,Macro(dial,${ARG2},${DIAL_OPTIONS},${ARG4})
  130. exten => s,10,Set(RingGroupMethod='') ;
  131.  
  132.  
  133. ;
  134. ; Outgoing channel(s) are busy ... inform the client
  135. ; but use noanswer features like ringgroups don't break by being answered
  136. ; just to play the message.
  137. ;
  138. [macro-outisbusy]
  139. exten => s,1,Progress
  140. exten => s,n,Playback(all-circuits-busy-now,noanswer)
  141. exten => s,n,Playback(pls-try-call-later,noanswer)
  142. exten => s,n,Macro(hangupcall)
  143.  
  144. ; dialout and strip the prefix
  145. [macro-dialout]
  146. exten => s,1,Macro(user-callerid,SKIPTTL)
  147. exten => s,2,GotoIf($["${ECID${CALLERID(number)}}" = ""]?5) ;check for CID override for exten
  148. exten => s,3,Set(CALLERID(all)=${ECID${CALLERID(number)}})
  149. exten => s,4,Goto(7)
  150. exten => s,5,GotoIf($["${OUTCID_${ARG1}}" = ""]?7) ;check for CID override for trunk
  151. exten => s,6,Set(CALLERID(all)=${OUTCID_${ARG1}})
  152. exten => s,7,Set(length=${LEN(${DIAL_OUT_${ARG1}})})
  153. exten => s,8,Dial(${OUT_${ARG1}}/${ARG2:${length}})
  154. exten => s,9,Playtones(congestion)
  155. exten => s,10,Congestion(5)
  156. exten => s,109,Macro(outisbusy)
  157.  
  158.  
  159. ; dialout using default OUT trunk - no prefix
  160. [macro-dialout-default]
  161. exten => s,1,Macro(user-callerid,SKIPTTL)
  162. exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)
  163. exten => s,3,Macro(outbound-callerid,${ARG1})
  164. exten => s,4,Dial(${OUT}/${ARG1})
  165. exten => s,5,Playtones(congestion)
  166. exten => s,6,Congestion(5)
  167. exten => s,105,Macro(outisbusy)
  168.  
  169. [macro-dialout-trunk-predial-hook]
  170. ; this macro intentionally left blank so it may be safely overwritten for any custom
  171. ; requirements that an installation may have.
  172. ;
  173. ; MACRO RETURN CODE: ${PREDIAL_HOOK_RET}
  174. ; if set to "BYPASS" then this trunk will be skipped
  175. ;
  176. exten => s,1,MacroExit()
  177.  
  178. [macro-user-logon]
  179. ; check device type
  180. ;
  181. exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
  182. exten => s,n,Answer()
  183. exten => s,n,Wait(1)
  184. exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
  185. ; get user's extension
  186. ;
  187. exten => s,n,Set(AMPUSER=${ARG1})
  188. exten => s,n,GotoIf($["${AMPUSER}" != ""]?gotpass)
  189. exten => s,n(playagain),Read(AMPUSER,please-enter-your-extension-then-press-pound,,,4)
  190. ; get user's password and authenticate
  191. ;
  192. exten => s,n,GotoIf($["${AMPUSER}" = ""]?s-MAXATTEMPTS,1)
  193. exten => s,n(gotpass),GotoIf($["${DB_EXISTS(AMPUSER/${AMPUSER}/password)}" = "0"]?s-NOUSER,1)
  194. exten => s,n,Set(AMPUSERPASS=${DB_RESULT})
  195. exten => s,n,GotoIf($[${LEN(${AMPUSERPASS})} = 0]?s-NOPASSWORD,1)
  196. ; do not continue if the user has already logged onto this device
  197. ;
  198. exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
  199. exten => s,n,GotoIf($["${DEVICEUSER}" = "${AMPUSER}"]?s-ALREADYLOGGEDON,1)
  200. exten => s,n,Authenticate(${AMPUSERPASS})
  201. exten => s,n,AGI(user_login_out.agi,login,${CALLERID(number)},${AMPUSER})
  202. exten => s,n,Playback(vm-goodbye)
  203.  
  204. exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into)
  205. exten => s-FIXED,n,Playback(ha/phone)
  206. exten => s-FIXED,n,SayDigits(${CALLERID(number)})
  207. exten => s-FIXED,n,Playback(is-curntly-unavail&vm-goodbye)
  208. exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into
  209.  
  210. exten => s-ALREADYLOGGEDON,1,NoOp(This device has already been logged into by this user)
  211. exten => s-ALREADYLOGGEDON,n,Playback(vm-goodbye)
  212. exten => s-ALREADYLOGGEDON,n,Hangup ;TODO should play msg indicated device is already logged into
  213.  
  214. exten => s-NOPASSWORD,1,NoOp(This extension does not exist or no password is set)
  215. exten => s-NOPASSWORD,n,Playback(pbx-invalid)
  216. exten => s-NOPASSWORD,n,Goto(s,playagain)
  217.  
  218. exten => s-MAXATTEMPTS,1,NoOp(Too many login attempts)
  219. exten => s-MAXATTEMPTS,n,Playback(vm-goodbye)
  220. exten => s-MAXATTEMPTS,n,Hangup
  221.  
  222. exten => s-NOUSER,1,NoOp(Invalid extension ${AMPUSER} entered)
  223. exten => s-NOUSER,n,Playback(pbx-invalid)
  224. exten => s-NOUSER,n,Goto(s,playagain)
  225.  
  226. [macro-user-logoff]
  227. ; check device type
  228. ;
  229. exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
  230. exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
  231. exten => s,n,AGI(user_login_out.agi,logout,${CALLERID(number)})
  232. exten => s,n(done),Playback(vm-goodbye)
  233.  
  234. exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of)
  235. exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye)
  236. exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into
  237.  
  238.  
  239.  
  240. ; Privacy Manager Macro makes sure that any calls that don't pass the privacy manager are presented
  241. ; with congestion since there have been observed cases of the call continuing if not stopped with a
  242. ; congestion, and this provides a slightly more friendly 'sorry' message in case the user is
  243. ; legitimately trying to be cooperative.
  244. ;
  245. ; Note: the following options are configurable in privacy.conf:
  246. ;
  247. ; maxretries = 3 ; default value, number of retries before failing
  248. ; minlength = 10 ; default value, number of digits to be accepted as valid CID
  249. ;
  250. [macro-privacy-mgr]
  251. exten => s,1,Set(KEEPCID=${CALLERID(num)})
  252. exten => s,n,GotoIf($["foo${CALLERID(num):0:1}"="foo+"]?CIDTEST2:CIDTEST1)
  253. exten => s,n(CIDTEST1),Set(TESTCID=${MATH(1+${CALLERID(num)})})
  254. exten => s,n,Goto(TESTRESULT)
  255. exten => s,n(CIDTEST2),Set(TESTCID=${MATH(1+${CALLERID(num):1})})
  256. exten => s,n(TESTRESULT),GotoIf($["foo${TESTCID}"="foo"]?CLEARCID:PRIVMGR)
  257. exten => s,n(CLEARCID),Set(CALLERID(num)=)
  258. exten => s,n(PRIVMGR),PrivacyManager(${ARG1},${ARG2})
  259. exten => s,n,GotoIf($["${PRIVACYMGRSTATUS}"="FAILED"]?fail)
  260. exten => s,n,GosubIf($["${CALLED_BLACKLIST}" = "1"]?app-blacklist-check,s,1)
  261. exten => s,n,SetCallerPres(allowed_passed_screen); stop gap until app_privacy.c clears unavailable bit
  262. exten => s,PRIVMGR+101(fail),Noop(STATUS: ${PRIVACYMGRSTATUS} CID: ${CALLERID(num)} ${CALLERID(name)} CALLPRES: ${CALLLINGPRES})
  263. exten => s,n,Playback(sorry-youre-having-problems)
  264. exten => s,n,Playback(goodbye)
  265. exten => s,n,Playtones(congestion)
  266. exten => s,n,Congestion(5)
  267. exten => h,1,Hangup
  268.  
  269.  
  270.  
  271. ; Text-To-Speech related macros
  272. ; These all follow common actions. First try to playback a file "tts/custom-md5"
  273. ; where "md5" is the md5() of whatever is going to be played. If that doesn't exist,
  274. ; try to playback using macro-tts-sayXXXXX (where XXXXX is text/digits/etc, same as
  275. ; the macro below). If that macro exits with MACRO_OFFSET=100, then it's done,
  276. ; otherwise, fallback to the default asterisk method.
  277. ;
  278. ; say text is purely for text-to-speech, there is no fallback
  279. [macro-saytext]
  280. exten => s,1,Noop(Trying custom SayText playback for "${ARG1}")
  281. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  282. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  283. ; call tts-saytext. This should set MACRO_OFFSET=101 if it was successful
  284. exten => s,n(tts),Macro(tts-saytext,${ARG1},${ARG2},${ARG3})
  285. exten => s,n,Noop(No text-to-speech handler for SayText, cannot say "${ARG1}")
  286. exten => s,n,Goto(done)
  287. exten => s,tts+101,Noop(tts handled saytext)
  288.  
  289. ; say name is for saying names typically, but fallsback to using SayAlpha
  290. ; (saying the word letter-by-letter)
  291. [macro-sayname]
  292. exten => s,1,Noop(Trying custom SayName playback for "${ARG1}")
  293. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  294. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  295. ; call tts-sayalpha. This should set MACRO_OFFSET=101 if it was successful
  296. exten => s,n(tts),Macro(tts-sayalpha,${ARG1},${ARG2},${ARG3})
  297. exten => s,n,SayAlpha(${ARG1})
  298. exten => s,n,Goto(done)
  299. exten => s,tts+101,Noop(tts handled sayname)
  300.  
  301. ; Say number is for saying numbers (eg "one thousand forty six")
  302. [macro-saynumber]
  303. exten => s,1,Noop(Trying custom SayNumber playback for "${ARG1}")
  304. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  305. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  306. ; call tts-saynumber. This should set MACRO_OFFSET=101 if it was successful
  307. exten => s,n(tts),Macro(tts-saynumber,${ARG1},${ARG2},${ARG3})
  308. exten => s,n,SayNumber(${ARG1})
  309. exten => s,n,Goto(done)
  310. exten => s,tts+101,Noop(tts handled saynumber)
  311.  
  312. ; Say digits is for saying digits one-by-one (eg, "one zero four six")
  313. [macro-saydigits]
  314. exten => s,1,Noop(Trying custom SayDigits playback for "${ARG1}")
  315. exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
  316. exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
  317. ; call tts-saydigits. This should set MACRO_OFFSET=101 if it was successful
  318. exten => s,n(tts),Macro(tts-saydigits,${ARG1},${ARG2},${ARG3})
  319. exten => s,n,SayDigits(${ARG1})
  320. exten => s,n,Goto(done)
  321.  
  322.  
  323. ;
  324. ; ############################################################################
  325. ; Inbound Contexts [from]
  326. ; ############################################################################
  327.  
  328. [from-sip-external]
  329. ; Yes. This is _really_ meant to be _. - I know asterisk whines about it, but
  330. ; I do know what I'm doing. This is correct.
  331. exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
  332. exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
  333. exten => _.,n,Goto(s,1)
  334. exten => s,1,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?checklang:noanonymous)
  335. exten => s,n(checklang),GotoIf($["${SIPLANG}"!=""]?setlanguage:from-trunk,${DID},1)
  336. exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
  337. exten => s,n,Goto(from-trunk,${DID},1)
  338. exten => s,n(noanonymous),Set(TIMEOUT(absolute)=15)
  339. exten => s,n,Answer
  340. exten => s,n,Wait(2)
  341. exten => s,n,Playback(ss-noservice)
  342. exten => s,n,Playtones(congestion)
  343. exten => s,n,Congestion(5)
  344. exten => h,1,Hangup
  345. exten => i,1,Hangup
  346. exten => t,1,Hangup
  347.  
  348. [from-internal-xfer]
  349. ; applications are now mostly all found in from-internal-additional in _custom.conf
  350. include => from-internal-custom
  351. include => parkedcalls
  352.  
  353. ; MODIFIED (PL)
  354. ;
  355. ; Currently the include for findmefollow is being auto-generated before ext-local which is the desired behavior.
  356. ; However, I haven't been able to do anything that I know of to force this. We need to determine if it should
  357. ; be hardcoded into here to make sure it doesn't change with some configuration. For now I will leave it out
  358. ; until we can discuss this.
  359. ;
  360. include => ext-local-confirm
  361. include => findmefollow-ringallv2
  362. include => from-internal-additional
  363. ; This causes grief with '#' transfers, commenting out for the moment.
  364. ; include => bad-number
  365. exten => s,1,Macro(hangupcall)
  366. exten => h,1,Macro(hangupcall)
  367.  
  368. [from-internal]
  369. include => from-internal-xfer
  370. include => bad-number
  371.  
  372. ;------------------------------------------------------------------------
  373. ; [macro-setmusic]
  374. ;------------------------------------------------------------------------
  375. ; CONTEXT: macro-setmusic
  376. ; PURPOSE: to turn off moh on routes where it is not desired
  377. ;
  378. ;------------------------------------------------------------------------
  379. [macro-setmusic]
  380. exten => s,1,NoOp(Setting Outbound Route MoH To: ${ARG1})
  381. exten => s,2,Set(CHANNEL(musicclass)=${ARG1}) ; this won't work in 1.2 anymore, could fix in auto-generate if we wanted...
  382. ;------------------------------------------------------------------------
  383.  
  384. ; ##########################################
  385. ; ## Ring Groups with Confirmation macros ##
  386. ; ##########################################
  387. ; Used by followme and ringgroups
  388.  
  389. ;------------------------------------------------------------------------
  390. ; [macro-dial-confirm]
  391. ;------------------------------------------------------------------------
  392. ; This has now been incorporated into dialparties. It still only works with ringall
  393. ; and ringall-prim strategies. Have not investigated why it doesn't work with
  394. ; hunt and memory hunt.
  395. ;
  396. ;------------------------------------------------------------------------
  397. [macro-dial-confirm]
  398. ; This was written to make it easy to use macro-dial-confirm instead of macro-dial in generated dialplans.
  399. ; This takes the same parameters, with an additional parameter of the ring group Number
  400. ; ARG1 is the timeout
  401. ; ARG2 is the DIAL_OPTIONS
  402. ; ARG3 is a list of xtns to call - 203-222-240-123123123#-211
  403. ; ARG4 is the ring group number
  404.  
  405. ; This sets a unique value to indicate that the channel is ringing. This is used for warning slow
  406. ; users that the call has already been picked up.
  407. ;
  408. exten => s,1,Set(DB(RG/${ARG4}/${CHANNEL})=RINGING)
  409.  
  410. ; We need to keep that channel variable, because it'll change when we do this dial, so set it to
  411. ; fallthrough to every sibling.
  412. ;
  413. exten => s,n,Set(__UNIQCHAN=${CHANNEL})
  414.  
  415. ; The calling ringgroup should have set RingGroupMethod appropriately. We need to set two
  416. ; additional parameters:
  417. ;
  418. ; USE_CONFIRMATION, RINGGROUP_INDEX
  419. ;
  420. ; These are passed to inform dialparties to place external calls through the [grps] context
  421. ;
  422. exten => s,n,Set(USE_CONFIRMATION=TRUE)
  423. exten => s,n,Set(RINGGROUP_INDEX=${ARG4})
  424. exten => s,n,Set(ARG4=) ; otherwise it gets passed to dialparties.agi which processes it (prob bug)
  425.  
  426. exten => s,n,Macro(dial,${ARG1},${ARG2},${ARG3})
  427.  
  428. ; delete the variable, if we are here, we are done trying to dial and it may have been left around
  429. ;
  430. exten => s,n,Noop(DELETE KEY: RG/${RINGGROUP_INDEX}/${CHANNEL}: ${DB_DELETE(RG/${RINGGROUP_INDEX}/${CHANNEL})})
  431. exten => s,n,Set(USE_CONFIRMATION=)
  432. exten => s,n,Set(RINGGROUP_INDEX=)
  433. ;------------------------------------------------------------------------
  434.  
  435.  
  436. ;------------------------------------------------------------------------
  437. ; [ext-local-confirm]
  438. ;------------------------------------------------------------------------
  439. ; If call confirm is being used in a ringgroup, then calls that do not require confirmation are sent
  440. ; to this extension instead of straight to the device.
  441. ;
  442. ; The sole purpose of sending them here is to make sure we run Macro(auto-confirm) if this
  443. ; extension answers the line. This takes care of clearing the database key that is used to inform
  444. ; other potential late comers that the extension has been answered by someone else.
  445. ;
  446. ; ALERT_INFO is deprecated in Asterisk 1.4 but still used throughout the FreePBX dialplan and
  447. ; usually set by dialparties.agi. This allows inheritance. Since no dialparties.agi here, set the
  448. ; header if it is set.
  449. ;
  450. ;------------------------------------------------------------------------
  451. [ext-local-confirm]
  452. exten => _LC-.,1,Noop(IN ext-local-confirm with - RT: ${RT}, RG_IDX: ${RG_IDX})
  453. exten => _LC-.,n,GotoIf($["x${ALERT_INFO}"="x"]?godial)
  454. exten => _LC-.,n,SIPAddHeader(Alert-Info: ${ALERT_INFO})
  455. exten => _LC-.,n(godial),dial(${DB(DEVICE/${EXTEN:3}/dial)},${RT},M(auto-confirm^${RG_IDX})${DIAL_OPTIONS})
  456.  
  457. ;------------------------------------------------------------------------
  458. ; [findmefollow-ringallv2]
  459. ;------------------------------------------------------------------------
  460. ; This context, to be included in from-internal, implements the PreRing part of findmefollow
  461. ; as well as the GroupRing part. It also communicates between the two so that if DND is set
  462. ; on the primary extension, and mastermode is enabled, then the other extensions will not ring
  463. ;
  464. ;------------------------------------------------------------------------
  465. [findmefollow-ringallv2]
  466. exten => _FMPR-.,1,Noop(In FMPR ${FMGRP} with ${EXTEN:5})
  467. exten => _FMPR-.,n,Set(RingGroupMethod=)
  468. exten => _FMPR-.,n,Set(USE_CONFIRMATION=)
  469. exten => _FMPR-.,n,Set(RINGGROUP_INDEX=)
  470. exten => _FMPR-.,n,Macro(simple-dial,${EXTEN:5},${FMREALPRERING})
  471. exten => _FMPR-.,n,GotoIf($["${DIALSTATUS}" != "BUSY"]?nodnd)
  472. exten => _FMPR-.,n,Set(DB(FM/DND/${FMGRP}/${FMUNIQUE})=DND)
  473. exten => _FMPR-.,n(nodnd),Noop(Ending FMPR ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
  474. exten => _FMPR-.,n,Hangup()
  475.  
  476. exten => _FMGL-.,1,Noop(In FMGL ${FMGRP} with ${EXTEN:5})
  477. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  478. exten => _FMGL-.,n,Wait(1)
  479. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  480. exten => _FMGL-.,n,Wait(1)
  481. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  482. exten => _FMGL-.,n,Wait(${FMPRERING})
  483. exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
  484. exten => _FMGL-.,n,DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
  485. exten => _FMGL-.,n(dodial),Macro(dial,${FMGRPTIME},${DIAL_OPTIONS},${EXTEN:5})
  486. exten => _FMGL-.,n,Noop(Ending FMGL ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
  487. exten => _FMGL-.,n,Hangup()
  488. exten => _FMGL-.,n+10(dodnd),DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
  489. exten => _FMGL-.,n,GotoIf($["${FMPRIME}" = "FALSE"]?dodial)
  490. exten => _FMGL-.,n,Noop(Got DND in FMGL ${FMGRP} with ${EXTEN:5} in ${RingGroupMethod} mode, aborting)
  491. exten => _FMGL-.,n,Hangup()
  492.  
  493. ;------------------------------------------------------------------------
  494. ; [block-cf]
  495. ;------------------------------------------------------------------------
  496. ; This context is set as a target with FORWARD_CONTEXT when Call Forwarding is set to be
  497. ; ignored in a ringgroup or other features that may take advantage of this. Server side
  498. ; CF is done in dialparties.agi but if a client device forwards a call, it will be caught
  499. ; and blocked here.
  500. ;------------------------------------------------------------------------
  501. [block-cf]
  502. exten => _X.,1,Noop(Blocking callforward to ${EXTEN} because CF is blocked)
  503. exten => _X.,n,Hangup()
  504.  
  505. ;------------------------------------------------------------------------
  506.  
  507.  
  508. ;this is where parked calls go if they time-out. Should probably re-ring
  509. [default]
  510. include => ext-local
  511. exten => s,1,Playback(vm-goodbye)
  512. exten => s,2,Macro(hangupcall)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement