;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make    ;
; custom modifications, details at: http://freepbx.org/configuration_files       ;
;--------------------------------------------------------------------------------;
;

[globals]
QUEDEVSTATE = TRUE
QUEUETOGGLE = *45
QUEUEPAUSETOGGLE = *46
CFDEVSTATE = TRUE
FMDEVSTATE = TRUE
DNDDEVSTATE = TRUE
OPERATOR_XTN = 
VM_OPTS = 
VM_GAIN = 
VM_DDTYPE = u
VMX_OPTS_LOOP = 
VMX_OPTS_DOVM = 
VMX_TIMEOUT = 2
VMX_REPEAT = 1
VMX_LOOPS = 1
DYNAMIC_FEATURES = apprecord
INTERCOMCODE = nointercom
FAX_RX = system
FAX_RX_EMAIL = fax@mydomain.com
FAX_RX_FROM = freepbx@gmail.com
ASTETCDIR = /etc/asterisk
ASTMODDIR = /usr/lib64/asterisk/modules
ASTVARLIBDIR = /var/lib/asterisk
ASTAGIDIR = /var/lib/asterisk/agi-bin
ASTSPOOLDIR = /var/spool/asterisk
ASTRUNDIR = /var/run/asterisk
ASTLOGDIR = /var/log/asterisk
CWINUSEBUSY = true
AMPMGRUSER = admin
AMPMGRPASS = f1l@r@k1
AMPDBENGINE = mysql
AMPDBHOST = localhost
AMPDBNAME = asterisk
AMPDBUSER = asteriskuser
AMPDBPASS = f1l@r@k1
VMX_CONTEXT = from-internal
VMX_PRI = 1
VMX_TIMEDEST_CONTEXT = 
VMX_TIMEDEST_EXT = dovm
VMX_TIMEDEST_PRI = 1
VMX_LOOPDEST_CONTEXT = 
VMX_LOOPDEST_EXT = dovm
VMX_LOOPDEST_PRI = 1
MIXMON_DIR = 
MIXMON_POST = 
DIAL_OPTIONS = tr
TRUNK_OPTIONS = 
TRUNK_RING_TIMER = 300
MIXMON_FORMAT = wav
REC_POLICY = caller
RINGTIMER_DEFAULT = 15
TRANSFER_CONTEXT = from-internal-xfer
ASTVERSION = 11.10.0
ASTCHANDAHDI = 1
NULL = ""
OUT_2 = SIP/IMS_2106528457
OUTCID_2 = +302106528457
OUTMAXCHANS_2 = 
OUTFAIL_2 = 
OUTPREFIX_2 = 
OUTDISABLE_2 = on
OUTKEEPCID_2 = off
FORCEDOUTCID_2 = 
PREFIX_TRUNK_2 = 
ALLOW_SIP_ANON = no
#include globals_custom.conf

;end of [globals]

[macro-parked-call]
include => macro-parked-call-custom
exten => s,1,AGI(parkfetch.agi,${ARG1})
exten => s,n,GotoIf($["${REC_STATUS}" != "RECORDING"]?next)
exten => s,n,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => s,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => s,n,MixMonitor(${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT},a,${MIXMON_POST})
exten => s,n(next),Set(CCSS_SETUP=TRUE)
exten => s,n,Macro(user-callerid,)
exten => s,n,GotoIf($["${ARG1}" = "" | ${DIALPLAN_EXISTS(${IF($["${ARG2}" = "default"]?parkedcalls:${ARG2})},${ARG1},1)} = 1]?pcall)
exten => s,n,ResetCDR()
exten => s,n,NoCDR()
exten => s,n,Wait(1)
exten => s,n,Playback(pbx-invalidpark)
exten => s,n,Wait(1)
exten => s,n,Hangup
exten => s,n(pcall),Noop(User: ${CALLERID(all)} attempting to pick up Parked Call Slot ${ARG1})
exten => s,n,ParkedCall(${ARG1},${ARG2})

exten => h,1,Macro(hangupcall,)

;--== end of [macro-parked-call] ==--;


[parkedcallstimeout]
include => parkedcallstimeout-custom
exten => _[0-9a-zA-Z*#].,1,Set(PARK_TARGET=${EXTEN})
exten => _[0-9a-zA-Z*#].,n,GotoIf($["${REC_STATUS}" != "RECORDING"]?next)
exten => _[0-9a-zA-Z*#].,n,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => _[0-9a-zA-Z*#].,n,MixMonitor(${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT},a,${MIXMON_POST})
exten => _[0-9a-zA-Z*#].,n(next),Goto(park-return-routing,${PARKINGSLOT},1)

;--== end of [parkedcallstimeout] ==--;


[park-dial]
include => park-dial-custom
exten => t,1,Noop(WARNING: PARKRETURN to: [${EXTEN}] failed with: [${DIALSTATUS}]. Trying Alternate Dest On Parking Lot ${PARKINGSLOT})
exten => t,n,Goto(park-orphan-routing,1)

exten => _[0-9a-zA-Z*#].,1,Noop(WARNING: PARKRETURN to: [${EXTEN}] failed with: [${DIALSTATUS}]. Trying Alternate Dest On Parking Lot ${PARKINGSLOT})
exten => _[0-9a-zA-Z*#].,n,Goto(park-orphan-routing,1)

;--== end of [park-dial] ==--;


[park-orphan-routing]
include => park-orphan-routing-custom
exten => ,1,Goto(app-blackhole,hangup,1)

;--== end of [park-orphan-routing] ==--;


[park-return-routing]
include => park-return-routing-custom
exten => ,1,Set(PLOT=)
exten => ,n,Goto(park-dial,${PARK_TARGET},1)
exten => ,n,Goto(app-blackhole,hangup,1)
exten => ,n,Goto(1)

exten => 1,1,Goto(1)

exten => 2,1,Goto(1)

exten => 3,1,Goto(1)

;--== end of [park-return-routing] ==--;


[park-hints]
include => park-hints-custom
include => parkedcalls ; Default Lot
exten => ,1,Macro(parked-call,,default)
exten => ,hint,park:@parkedcalls

exten => 1,1,Macro(parked-call,1,default)
exten => 1,hint,park:1@parkedcalls

exten => 2,1,Macro(parked-call,2,default)
exten => 2,hint,park:2@parkedcalls

exten => 3,1,Macro(parked-call,3,default)
exten => 3,hint,park:3@parkedcalls

exten => *85,1,Macro(parked-call,,default)
exten => *85,n,Macro(parked-call,,default)
exten => *85,hint,park:@parkedcalls&park:1@parkedcalls&park:2@parkedcalls&park:3@parkedcalls
exten => *85,hint,park:@parkedcalls&park:1@parkedcalls&park:2@parkedcalls&park:3@parkedcalls

exten => *853050,1,Macro(parked-call,,default)
exten => *853050,hint,Custom:PARK3050

exten => *853051,1,Macro(parked-call,,default)
exten => *853051,hint,Custom:PARK3051

exten => *853301,1,Macro(parked-call,,default)
exten => *853301,hint,Custom:PARK3301

exten => *853302,1,Macro(parked-call,,default)
exten => *853302,hint,Custom:PARK3302

exten => *853303,1,Macro(parked-call,,default)
exten => *853303,hint,Custom:PARK3303

exten => *853304,1,Macro(parked-call,,default)
exten => *853304,hint,Custom:PARK3304

exten => *853307,1,Macro(parked-call,,default)
exten => *853307,hint,Custom:PARK3307

exten => *853310,1,Macro(parked-call,,default)
exten => *853310,hint,Custom:PARK3310

exten => *853311,1,Macro(parked-call,,default)
exten => *853311,hint,Custom:PARK3311

exten => *853312,1,Macro(parked-call,,default)
exten => *853312,hint,Custom:PARK3312

exten => *853313,1,Macro(parked-call,,default)
exten => *853313,hint,Custom:PARK3313

exten => *853314,1,Macro(parked-call,,default)
exten => *853314,hint,Custom:PARK3314

exten => *854444,1,Macro(parked-call,,default)
exten => *854444,hint,Custom:PARK4444

exten => *855123,1,Macro(parked-call,,default)
exten => *855123,hint,Custom:PARK5123

;--== end of [park-hints] ==--;


[ext-featurecodes]
include => ext-featurecodes-custom
exten => *30,1,Goto(from-internal,*30,1)

exten => *31,1,Goto(from-internal,*31,1)

exten => 555,1,Goto(from-internal,555,1)

exten => 7777,1,Goto(from-internal,7777,1)

exten => 888,1,Goto(from-internal,888,1)

exten => 666,1,Goto(from-internal,666,1)

exten => *43,1,Goto(from-internal,*43,1)

exten => *60,1,Goto(from-internal,*60,1)

exten => *85,1,Goto(from-internal,*85,1)

exten => 411,1,Goto(from-internal,411,1)

exten => *98,1,Goto(from-internal,*98,1)

;--== end of [ext-featurecodes] ==--;


[cidlookup]
include => cidlookup-custom
exten => cidlookup_3,1,Set(CURLOPT(httptimeout)=7)
exten => cidlookup_3,n,Set(CALLERID(name)=${CURL(https://api.opencnam.com/v2/phone/${CALLERID(num)}?format=pbx&ref=freepbx)})
exten => cidlookup_3,n,Set(current_hour=${STRFTIME(,,%Y-%m-%d %H)})
exten => cidlookup_3,n,Set(last_query_hour=${DB(cidlookup/opencnam_last_query_hour)})
exten => cidlookup_3,n,Set(total_hourly_queries=${DB(cidlookup/opencnam_total_hourly_queries)})
exten => cidlookup_3,n,ExecIf($["${last_query_hour}" != "${current_hour}"]?Set(DB(cidlookup/opencnam_total_hourly_queries)=0))
exten => cidlookup_3,n,ExecIf($["${total_hourly_queries}" = ""]?Set(DB(cidlookup/opencnam_total_hourly_queries)=0))
exten => cidlookup_3,n,Set(DB(cidlookup/opencnam_total_hourly_queries)=${MATH(${DB(cidlookup/opencnam_total_hourly_queries)}+1,i)})
exten => cidlookup_3,n,ExecIf($[${DB(cidlookup/opencnam_total_hourly_queries)} >= 60]?System(${ASTVARLIBDIR}/bin/opencnam-alert.php))
exten => cidlookup_3,n,Set(DB(cidlookup/opencnam_last_query_hour)=${current_hour})
exten => cidlookup_3,n,Return()

exten => cidlookup_return,1,ExecIf($["${DB(cidname/${CALLERID(num)})}" != ""]?Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})}))
exten => cidlookup_return,n,Return()

;--== end of [cidlookup] ==--;


[macro-autoanswer]
include => macro-autoanswer-custom
exten => s,1,Set(DIAL=${DB(DEVICE/${ARG1}/dial)})
exten => s,n,ExecIf($["${DIAL:0:3}" = "ZAP"]?Set(DIAL=DAHDI${DIAL:3}))
exten => s,n,GotoIf($["${DB(DEVICE/${ARG1}/autoanswer/macro)}" != "" ]?macro)
exten => s,n,Set(phone=${SIPPEER(${CUT(DIAL,/,2)}:useragent)})
exten => s,n,ExecIf($["${phone:0:5}" = "Mitel"]?Set(CALLINFO=Call-Info: <sip:broadworks.net>\;answer-after=0))
exten => s,n,ExecIf($["${phone:0:9}" = "Panasonic"]?Set(ALERTINFO=Alert-Info: Intercom))
exten => s,n,ExecIf($["${phone:0:7}" = "Polycom"]?Set(ALERTINFO=Alert-Info: info=Auto Answer))
exten => s,n,ExecIf($["${phone:0:6}" = "Digium"]?Set(ALERTINFO=Alert-Info: ring-answer))
exten => s,n,ExecIf($["${ALERTINFO}" != ""]?SipAddHeader(${ALERTINFO}))
exten => s,n,ExecIf($["${CALLINFO}" != ""]?SipAddHeader(${CALLINFO}))
exten => s,n,ExecIf($["${SIPURI}" != ""]?Set(__SIP_URI_OPTIONS=${SIPURI}))
exten => s,n+2(macro),Macro(${DB(DEVICE/${ARG1}/autoanswer/macro)},${ARG1})

;--== end of [macro-autoanswer] ==--;


[app-paging]
include => app-paging-custom
exten => ssetup,1,Set(_SIPURI=)
exten => ssetup,n,Set(_ALERTINFO=Alert-Info: Ring Answer)
exten => ssetup,n,Set(_CALLINFO=Call-Info: <uri>\;answer-after=0)
exten => ssetup,n,Set(_SIPURI=intercom=true)
exten => ssetup,n,Set(_DOPTIONS=A(beep))
exten => ssetup,n,Set(_DTIME=5)
exten => ssetup,n,Set(_ANSWERMACRO=)
exten => ssetup,n,Set(PAGE_CONF=${EPOCH}${RAND(100,999)})
exten => ssetup,n,Return()

exten => _PAGE.,1(SKIPCHECK),Macro(autoanswer,${EXTEN:4})
exten => _PAGE.,n,Dial(${DIAL},${DTIME},${DOPTIONS})
exten => _PAGE.,n(skipself),Hangup

exten => _SPAGE.,1(chanspy),ChanSpy(${SP_DEVICE}-,qW)
exten => _SPAGE.,n,Hangup

;--== end of [app-paging] ==--;


[app-queue-toggle]
include => app-queue-toggle-custom
exten => s,1(start),Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,Set(QUEUESTAT=LOGGEDOUT)
exten => s,n,AGI(queue_devstate.agi,getqueues,${AMPUSER})
exten => s,n,GotoIf($["${QUEUESTAT}" = "LOGGEDOUT"]?activate)
exten => s,n,GotoIf($["${QUEUESTAT}" = "LOGGEDIN"]?deactivate)
exten => s,n,GotoIf($["${QUEUESTAT}" = "STATIC"]?static:end)
exten => s,n(deactivate),Noop(Agent Logged out)
exten => s,n,Macro(toggle-del-agent,)
exten => s,n(logout),Set(STATE=NOT_INUSE)
exten => s,n,Gosub(sstate,1())
exten => s,n,Playback(agent-loggedoff)
exten => s,n,Macro(hangupcall,)
exten => s,n(activate),Noop(Agent Logged In)
exten => s,n,Macro(toggle-add-agent,)
exten => s,n,GotoIf($["${QAGENT_UNAUTHORIZED}"="1"]?logout)
exten => s,n,Set(STATE=INUSE)
exten => s,n,Gosub(sstate,1())
exten => s,n,Playback(agent-loginok)
exten => s,n,SayDigits(${CALLBACKNUM})
exten => s,n,Macro(hangupcall,)
exten => s,n(static),Noop(User is a Static Agent)
exten => s,n,Set(STATE=INUSE)
exten => s,n,Gosub(sstate,1())
exten => s,n,Playback(agent-loginok)
exten => s,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICES=${DB(AMPUSER/${AMPUSER}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:QUEUE${CUT(DEVICES,&,${ITER})}*${QUEUENO})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-queue-toggle] ==--;


[app-all-queue-toggle]
include => app-all-queue-toggle-custom
exten => s,1(start),Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,AGI(queue_devstate.agi,getall,${AMPUSER})
exten => s,n,GotoIf($["${QUEUESTAT}" = "NOQUEUES"]?skip)
exten => s,n,Set(TOGGLE_MACRO=${IF($["${QUEUESTAT}"="LOGGEDOUT"]?toggle-add-agent:toggle-del-agent)})
exten => s,n,Set(STATE=${IF($["${QUEUESTAT}"="LOGGEDOUT"]?INUSE:NOT_INUSE)})
exten => s,n,Set(LOOPCNTALL=${FIELDQTY(USERQUEUES,-)})
exten => s,n,Set(ITERALL=1)
exten => s,n(begin),Set(QUEUENO=${CUT(USERQUEUES,-,${ITERALL})})
exten => s,n,Set(ITERALL=$[${ITERALL}+1])
exten => s,n,Macro(${TOGGLE_MACRO},)
exten => s,n,Gosub(app-queue-toggle,sstate,1())
exten => s,n,GotoIf($[${ITERALL} <= ${LOOPCNTALL}]?begin)
exten => s,n(skip),ExecIf($["${QUEUESTAT}"="LOGGEDIN" | "${QUEUESTAT}"="NOQUEUES"]?Playback(agent-loggedoff))
exten => s,n,ExecIf($["${QUEUESTAT}"="LOGGEDOUT"]?Playback(agent-loginok))
exten => s,n,ExecIf($["${QUEUESTAT}"="LOGGEDOUT"]?SayDigits(${AMPUSER}))
exten => s,n,Macro(hangupcall,)

;--== end of [app-all-queue-toggle] ==--;


[macro-toggle-del-agent]
include => macro-toggle-del-agent-custom
exten => s,1,Wait(1)
exten => s,n,Macro(user-callerid,SKIPTTL,)
exten => s,n,Set(CALLBACKNUM=${AMPUSER})
exten => s,n,RemoveQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n)
exten => s,n,RemoveQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-internal/n)
exten => s,n,UserEvent(RefreshQueue)
exten => s,n,QueueLog(${QUEUENO},MANAGER,${AMPUSERCIDNAME},REMOVEMEMBER,)
exten => s,n,MacroExit()

;--== end of [macro-toggle-del-agent] ==--;


[macro-toggle-add-agent]
include => macro-toggle-add-agent-custom
exten => s,1,Wait(1)
exten => s,n,Macro(user-callerid,SKIPTTL,)
exten => s,n,Set(CALLBACKNUM=${AMPUSER})
exten => s,n,GotoIf($["${DB(QPENALTY/${QUEUENO}/dynmemberonly)}" = "yes" & ${DB_EXISTS(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})} != 1]?invalid)
exten => s,n,ExecIf($["${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]?AddQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local))
exten => s,n,ExecIf($["${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]?AddQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}))
exten => s,n,UserEvent(AgentLogin,Agent: ${CALLBACKNUM})
exten => s,n,QueueLog(${QUEUENO},MANAGER,${AMPUSERCIDNAME},ADDMEMBER,)
exten => s,n,MacroExit()
exten => s,n(invalid),Playback(pbx-invalid)
exten => s,n,Set(QAGENT_UNAUTHORIZED=1)
exten => s,n,MacroExit()

;--== end of [macro-toggle-add-agent] ==--;


[app-queue-pause-toggle]
include => app-queue-pause-toggle-custom
exten => s,1(start),Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,Set(MEMBR=Local/${AMPUSER}@from-queue/n)
exten => s,n,Set(PAUSE_STATE=${QUEUE_MEMBER(${ARG1},paused,${MEMBR})})
exten => s,n,Set(QUEUE_MEMBER(${ARG1},paused,${MEMBR})=${IF($[${PAUSE_STATE}]?0:1)})
exten => s,n,Playback(dictate/pause&${IF($[${PAUSE_STATE}]?de-activated:activated)})
exten => s,n,ExecIf($[${ARG2}]?Return())
exten => s,n,Macro(hangupcall,)

;--== end of [app-queue-pause-toggle] ==--;


[app-all-queue-pause-toggle]
include => app-all-queue-pause-toggle-custom
exten => s,1(start),Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,AGI(queue_devstate.agi,toggle-pause-all,${AMPUSER})
exten => s,n,Playback(dictate/pause&${IF($[${TOGGLEPAUSED}]?activated:de-activated)})
exten => s,n,Macro(hangupcall,)

;--== end of [app-all-queue-pause-toggle] ==--;


[ext-queues]
include => ext-queues-custom
exten => 701,1,Macro(user-callerid,)
exten => 701,n,Answer
exten => 701,n,Macro(blkvm-set,reset)
exten => 701,n,ExecIf($["${REGEX("(M[(]auto-blkvm[)])" ${DIAL_OPTIONS})}" != "1"]?Set(_DIAL_OPTIONS=${DIAL_OPTIONS}M(auto-blkvm)))
exten => 701,n,Set(__NODEST=${EXTEN})
exten => 701,n,Set(QCIDPP=${IF($[${LEN(${VQ_CIDPP})}>0]?${VQ_CIDPP}: )})
exten => 701,n,Set(VQ_CIDPP=)
exten => 701,n,ExecIf($["${QCIDPP}"!=""]?Macro(prepend-cid,${QCIDPP}))
exten => 701,n,Set(QAINFO=${IF($[${LEN(${VQ_AINFO})}>0]?${VQ_AINFO}: )})
exten => 701,n,Set(VQ_AINFO=)
exten => 701,n,ExecIf($["${QAINFO}"!=""]?Set(__ALERT_INFO=${QAINFO}))
exten => 701,n,Set(QJOINMSG=${IF($[${LEN(${VQ_JOINMSG})}>0]?${IF($["${VQ_JOINMSG}"!="0"]?${VQ_JOINMSG}: )}: )})
exten => 701,n,Set(VQ_JOINMSG=)
exten => 701,n,Set(QMOH=${IF($["${VQ_MOH}"!=""]?${VQ_MOH}: )})
exten => 701,n,Set(VQ_MOH=)
exten => 701,n,ExecIf($["${QMOH}"!=""]?Set(__MOHCLASS=${QMOH}))
exten => 701,n,Set(QRETRY=${IF($[${LEN(${VQ_RETRY})}>0]?${VQ_RETRY}: )})
exten => 701,n,Set(VQ_RETRY=)
exten => 701,n(qoptions),Set(QOPTIONS=${IF($[${LEN(${VQ_OPTIONS})}>0]?${VQ_OPTIONS}:t)}${QCANCELMISSED}${QRINGOPTS}${QRETRY})
exten => 701,n,Set(VQ_OPTIONS=)
exten => 701,n(qgosub),Set(QGOSUB=${IF($[${LEN(${VQ_GOSUB})}>0]?${VQ_GOSUB}:${QGOSUB})})
exten => 701,n,Set(VQ_GOSUB=)
exten => 701,n(qagi),Set(QAGI=${IF($[${LEN(${VQ_AGI})}>0]?${VQ_AGI}:${QAGI})})
exten => 701,n,Set(VQ_AGI=)
exten => 701,n(qrule),Set(QRULE=${IF($[${LEN(${VQ_RULE})}>0]?${IF($["${VQ_RULE}"!="0"]?${VQ_RULE}: )}:${QRULE})})
exten => 701,n,Set(VQ_RULE=)
exten => 701,n(qposition),Set(QPOSITION=${IF($[${LEN(${VQ_POSITION})}>0]?${VQ_POSITION}:${QPOSITION})})
exten => 701,n,Set(VQ_POSITION=)
exten => 701,n,Gosub(sub-record-check,s,1(q,701,dontcare))
exten => 701,n,ExecIf($["${QJOINMSG}"!=""]?Playback(${QJOINMSG}, ))
exten => 701,n,QueueLog(701,${UNIQUEID},NONE,DID,${FROM_DID})
exten => 701,n,Set(QAANNOUNCE=${IF($[${LEN(${VQ_AANNOUNCE})}>0]?${IF($["${VQ_AANNOUNCE}"!="0"]?${VQ_AANNOUNCE}: )}: )})
exten => 701,n,Set(VQ_AANNOUNCE=)
exten => 701,n,Set(QMAXWAIT=${IF($[${LEN(${VQ_MAXWAIT})}>0]?${VQ_MAXWAIT}: )})
exten => 701,n,Set(VQ_MAXWAIT=)
exten => 701,n(qcall),Queue(701,${QOPTIONS},,${QAANNOUNCE},${QMAXWAIT},${QAGI},,${QGOSUB},${QRULE},${QPOSITION})
exten => 701,n,Macro(blkvm-clr,)
exten => 701,n,Gosub(sub-record-cancel,s,1())
exten => 701,n,Set(__NODEST=)
exten => 701,n,Set(_QUEUE_PRIO=0)
exten => 701,n,Set(QDEST=${VQ_DEST})
exten => 701,n,Set(VQ_DEST=)
exten => 701,n(gotodest),GotoIf($["${QDEST}"=""]?:${CUT(QDEST,^,1)},${CUT(QDEST,^,2)},${CUT(QDEST,^,3)})

exten => 701*,1,Macro(agent-add,701,)

exten => 701**,1,Macro(agent-del,701)

exten => *45701,1,Set(QUEUENO=701)
exten => *45701,n,Goto(app-queue-toggle,s,start)

exten => *46701,1,Gosub(app-queue-pause-toggle,s,1(701))

exten => 702,1,Macro(user-callerid,)
exten => 702,n,Answer
exten => 702,n,Macro(blkvm-set,reset)
exten => 702,n,ExecIf($["${REGEX("(M[(]auto-blkvm[)])" ${DIAL_OPTIONS})}" != "1"]?Set(_DIAL_OPTIONS=${DIAL_OPTIONS}M(auto-blkvm)))
exten => 702,n,Set(__NODEST=${EXTEN})
exten => 702,n,Set(QCIDPP=${IF($[${LEN(${VQ_CIDPP})}>0]?${VQ_CIDPP}: )})
exten => 702,n,Set(VQ_CIDPP=)
exten => 702,n,ExecIf($["${QCIDPP}"!=""]?Macro(prepend-cid,${QCIDPP}))
exten => 702,n,Set(QAINFO=${IF($[${LEN(${VQ_AINFO})}>0]?${VQ_AINFO}: )})
exten => 702,n,Set(VQ_AINFO=)
exten => 702,n,ExecIf($["${QAINFO}"!=""]?Set(__ALERT_INFO=${QAINFO}))
exten => 702,n,Set(QJOINMSG=${IF($[${LEN(${VQ_JOINMSG})}>0]?${IF($["${VQ_JOINMSG}"!="0"]?${VQ_JOINMSG}: )}: )})
exten => 702,n,Set(VQ_JOINMSG=)
exten => 702,n,Set(QMOH=${IF($["${VQ_MOH}"!=""]?${VQ_MOH}: )})
exten => 702,n,Set(VQ_MOH=)
exten => 702,n,ExecIf($["${QMOH}"!=""]?Set(__MOHCLASS=${QMOH}))
exten => 702,n,Set(QRETRY=${IF($[${LEN(${VQ_RETRY})}>0]?${VQ_RETRY}: )})
exten => 702,n,Set(VQ_RETRY=)
exten => 702,n(qoptions),Set(QOPTIONS=${IF($[${LEN(${VQ_OPTIONS})}>0]?${VQ_OPTIONS}:t)}${QCANCELMISSED}${QRINGOPTS}${QRETRY})
exten => 702,n,Set(VQ_OPTIONS=)
exten => 702,n(qgosub),Set(QGOSUB=${IF($[${LEN(${VQ_GOSUB})}>0]?${VQ_GOSUB}:${QGOSUB})})
exten => 702,n,Set(VQ_GOSUB=)
exten => 702,n(qagi),Set(QAGI=${IF($[${LEN(${VQ_AGI})}>0]?${VQ_AGI}:${QAGI})})
exten => 702,n,Set(VQ_AGI=)
exten => 702,n(qrule),Set(QRULE=${IF($[${LEN(${VQ_RULE})}>0]?${IF($["${VQ_RULE}"!="0"]?${VQ_RULE}: )}:${QRULE})})
exten => 702,n,Set(VQ_RULE=)
exten => 702,n(qposition),Set(QPOSITION=${IF($[${LEN(${VQ_POSITION})}>0]?${VQ_POSITION}:${QPOSITION})})
exten => 702,n,Set(VQ_POSITION=)
exten => 702,n,Gosub(sub-record-check,s,1(q,702,dontcare))
exten => 702,n,ExecIf($["${QJOINMSG}"!=""]?Playback(${QJOINMSG}, ))
exten => 702,n,QueueLog(702,${UNIQUEID},NONE,DID,${FROM_DID})
exten => 702,n,Set(QAANNOUNCE=${IF($[${LEN(${VQ_AANNOUNCE})}>0]?${IF($["${VQ_AANNOUNCE}"!="0"]?${VQ_AANNOUNCE}: )}: )})
exten => 702,n,Set(VQ_AANNOUNCE=)
exten => 702,n,Set(QMAXWAIT=${IF($[${LEN(${VQ_MAXWAIT})}>0]?${VQ_MAXWAIT}: )})
exten => 702,n,Set(VQ_MAXWAIT=)
exten => 702,n(qcall),Queue(702,${QOPTIONS},,${QAANNOUNCE},${QMAXWAIT},${QAGI},,${QGOSUB},${QRULE},${QPOSITION})
exten => 702,n,Macro(blkvm-clr,)
exten => 702,n,Gosub(sub-record-cancel,s,1())
exten => 702,n,Set(__NODEST=)
exten => 702,n,Set(_QUEUE_PRIO=0)
exten => 702,n,Set(QDEST=${VQ_DEST})
exten => 702,n,Set(VQ_DEST=)
exten => 702,n(gotodest),GotoIf($["${QDEST}"=""]?:${CUT(QDEST,^,1)},${CUT(QDEST,^,2)},${CUT(QDEST,^,3)})

exten => 702*,1,Macro(agent-add,702,)

exten => 702**,1,Macro(agent-del,702)

exten => *45702,1,Set(QUEUENO=702)
exten => *45702,n,Goto(app-queue-toggle,s,start)

exten => *46702,1,Gosub(app-queue-pause-toggle,s,1(702))

exten => 703,1,Macro(user-callerid,)
exten => 703,n,Answer
exten => 703,n,Macro(blkvm-set,reset)
exten => 703,n,ExecIf($["${REGEX("(M[(]auto-blkvm[)])" ${DIAL_OPTIONS})}" != "1"]?Set(_DIAL_OPTIONS=${DIAL_OPTIONS}M(auto-blkvm)))
exten => 703,n,Set(__NODEST=${EXTEN})
exten => 703,n,Set(QCIDPP=${IF($[${LEN(${VQ_CIDPP})}>0]?${VQ_CIDPP}: )})
exten => 703,n,Set(VQ_CIDPP=)
exten => 703,n,ExecIf($["${QCIDPP}"!=""]?Macro(prepend-cid,${QCIDPP}))
exten => 703,n,Set(QAINFO=${IF($[${LEN(${VQ_AINFO})}>0]?${VQ_AINFO}: )})
exten => 703,n,Set(VQ_AINFO=)
exten => 703,n,ExecIf($["${QAINFO}"!=""]?Set(__ALERT_INFO=${QAINFO}))
exten => 703,n,Set(QJOINMSG=${IF($[${LEN(${VQ_JOINMSG})}>0]?${IF($["${VQ_JOINMSG}"!="0"]?${VQ_JOINMSG}: )}: )})
exten => 703,n,Set(VQ_JOINMSG=)
exten => 703,n,Set(QMOH=${IF($["${VQ_MOH}"!=""]?${VQ_MOH}: )})
exten => 703,n,Set(VQ_MOH=)
exten => 703,n,ExecIf($["${QMOH}"!=""]?Set(__MOHCLASS=${QMOH}))
exten => 703,n,Set(QRETRY=${IF($[${LEN(${VQ_RETRY})}>0]?${VQ_RETRY}: )})
exten => 703,n,Set(VQ_RETRY=)
exten => 703,n(qoptions),Set(QOPTIONS=${IF($[${LEN(${VQ_OPTIONS})}>0]?${VQ_OPTIONS}:t)}${QCANCELMISSED}${QRINGOPTS}${QRETRY})
exten => 703,n,Set(VQ_OPTIONS=)
exten => 703,n(qgosub),Set(QGOSUB=${IF($[${LEN(${VQ_GOSUB})}>0]?${VQ_GOSUB}:${QGOSUB})})
exten => 703,n,Set(VQ_GOSUB=)
exten => 703,n(qagi),Set(QAGI=${IF($[${LEN(${VQ_AGI})}>0]?${VQ_AGI}:${QAGI})})
exten => 703,n,Set(VQ_AGI=)
exten => 703,n(qrule),Set(QRULE=${IF($[${LEN(${VQ_RULE})}>0]?${IF($["${VQ_RULE}"!="0"]?${VQ_RULE}: )}:${QRULE})})
exten => 703,n,Set(VQ_RULE=)
exten => 703,n(qposition),Set(QPOSITION=${IF($[${LEN(${VQ_POSITION})}>0]?${VQ_POSITION}:${QPOSITION})})
exten => 703,n,Set(VQ_POSITION=)
exten => 703,n,Gosub(sub-record-check,s,1(q,703,dontcare))
exten => 703,n,ExecIf($["${QJOINMSG}"!=""]?Playback(${QJOINMSG}, ))
exten => 703,n,QueueLog(703,${UNIQUEID},NONE,DID,${FROM_DID})
exten => 703,n,Set(QAANNOUNCE=${IF($[${LEN(${VQ_AANNOUNCE})}>0]?${IF($["${VQ_AANNOUNCE}"!="0"]?${VQ_AANNOUNCE}: )}: )})
exten => 703,n,Set(VQ_AANNOUNCE=)
exten => 703,n,Set(QMAXWAIT=${IF($[${LEN(${VQ_MAXWAIT})}>0]?${VQ_MAXWAIT}: )})
exten => 703,n,Set(VQ_MAXWAIT=)
exten => 703,n(qcall),Queue(703,${QOPTIONS},,${QAANNOUNCE},${QMAXWAIT},${QAGI},,${QGOSUB},${QRULE},${QPOSITION})
exten => 703,n,Macro(blkvm-clr,)
exten => 703,n,Gosub(sub-record-cancel,s,1())
exten => 703,n,Set(__NODEST=)
exten => 703,n,Set(_QUEUE_PRIO=0)
exten => 703,n,Set(QDEST=${VQ_DEST})
exten => 703,n,Set(VQ_DEST=)
exten => 703,n(gotodest),GotoIf($["${QDEST}"=""]?:${CUT(QDEST,^,1)},${CUT(QDEST,^,2)},${CUT(QDEST,^,3)})

exten => 703*,1,Macro(agent-add,703,)

exten => 703**,1,Macro(agent-del,703)

exten => *45703,1,Set(QUEUENO=703)
exten => *45703,n,Goto(app-queue-toggle,s,start)

exten => *46703,1,Gosub(app-queue-pause-toggle,s,1(703))

exten => *45,1,Goto(app-all-queue-toggle,s,start)

exten => _*45*X.,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3050,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3051,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3301,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3302,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3303,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3304,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3307,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3310,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3311,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3312,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3313,1,Goto(app-all-queue-toggle,s,start)

exten => *45*3314,1,Goto(app-all-queue-toggle,s,start)

exten => *45*4444,1,Goto(app-all-queue-toggle,s,start)

exten => *45*5123,1,Goto(app-all-queue-toggle,s,start)

exten => *46,1,Goto(app-all-queue-pause-toggle,s,1)

exten => _*46*X.,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*3050*701,1,Gosub(app-queue-pause-toggle,s,1(701))
exten => *46*3050*701,hint,qpause:701:Local/3050@from-queue/n

exten => *46*3050,1,Goto(app-all-queue-pause-toggle,s,1)
exten => *46*3050,hint,qpause:701:Local/3050@from-queue/n

exten => *46*3051*701,1,Gosub(app-queue-pause-toggle,s,1(701))
exten => *46*3051*701,hint,qpause:701:Local/3051@from-queue/n

exten => *46*3051,1,Goto(app-all-queue-pause-toggle,s,1)
exten => *46*3051,hint,qpause:701:Local/3051@from-queue/n

exten => *46*3301*702,1,Gosub(app-queue-pause-toggle,s,1(702))
exten => *46*3301*702,hint,qpause:702:Local/3301@from-queue/n

exten => *46*3301,1,Goto(app-all-queue-pause-toggle,s,1)
exten => *46*3301,hint,qpause:702:Local/3301@from-queue/n

exten => *46*3302*702,1,Gosub(app-queue-pause-toggle,s,1(702))
exten => *46*3302*702,hint,qpause:702:Local/3302@from-queue/n

exten => *46*3302,1,Goto(app-all-queue-pause-toggle,s,1)
exten => *46*3302,hint,qpause:702:Local/3302@from-queue/n

exten => *46*3303,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*3304*703,1,Gosub(app-queue-pause-toggle,s,1(703))
exten => *46*3304*703,hint,qpause:703:Local/3304@from-queue/n

exten => *46*3304,1,Goto(app-all-queue-pause-toggle,s,1)
exten => *46*3304,hint,qpause:703:Local/3304@from-queue/n

exten => *46*3307,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*3310,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*3311*702,1,Gosub(app-queue-pause-toggle,s,1(702))
exten => *46*3311*702,hint,qpause:702:Local/3311@from-queue/n

exten => *46*3311,1,Goto(app-all-queue-pause-toggle,s,1)
exten => *46*3311,hint,qpause:702:Local/3311@from-queue/n

exten => *46*3312,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*3313,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*3314,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*4444,1,Goto(app-all-queue-pause-toggle,s,1)

exten => *46*5123,1,Goto(app-all-queue-pause-toggle,s,1)

exten => h,1,Macro(hangupcall,)

;--== end of [ext-queues] ==--;


[from-queue]
include => from-queue-custom
exten => 701,1,Goto(from-internal,${QAGENT},1)

exten => 702,1,Goto(from-internal,${QAGENT},1)

exten => 703,1,Goto(from-internal,${QAGENT},1)

exten => _.,1,Set(QAGENT=${EXTEN})
exten => _.,n,Goto(${NODEST},1)

;--== end of [from-queue] ==--;


[from-queue-exten-internal]
include => from-queue-exten-internal-custom
include => from-queue-exten-only
include => from-internal
exten => foo,1,Noop(bar)

;--== end of [from-queue-exten-internal] ==--;


[from-queue-exten-only]
include => from-queue-exten-only-custom
exten => 3050,1,Set(RingGroupMethod=none)
exten => 3050,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3050,n(checkrecord),Gosub(sub-record-check,s,1(exten,3050))
exten => 3050,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3050)
exten => 3050,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3050,n,Hangup

exten => 3051,1,Set(RingGroupMethod=none)
exten => 3051,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3051,n(checkrecord),Gosub(sub-record-check,s,1(exten,3051))
exten => 3051,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3051)
exten => 3051,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3051,n,Hangup

exten => 3301,1,Set(RingGroupMethod=none)
exten => 3301,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3301,n(checkrecord),Gosub(sub-record-check,s,1(exten,3301))
exten => 3301,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3301)
exten => 3301,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3301,n,Hangup

exten => 3302,1,Set(RingGroupMethod=none)
exten => 3302,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3302,n(checkrecord),Gosub(sub-record-check,s,1(exten,3302))
exten => 3302,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3302)
exten => 3302,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3302,n,Hangup

exten => 3303,1,Set(RingGroupMethod=none)
exten => 3303,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3303,n(checkrecord),Gosub(sub-record-check,s,1(exten,3303))
exten => 3303,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3303)
exten => 3303,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3303,n,Hangup

exten => 3304,1,Set(RingGroupMethod=none)
exten => 3304,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3304,n(checkrecord),Gosub(sub-record-check,s,1(exten,3304))
exten => 3304,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3304)
exten => 3304,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3304,n,Hangup

exten => 3307,1,Set(RingGroupMethod=none)
exten => 3307,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3307,n(checkrecord),Gosub(sub-record-check,s,1(exten,3307))
exten => 3307,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3307)
exten => 3307,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3307,n,Hangup

exten => 3310,1,Set(RingGroupMethod=none)
exten => 3310,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3310,n(checkrecord),Gosub(sub-record-check,s,1(exten,3310))
exten => 3310,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3310)
exten => 3310,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3310,n,Hangup

exten => 3311,1,Set(RingGroupMethod=none)
exten => 3311,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3311,n(checkrecord),Gosub(sub-record-check,s,1(exten,3311))
exten => 3311,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3311)
exten => 3311,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3311,n,Hangup

exten => 3312,1,Set(RingGroupMethod=none)
exten => 3312,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3312,n(checkrecord),Gosub(sub-record-check,s,1(exten,3312))
exten => 3312,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3312)
exten => 3312,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3312,n,Hangup

exten => 3313,1,Set(RingGroupMethod=none)
exten => 3313,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3313,n(checkrecord),Gosub(sub-record-check,s,1(exten,3313))
exten => 3313,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3313)
exten => 3313,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3313,n,Hangup

exten => 3314,1,Set(RingGroupMethod=none)
exten => 3314,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 3314,n(checkrecord),Gosub(sub-record-check,s,1(exten,3314))
exten => 3314,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},3314)
exten => 3314,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 3314,n,Hangup

exten => 4444,1,Set(RingGroupMethod=none)
exten => 4444,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 4444,n(checkrecord),Gosub(sub-record-check,s,1(exten,4444))
exten => 4444,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},4444)
exten => 4444,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 4444,n,Hangup

exten => 5123,1,Set(RingGroupMethod=none)
exten => 5123,n,Set(QDOPTS=${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))})
exten => 5123,n(checkrecord),Gosub(sub-record-check,s,1(exten,5123))
exten => 5123,n,Macro(dial-one,,${DIAL_OPTIONS}${QDOPTS},5123)
exten => 5123,n,GotoIf($["${CALLER_DEST}"!=""]?${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)})
exten => 5123,n,Hangup

exten => h,1,Macro(hangupcall,)

;--== end of [from-queue-exten-only] ==--;


[macro-agent-add]
include => macro-agent-add-custom
exten => s,1,Wait(1)
exten => s,n,Set(QUEUENO=${ARG1})
exten => s,n,Macro(user-callerid,SKIPTTL)
exten => s,n(a3),Read(CALLBACKNUM,agent-login,,,,)
exten => s,n,GotoIf($[${LEN(${CALLBACKNUM})}=0]?a5:a7)
exten => s,n(a5),Set(CALLBACKNUM=${IF($[${LEN(${AMPUSER})}=0]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,Set(THISDEVICE=${DB(DEVICE/${REALCALLERIDNUM}/dial)})
exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a3)
exten => s,n(a7),GotoIf($["${CALLBACKNUM}" = "${QUEUENO}"]?invalid)
exten => s,n,GotoIf($["${ARG3}" = "EXTEN" & ${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 0]?invalid)
exten => s,n,GotoIf($["${DB(QPENALTY/${QUEUENO}/dynmemberonly)}" = "yes" & ${DB_EXISTS(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})} != 1]?invalid)
exten => s,n,ExecIf($["${QREGEX}" != ""]?GotoIf($["${REGEX("${QREGEX}" ${CALLBACKNUM})}" = "0"]?invalid))
exten => s,n,ExecIf($["${ARG2}" != ""]?Authenticate(${ARG2}))
exten => s,n,Set(STATE=INUSE)
exten => s,n,Gosub(app-queue-toggle,sstate,1())
exten => s,n,ExecIf($[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]?AddQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local))
exten => s,n,ExecIf($[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]?AddQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}))
exten => s,n,ExecIf($[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 0]?AddQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})}))
exten => s,n,UserEvent(Agentlogin,Agent: ${CALLBACKNUM})
exten => s,n,Wait(1)
exten => s,n,Playback(agent-loginok&with&extension)
exten => s,n,SayDigits(${CALLBACKNUM})
exten => s,n,Hangup
exten => s,n,MacroExit()
exten => s,n(invalid),Playback(pbx-invalid)
exten => s,n,Goto(a3)

;--== end of [macro-agent-add] ==--;


[macro-agent-del]
include => macro-agent-del-custom
exten => s,1,Wait(1)
exten => s,n,Set(QUEUENO=${ARG1})
exten => s,n,Macro(user-callerid,SKIPTTL)
exten => s,n(a3),Read(CALLBACKNUM,agent-logoff,,,,)
exten => s,n,GotoIf($[${LEN(${CALLBACKNUM})}=0]?a5:a7)
exten => s,n(a5),Set(CALLBACKNUM=${IF($[${LEN(${AMPUSER})}=0]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a3)
exten => s,n,Set(STATE=NOT_INUSE)
exten => s,n,Gosub(app-queue-toggle,sstate,1())
exten => s,n(a7),RemoveQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-queue/n)
exten => s,n,RemoveQueueMember(${QUEUENO},Local/${CALLBACKNUM}@from-internal/n)
exten => s,n,UserEvent(RefreshQueue)
exten => s,n,Wait(1)
exten => s,n,Playback(agent-loggedoff)
exten => s,n,Hangup

;--== end of [macro-agent-del] ==--;


[app-gabcast]
include => app-gabcast-custom
exten => *422,1,Macro(user-callerid,)
exten => *422,n,Goto(gabcast,${AMPUSER},1)

;--== end of [app-gabcast] ==--;


[gabcast]
include => gabcast-custom
exten => _X.,1,Dial(IAX2/iax.gabcast.com/422,120,tr)

exten => s,1,Dial(IAX2/iax.gabcast.com/422,120,tr)

;--== end of [gabcast] ==--;


[app-callwaiting-cwoff]
include => app-callwaiting-cwoff-custom
exten => *71,1,Answer
exten => *71,n,Wait(1)
exten => *71,n,Macro(user-callerid,)
exten => *71,n,Noop(Deleting: CW/${AMPUSER} ${DB_DELETE(CW/${AMPUSER})})
exten => *71,n(hook_1),Playback(call-waiting&de-activated)
exten => *71,n,Macro(hangupcall,)

;--== end of [app-callwaiting-cwoff] ==--;


[app-callwaiting-cwon]
include => app-callwaiting-cwon-custom
exten => *70,1,Answer
exten => *70,n,Wait(1)
exten => *70,n,Macro(user-callerid,)
exten => *70,n,Set(DB(CW/${AMPUSER})=ENABLED)
exten => *70,n(hook_1),Playback(call-waiting&activated)
exten => *70,n,Macro(hangupcall,)

;--== end of [app-callwaiting-cwon] ==--;


[app-calltrace]
include => app-calltrace-custom
exten => *69,1,Goto(app-calltrace-perform,s,1)

;--== end of [app-calltrace] ==--;


[app-calltrace-perform]
include => app-calltrace-perform-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,Playback(info-about-last-call&telephone-number)
exten => s,n,Set(lastcaller=${DB(CALLTRACE/${AMPUSER})})
exten => s,n,GotoIf($[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]?noinfo)
exten => s,n,SayDigits(${lastcaller})
exten => s,n,Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=7)
exten => s,n,Background(to-call-this-number&press-1)
exten => s,n,Goto(fin)
exten => s,n(noinfo),Playback(from-unknown-caller)
exten => s,n,Macro(hangupcall,)
exten => s,n(fin),Noop(Waiting for input)
exten => s,n,WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)

exten => 1,1,Goto(from-internal,${lastcaller},1)

exten => i,1,Playback(vm-goodbye)
exten => i,n,Macro(hangupcall,)

exten => t,1,Playback(vm-goodbye)
exten => t,n,Macro(hangupcall,)

;--== end of [app-calltrace-perform] ==--;


[app-echo-test]
include => app-echo-test-custom
exten => *43,1,Answer
exten => *43,n,Wait(1)
exten => *43,n,Playback(demo-echotest)
exten => *43,n,Echo()
exten => *43,n,Playback(demo-echodone)
exten => *43,n,Hangup

;--== end of [app-echo-test] ==--;


[app-speakextennum]
include => app-speakextennum-custom
exten => *65,1,Answer
exten => *65,n,Wait(1)
exten => *65,n,Macro(user-callerid,)
exten => *65,n,Playback(your)
exten => *65,n,Playback(extension)
exten => *65,n,Playback(number)
exten => *65,n,Playback(is)
exten => *65,n,SayDigits(${AMPUSER})
exten => *65,n,Wait(2)
exten => *65,n,Hangup

;--== end of [app-speakextennum] ==--;


[sub-hr24format]
include => sub-hr24format-custom
exten => s,1,Goto(${CHANNEL(language)},1)
exten => s,n,GotoIf($[${DIALPLAN_EXISTS(sub-hr24format,${CHANNEL(language)},1)}]?${CHANNEL(language)},1:en,1)

exten => i,1,Playback(at-tone-time-exactly)
exten => i,n,SayUnixTime(${FutureTime},,kM 'and' S 'seconds')
exten => i,n,Return()

exten => de,1,Playback(at-tone-time-exactly)
exten => de,n,SayUnixTime(${FutureTime},,kMS)
exten => de,n,Return()
exten => de,n,Playback(at-tone-time-exactly)
exten => de,n,SayUnixTime(${FutureTime},,kMS)
exten => de,n,Return()

exten => en,1,Playback(at-tone-time-exactly)
exten => en,n,SayUnixTime(${FutureTime},,kM 'and' S 'seconds')
exten => en,n,Return()

;--== end of [sub-hr24format] ==--;


[app-speakingclock]
include => app-speakingclock-custom
exten => *60,1,Answer
exten => *60,n,Wait(1)
exten => *60,n,Set(NumLoops=0)
exten => *60,n(start),Set(FutureTime=$[${EPOCH} + 11])
exten => *60,n,Gosub(sub-hr24format,s,1())
exten => *60,n(waitloop),Set(TimeLeft=$[${FutureTime} - ${EPOCH}])
exten => *60,n,GotoIf($[${TimeLeft} < 1]?playbeep)
exten => *60,n,Wait(1)
exten => *60,n,Goto(waitloop)
exten => *60,n(playbeep),Playback(beep)
exten => *60,n,Wait(5)
exten => *60,n,Set(NumLoops=$[${NumLoops} + 1])
exten => *60,n,GotoIf($[${NumLoops} < 5]?start)
exten => *60,n,Playback(goodbye)
exten => *60,n,Hangup

;--== end of [app-speakingclock] ==--;


[sub-hr12format]
include => sub-hr12format-custom
exten => s,1,GotoIf($[${DIALPLAN_EXISTS(sub-hr12format,${CHANNEL(language)},1)}]?${CHANNEL(language)},1:en,1)

exten => en,1,Playback(at-tone-time-exactly)
exten => en,n,SayUnixTime(${FutureTime},,IM 'and' S 'seconds' p)
exten => en,n,Return()

exten => de,1,Playback(at-tone-time-exactly)
exten => de,n,SayUnixTime(${FutureTime},,IMSp)
exten => de,n,Return()

;--== end of [sub-hr12format] ==--;


[macro-speeddial-lookup]
include => macro-speeddial-lookup-custom
exten => s,1,GotoIf($["${ARG2}"=""]]?lookupsys)
exten => s,n,Set(SPEEDDIALNUMBER=)
exten => s,n(lookupuser),Set(SPEEDDIALNUMBER=${DB(AMPUSER/${ARG2}/speeddials/${ARG1})})
exten => s,n,GotoIf($["${SPEEDDIALNUMBER}"=""]?lookupsys)
exten => s,n,Noop(Found speeddial ${ARG1} for user ${ARG2}: ${SPEEDDIALNUMBER})
exten => s,n,Goto(end)
exten => s,lookupuser+101(lookupsys),Set(SPEEDDIALNUMBER=${DB(sysspeeddials/${ARG1})})
exten => s,n,GotoIf($["${SPEEDDIALNUMBER}"=""]?failed)
exten => s,n,Noop(Found system speeddial ${ARG1}: ${SPEEDDIALNUMBER})
exten => s,n,Goto(end)
exten => s,lookupsys+101(failed),Noop(No system or user speeddial found)
exten => s,n(end),Noop(End of Speeddial-lookup)

;--== end of [macro-speeddial-lookup] ==--;


[app-speeddial]
include => app-speeddial-custom
exten => _*0.,1,Macro(user-callerid,)
exten => _*0.,n,Set(SPEEDDIALLOCATION=${EXTEN:2})
exten => _*0.,n(lookup),Macro(speeddial-lookup,${SPEEDDIALLOCATION},${AMPUSER})
exten => _*0.,n,GotoIf($["${SPEEDDIALNUMBER}"=""]?failed)
exten => _*0.,n,Goto(from-internal,${SPEEDDIALNUMBER},1)
exten => _*0.,lookup+101(failed),Playback(speed-dial-empty)
exten => _*0.,n,Congestion()

exten => *75,1,Goto(app-speeddial-set,s,1)

;--== end of [app-speeddial] ==--;


[app-speeddial-set]
include => app-speeddial-set-custom
exten => s,1,Macro(user-callerid,)
exten => s,n(setloc),Read(newlocation,speed-enterlocation,,,,)
exten => s,n(lookup),Macro(speeddial-lookup,${newlocation},${AMPUSER})
exten => s,n(lookup),GotoIf($["${SPEEDDIALNUMBER}"!=""]?conflicts)
exten => s,n(setnum),Read(newnum,speed-enternumber,,,,)
exten => s,n(success),Set(DB(AMPUSER/${AMPUSER}/speeddials/${newlocation})=${newnum})
exten => s,n,Playback(speed-dial)
exten => s,n,SayDigits(${newlocation})
exten => s,n,Playback(is-set-to)
exten => s,n,SayDigits(${newnum})
exten => s,n,Hangup
exten => s,n(conflicts),Playback(speed-dial)
exten => s,n,SayDigits(${newlocation})
exten => s,n,Playback(is-in-use)
exten => s,n,Background(press-1&to-listen-to-it&press-2&to-enter-a-diff&location&press-3&to-change&telephone-number)
exten => s,n,WaitExten(60,)

exten => 1,1,Playback(speed-dial)
exten => 1,n,SayDigits(${newlocation})
exten => 1,n,Playback(is-set-to)
exten => 1,n,SayDigits(${SPEEDDIALNUMBER})
exten => 1,n,Goto(s,conflicts)

exten => 2,1,Goto(s,setloc)

exten => 3,1,Goto(s,setnum)

exten => t,1,Congestion()

;--== end of [app-speeddial-set] ==--;


[macro-outisbusy]
include => macro-outisbusy-custom
exten => s,1,Progress
exten => s,n,GotoIf($["${EMERGENCYROUTE}" = "YES"]?emergency,1)
exten => s,n,GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?intracompany,1)
exten => s,n,Playback(all-circuits-busy-now&pls-try-call-later, noanswer)
exten => s,n,Congestion(20)
exten => s,n,Hangup

exten => intracompany,1,Playback(all-circuits-busy-now&pls-try-call-later, noanswer)
exten => intracompany,n,Congestion(20)
exten => intracompany,n,Hangup

exten => emergency,1,Playback(all-circuits-busy-now&pls-try-call-later)
exten => emergency,n,Congestion(20)
exten => emergency,n,Hangup

;--== end of [macro-outisbusy] ==--;


[app-cf-busy-off]
include => app-cf-busy-off-custom
exten => *91,1,Answer
exten => *91,n,Wait(1)
exten => *91,n,Macro(user-callerid,)
exten => *91,n,Set(fromext=${AMPUSER})
exten => *91,n,Noop(Deleting: CFB/${fromext} ${DB_DELETE(CFB/${fromext})})
exten => *91,n(hook_1),Playback(call-fwd-on-busy&de-activated)
exten => *91,n,Macro(hangupcall,)

exten => _*91.,1,Answer
exten => _*91.,n,Wait(1)
exten => _*91.,n,Set(fromext=${EXTEN:3})
exten => _*91.,n,Noop(Deleting: CFB/${fromext} ${DB_DELETE(CFB/${fromext})})
exten => _*91.,n(hook_2),Playback(call-fwd-on-busy&for&extension)
exten => _*91.,n,SayDigits(${fromext})
exten => _*91.,n,Playback(cancelled)
exten => _*91.,n,Macro(hangupcall,)

;--== end of [app-cf-busy-off] ==--;


[app-cf-busy-off-any]
include => app-cf-busy-off-any-custom
exten => *92,1,Answer
exten => *92,n,Macro(user-callerid,)
exten => *92,n,Wait(1)
exten => *92,n,Read(fromext,please-enter-your&extension&then-press-pound,,,,)
exten => *92,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *92,n,Wait(1)
exten => *92,n,Noop(Deleting: CFB/${fromext} ${DB_DELETE(CFB/${fromext})})
exten => *92,n(hook_1),Playback(call-fwd-on-busy&for&extension)
exten => *92,n,SayDigits(${fromext})
exten => *92,n,Playback(cancelled)
exten => *92,n,Macro(hangupcall,)

;--== end of [app-cf-busy-off-any] ==--;


[app-cf-busy-on]
include => app-cf-busy-on-custom
exten => *90,1,Answer
exten => *90,n,Wait(1)
exten => *90,n,Macro(user-callerid,)
exten => *90,n,Read(fromext,call-fwd-on-busy&please-enter-your&extension&then-press-pound,,,,)
exten => *90,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *90,n,Wait(1)
exten => *90,n(startread),Read(toext,ent-target-attendant&then-press-pound,,,,)
exten => *90,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *90,n,Wait(1)
exten => *90,n,Set(DB(CFB/${fromext})=${toext})
exten => *90,n(hook_1),Playback(call-fwd-on-busy&for&extension)
exten => *90,n,SayDigits(${fromext})
exten => *90,n,Playback(is-set-to)
exten => *90,n,SayDigits(${toext})
exten => *90,n,Macro(hangupcall,)

exten => _*90.,1,Answer
exten => _*90.,n,Wait(1)
exten => _*90.,n,Macro(user-callerid,)
exten => _*90.,n,Set(fromext=${AMPUSER})
exten => _*90.,n,Set(toext=${EXTEN:3})
exten => _*90.,n,Set(DB(CFB/${fromext})=${toext})
exten => _*90.,n(hook_2),Playback(call-fwd-on-busy&for&extension)
exten => _*90.,n,SayDigits(${fromext})
exten => _*90.,n,Playback(is-set-to)
exten => _*90.,n,SayDigits(${toext})
exten => _*90.,n,Macro(hangupcall,)

;--== end of [app-cf-busy-on] ==--;


[app-cf-off]
include => app-cf-off-custom
exten => *73,1,Answer
exten => *73,n,Wait(1)
exten => *73,n,Macro(user-callerid,)
exten => *73,n,Set(fromext=${AMPUSER})
exten => *73,n,Noop(Deleting: CF/${fromext} ${DB_DELETE(CF/${fromext})})
exten => *73,n,Set(STATE=NOT_INUSE)
exten => *73,n,Gosub(app-cf-off,sstate,1())
exten => *73,n(hook_1),Playback(call-fwd-unconditional&de-activated)
exten => *73,n,Macro(hangupcall,)

exten => _*73.,1,Answer
exten => _*73.,n,Wait(1)
exten => _*73.,n,Set(fromext=${EXTEN:3})
exten => _*73.,n,Noop(Deleting: CF/${fromext} ${DB_DELETE(CF/${fromext})})
exten => _*73.,n,Set(STATE=NOT_INUSE)
exten => _*73.,n,Gosub(app-cf-off,sstate,1())
exten => _*73.,n(hook_2),Playback(call-fwd-unconditional&for&extension)
exten => _*73.,n,SayDigits(${fromext})
exten => _*73.,n,Playback(cancelled)
exten => _*73.,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:CF${fromext})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${fromext}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVCF${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-cf-off] ==--;


[app-cf-off-any]
include => app-cf-off-any-custom
exten => *74,1,Answer
exten => *74,n,Macro(user-callerid,)
exten => *74,n,Wait(1)
exten => *74,n,Read(fromext,please-enter-your&extension&then-press-pound,,,,)
exten => *74,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *74,n,Wait(1)
exten => *74,n,Noop(Deleting: CF/${fromext} ${DB_DELETE(CF/${fromext})})
exten => *74,n,Set(STATE=NOT_INUSE)
exten => *74,n,Gosub(app-cf-off-any,sstate,1())
exten => *74,n(hook_1),Playback(call-fwd-unconditional&for&extension)
exten => *74,n,SayDigits(${fromext})
exten => *74,n,Playback(cancelled)
exten => *74,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:CF${fromext})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${fromext}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVCF${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-cf-off-any] ==--;


[app-cf-on]
include => app-cf-on-custom
exten => *72,1,Answer
exten => *72,n,Wait(1)
exten => *72,n,Macro(user-callerid,)
exten => *72,n,Read(fromext,call-fwd-unconditional&please-enter-your&extension&then-press-pound,,,,)
exten => *72,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *72,n,Wait(1)
exten => *72,n(startread),Read(toext,ent-target-attendant&then-press-pound,,,,)
exten => *72,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *72,n,Wait(1)
exten => *72,n,Set(DB(CF/${fromext})=${toext})
exten => *72,n,Set(STATE=BUSY)
exten => *72,n,Gosub(app-cf-on,sstate,1())
exten => *72,n(hook_1),Playback(call-fwd-unconditional&for&extension)
exten => *72,n,SayDigits(${fromext})
exten => *72,n,Playback(is-set-to)
exten => *72,n,SayDigits(${toext})
exten => *72,n,Macro(hangupcall,)

exten => _*72.,1,Answer
exten => _*72.,n,Wait(1)
exten => _*72.,n,Macro(user-callerid,)
exten => _*72.,n,Set(fromext=${AMPUSER})
exten => _*72.,n,Set(toext=${EXTEN:3})
exten => _*72.,n,Set(DB(CF/${fromext})=${toext})
exten => _*72.,n,Set(STATE=BUSY)
exten => _*72.,n,Gosub(app-cf-on,sstate,1())
exten => _*72.,n(hook_2),Playback(call-fwd-unconditional&for&extension)
exten => _*72.,n,SayDigits(${fromext})
exten => _*72.,n,Playback(is-set-to)
exten => _*72.,n,SayDigits(${toext})
exten => _*72.,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:CF${fromext})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${fromext}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVCF${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-cf-on] ==--;


[app-cf-unavailable-off]
include => app-cf-unavailable-off-custom
exten => *53,1,Answer
exten => *53,n,Wait(1)
exten => *53,n,Macro(user-callerid,)
exten => *53,n,Set(fromext=${AMPUSER})
exten => *53,n,Noop(Deleting: CFU/${fromext} ${DB_DELETE(CFU/${fromext})})
exten => *53,n(hook_1),Playback(call-fwd-no-ans&de-activated)
exten => *53,n,Macro(hangupcall,)

exten => _*53.,1,Answer
exten => _*53.,n,Wait(1)
exten => _*53.,n,Set(fromext=${EXTEN:3})
exten => _*53.,n,Noop(Deleting: CFU/${fromext} ${DB_DELETE(CFU/${fromext})})
exten => _*53.,n(hook_2),Playback(call-fwd-no-ans&for&extension)
exten => _*53.,n,SayDigits(${fromext})
exten => _*53.,n,Playback(cancelled)
exten => _*53.,n,Macro(hangupcall,)

;--== end of [app-cf-unavailable-off] ==--;


[app-cf-unavailable-on]
include => app-cf-unavailable-on-custom
exten => *52,1,Answer
exten => *52,n,Wait(1)
exten => *52,n,Macro(user-callerid,)
exten => *52,n,Read(fromext,call-fwd-no-ans&please-enter-your&extension&then-press-pound,,,,)
exten => *52,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *52,n,Wait(1)
exten => *52,n(startread),Read(toext,ent-target-attendant&then-press-pound,,,,)
exten => *52,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *52,n,Wait(1)
exten => *52,n,Set(DB(CFU/${fromext})=${toext})
exten => *52,n(hook_1),Playback(call-fwd-no-ans&for&extension)
exten => *52,n,SayDigits(${fromext})
exten => *52,n,Playback(is-set-to)
exten => *52,n,SayDigits(${toext})
exten => *52,n,Macro(hangupcall,)

exten => _*52.,1,Answer
exten => _*52.,n,Wait(1)
exten => _*52.,n,Macro(user-callerid,)
exten => _*52.,n,Set(fromext=${AMPUSER})
exten => _*52.,n,Set(toext=${EXTEN:3})
exten => _*52.,n,Set(DB(CFU/${fromext})=${toext})
exten => _*52.,n(hook_2),Playback(call-fwd-no-ans&for&extension)
exten => _*52.,n,SayDigits(${fromext})
exten => _*52.,n,Playback(is-set-to)
exten => _*52.,n,SayDigits(${toext})
exten => _*52.,n,Macro(hangupcall,)

;--== end of [app-cf-unavailable-on] ==--;


[app-cf-toggle]
include => app-cf-toggle-custom
exten => *740,1,Answer
exten => *740,n,Wait(1)
exten => *740,n,Macro(user-callerid,)
exten => *740,n,Set(fromext=${AMPUSER})
exten => *740,n,GotoIf($["${DB(CF/${fromext})}" = ""]?activate:deactivate)
exten => *740,n(activate),Read(toext,ent-target-attendant&then-press-pound,,,,)
exten => *740,n,GotoIf($["${toext}"=""]?activate)
exten => *740,n,Wait(1)
exten => *740,n(toext),Set(DB(CF/${fromext})=${toext})
exten => *740,n,Set(STATE=BUSY)
exten => *740,n,Gosub(app-cf-toggle,sstate,1())
exten => *740,n(hook_on),Playback(call-fwd-unconditional&for&extension)
exten => *740,n,SayDigits(${fromext})
exten => *740,n,Playback(is-set-to)
exten => *740,n,SayDigits(${toext})
exten => *740,n,Macro(hangupcall,)
exten => *740,n(setdirect),Answer
exten => *740,n,Wait(1)
exten => *740,n,Macro(user-callerid,)
exten => *740,n,Goto(toext)
exten => *740,n(deactivate),Noop(Deleting: CF/${fromext} ${DB_DELETE(CF/${fromext})})
exten => *740,n,Set(STATE=NOT_INUSE)
exten => *740,n,Gosub(app-cf-toggle,sstate,1())
exten => *740,n(hook_off),Playback(call-fwd-unconditional&de-activated)
exten => *740,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:CF${fromext})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${fromext}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVCF${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-cf-toggle] ==--;


[ext-cf-hints]
include => ext-cf-hints-custom
exten => *7403050,1,Goto(app-cf-toggle,*740,1)
exten => *7403050,hint,Custom:DEVCF3050

exten => _*7403050.,1,Set(toext=${EXTEN:8})
exten => _*7403050.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403051,1,Goto(app-cf-toggle,*740,1)
exten => *7403051,hint,Custom:DEVCF3051

exten => _*7403051.,1,Set(toext=${EXTEN:8})
exten => _*7403051.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403301,1,Goto(app-cf-toggle,*740,1)
exten => *7403301,hint,Custom:DEVCF3301

exten => _*7403301.,1,Set(toext=${EXTEN:8})
exten => _*7403301.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403302,1,Goto(app-cf-toggle,*740,1)
exten => *7403302,hint,Custom:DEVCF3302

exten => _*7403302.,1,Set(toext=${EXTEN:8})
exten => _*7403302.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403303,1,Goto(app-cf-toggle,*740,1)
exten => *7403303,hint,Custom:DEVCF3303

exten => _*7403303.,1,Set(toext=${EXTEN:8})
exten => _*7403303.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403304,1,Goto(app-cf-toggle,*740,1)
exten => *7403304,hint,Custom:DEVCF3304

exten => _*7403304.,1,Set(toext=${EXTEN:8})
exten => _*7403304.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403307,1,Goto(app-cf-toggle,*740,1)
exten => *7403307,hint,Custom:DEVCF3307

exten => _*7403307.,1,Set(toext=${EXTEN:8})
exten => _*7403307.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403310,1,Goto(app-cf-toggle,*740,1)
exten => *7403310,hint,Custom:DEVCF3310

exten => _*7403310.,1,Set(toext=${EXTEN:8})
exten => _*7403310.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403311,1,Goto(app-cf-toggle,*740,1)
exten => *7403311,hint,Custom:DEVCF3311

exten => _*7403311.,1,Set(toext=${EXTEN:8})
exten => _*7403311.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403312,1,Goto(app-cf-toggle,*740,1)
exten => *7403312,hint,Custom:DEVCF3312

exten => _*7403312.,1,Set(toext=${EXTEN:8})
exten => _*7403312.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403313,1,Goto(app-cf-toggle,*740,1)
exten => *7403313,hint,Custom:DEVCF3313

exten => _*7403313.,1,Set(toext=${EXTEN:8})
exten => _*7403313.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7403314,1,Goto(app-cf-toggle,*740,1)
exten => *7403314,hint,Custom:DEVCF3314

exten => _*7403314.,1,Set(toext=${EXTEN:8})
exten => _*7403314.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7404444,1,Goto(app-cf-toggle,*740,1)
exten => *7404444,hint,Custom:DEVCF4444

exten => _*7404444.,1,Set(toext=${EXTEN:8})
exten => _*7404444.,n,Goto(app-cf-toggle,*740,setdirect)

exten => *7405123,1,Goto(app-cf-toggle,*740,1)
exten => *7405123,hint,Custom:DEVCF5123

exten => _*7405123.,1,Set(toext=${EXTEN:8})
exten => _*7405123.,n,Goto(app-cf-toggle,*740,setdirect)

;--== end of [ext-cf-hints] ==--;


[app-fmf-toggle]
include => app-fmf-toggle-custom
exten => *21,1,Goto(app-fmf-toggle,s,start)

exten => s,1(start),Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,GotoIf($["${DB(AMPUSER/${AMPUSER}/followme/ddial)}" = "EXTENSION"]?activate)
exten => s,n,GotoIf($["${DB(AMPUSER/${AMPUSER}/followme/ddial)}" = "DIRECT"]?deactivate:end)
exten => s,n(deactivate),Set(DB(AMPUSER/${AMPUSER}/followme/ddial)=EXTENSION)
exten => s,n,Set(STATE=NOT_INUSE)
exten => s,n,Gosub(app-fmf-toggle,sstate,1())
exten => s,n(hook_off),Playback(followme&de-activated)
exten => s,n(end),Macro(hangupcall,)
exten => s,n(activate),Set(DB(AMPUSER/${AMPUSER}/followme/ddial)=DIRECT)
exten => s,n,Set(STATE=INUSE)
exten => s,n,Gosub(app-fmf-toggle,sstate,1())
exten => s,n(hook_on),Playback(followme&activated)
exten => s,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICES=${DB(AMPUSER/${AMPUSER}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:FOLLOWME${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-fmf-toggle] ==--;


[ext-findmefollow]
include => ext-findmefollow-custom
exten => *213050,1,Goto(app-fmf-toggle,*21,1)
exten => *213050,hint,Custom:FOLLOWME3050

exten => *213051,1,Goto(app-fmf-toggle,*21,1)
exten => *213051,hint,Custom:FOLLOWME3051

exten => *213301,1,Goto(app-fmf-toggle,*21,1)
exten => *213301,hint,Custom:FOLLOWME3301

exten => *213302,1,Goto(app-fmf-toggle,*21,1)
exten => *213302,hint,Custom:FOLLOWME3302

exten => *213303,1,Goto(app-fmf-toggle,*21,1)
exten => *213303,hint,Custom:FOLLOWME3303

exten => *213304,1,Goto(app-fmf-toggle,*21,1)
exten => *213304,hint,Custom:FOLLOWME3304

exten => *213307,1,Goto(app-fmf-toggle,*21,1)
exten => *213307,hint,Custom:FOLLOWME3307

exten => *213310,1,Goto(app-fmf-toggle,*21,1)
exten => *213310,hint,Custom:FOLLOWME3310

exten => *213311,1,Goto(app-fmf-toggle,*21,1)
exten => *213311,hint,Custom:FOLLOWME3311

exten => *213312,1,Goto(app-fmf-toggle,*21,1)
exten => *213312,hint,Custom:FOLLOWME3312

exten => *213313,1,Goto(app-fmf-toggle,*21,1)
exten => *213313,hint,Custom:FOLLOWME3313

exten => *213314,1,Goto(app-fmf-toggle,*21,1)
exten => *213314,hint,Custom:FOLLOWME3314

exten => *214444,1,Goto(app-fmf-toggle,*21,1)
exten => *214444,hint,Custom:FOLLOWME4444

exten => *215123,1,Goto(app-fmf-toggle,*21,1)
exten => *215123,hint,Custom:FOLLOWME5123

;--== end of [ext-findmefollow] ==--;


[app-dnd-off]
include => app-dnd-off-custom
exten => *79,1,Answer
exten => *79,n,Wait(1)
exten => *79,n,Macro(user-callerid,)
exten => *79,n,Noop(Deleting: DND/${AMPUSER} ${DB_DELETE(DND/${AMPUSER})})
exten => *79,n,Set(STATE=NOT_INUSE)
exten => *79,n,Gosub(app-dnd-off,sstate,1())
exten => *79,n(hook_1),Playback(do-not-disturb&de-activated)
exten => *79,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:DND${AMPUSER})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${AMPUSER}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVDND${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-dnd-off] ==--;


[app-dnd-on]
include => app-dnd-on-custom
exten => *78,1,Answer
exten => *78,n,Wait(1)
exten => *78,n,Macro(user-callerid,)
exten => *78,n,Set(DB(DND/${AMPUSER})=YES)
exten => *78,n,Set(STATE=BUSY)
exten => *78,n,Gosub(app-dnd-on,sstate,1())
exten => *78,n(hook_1),Playback(do-not-disturb&activated)
exten => *78,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:DND${AMPUSER})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${AMPUSER}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVDND${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-dnd-on] ==--;


[app-dnd-toggle]
include => app-dnd-toggle-custom
exten => *76,1,Answer
exten => *76,n,Wait(1)
exten => *76,n,Macro(user-callerid,)
exten => *76,n,GotoIf($["${DB(DND/${AMPUSER})}" = ""]?activate:deactivate)
exten => *76,n(activate),Set(DB(DND/${AMPUSER})=YES)
exten => *76,n,Set(STATE=BUSY)
exten => *76,n,Gosub(app-dnd-toggle,sstate,1())
exten => *76,n(hook_on),Playback(do-not-disturb&activated)
exten => *76,n,Macro(hangupcall,)
exten => *76,n(deactivate),Noop(Deleting: DND/${AMPUSER} ${DB_DELETE(DND/${AMPUSER})})
exten => *76,n,Set(STATE=NOT_INUSE)
exten => *76,n,Gosub(app-dnd-toggle,sstate,1())
exten => *76,n(hook_off),Playback(do-not-disturb&de-activated)
exten => *76,n,Macro(hangupcall,)

exten => sstate,1,Set(DEVICE_STATE(Custom:DND${AMPUSER})=${STATE})
exten => sstate,n,Set(DEVICES=${DB(AMPUSER/${AMPUSER}/device)})
exten => sstate,n,GotoIf($["${DEVICES}" = "" ]?return)
exten => sstate,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => sstate,n,Set(ITER=1)
exten => sstate,n(begin),Set(DEVICE_STATE(Custom:DEVDND${CUT(DEVICES,&,${ITER})})=${STATE})
exten => sstate,n,Set(ITER=$[${ITER} + 1])
exten => sstate,n,GotoIf($[${ITER} <= ${LOOPCNT}]?begin)
exten => sstate,n(return),Return()

;--== end of [app-dnd-toggle] ==--;


[ext-dnd-hints]
include => ext-dnd-hints-custom
exten => *763050,1,Goto(app-dnd-toggle,*76,1)
exten => *763050,hint,Custom:DEVDND3050

exten => *763051,1,Goto(app-dnd-toggle,*76,1)
exten => *763051,hint,Custom:DEVDND3051

exten => *763301,1,Goto(app-dnd-toggle,*76,1)
exten => *763301,hint,Custom:DEVDND3301

exten => *763302,1,Goto(app-dnd-toggle,*76,1)
exten => *763302,hint,Custom:DEVDND3302

exten => *763303,1,Goto(app-dnd-toggle,*76,1)
exten => *763303,hint,Custom:DEVDND3303

exten => *763304,1,Goto(app-dnd-toggle,*76,1)
exten => *763304,hint,Custom:DEVDND3304

exten => *763307,1,Goto(app-dnd-toggle,*76,1)
exten => *763307,hint,Custom:DEVDND3307

exten => *763310,1,Goto(app-dnd-toggle,*76,1)
exten => *763310,hint,Custom:DEVDND3310

exten => *763311,1,Goto(app-dnd-toggle,*76,1)
exten => *763311,hint,Custom:DEVDND3311

exten => *763312,1,Goto(app-dnd-toggle,*76,1)
exten => *763312,hint,Custom:DEVDND3312

exten => *763313,1,Goto(app-dnd-toggle,*76,1)
exten => *763313,hint,Custom:DEVDND3313

exten => *763314,1,Goto(app-dnd-toggle,*76,1)
exten => *763314,hint,Custom:DEVDND3314

exten => *764444,1,Goto(app-dnd-toggle,*76,1)
exten => *764444,hint,Custom:DEVDND4444

exten => *765123,1,Goto(app-dnd-toggle,*76,1)
exten => *765123,hint,Custom:DEVDND5123

;--== end of [ext-dnd-hints] ==--;


[ivr-3] ; Unnamed
include => ivr-3-custom
include => from-did-direct-ivr
exten => s,1,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT})
exten => s,n,Set(_IVR_CONTEXT=${CONTEXT})
exten => s,n,Set(__IVR_RETVM=)
exten => s,n,GotoIf($["${CDR(disposition)}" = "ANSWERED"]?skip)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(skip),Set(IVR_MSG=)
exten => s,n(start),Set(TIMEOUT(digit)=3)
exten => s,n,ExecIf($["${IVR_MSG}" != ""]?Background(${IVR_MSG}))
exten => s,n,WaitExten(10,)

exten => i,1,Playback(sorry-youre-having-problems)
exten => i,n,Goto(hang,1)

exten => t,1,Playback(sorry-youre-having-problems)
exten => t,n,Goto(hang,1)

exten => return,1,Set(_IVR_CONTEXT=${CONTEXT})
exten => return,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT_${CONTEXT}})
exten => return,n,Set(IVR_MSG=)
exten => return,n,Goto(s,start)

exten => h,1,Hangup

exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup

;--== end of [ivr-3] ==--;


[app-pbdirectory]
include => app-pbdirectory-custom
exten => 411,1,Goto(pbdirectory,1)

exten => pbdirectory,1,Answer
exten => pbdirectory,n,Wait(1)
exten => pbdirectory,n,Macro(user-callerid,)
exten => pbdirectory,n,AGI(pbdirectory)
exten => pbdirectory,n,GotoIf($["${dialnumber}"=""]?hangup,1)
exten => pbdirectory,n,Noop(Got number to dial: ${dialnumber})
exten => pbdirectory,n,Dial(Local/${dialnumber}@from-internal/n,)

exten => hangup,1,Hangup

;--== end of [app-pbdirectory] ==--;


[app-recordings]
include => app-recordings-custom
exten => *77,1,Macro(user-callerid,)
exten => *77,n,Wait(2)
exten => *77,n,Macro(systemrecording,dorecord)

exten => *99,1,Macro(user-callerid,)
exten => *99,n,Wait(2)
exten => *99,n,Macro(systemrecording,docheck)

;--== end of [app-recordings] ==--;


[macro-systemrecording]
include => macro-systemrecording-custom
exten => s,1,Set(RECFILE=${IF($["${ARG2}" = ""]?/var/spool/asterisk/tmp/${AMPUSER}-ivrrecording:${ARG2})})
exten => s,n,ExecIf($["${ARG3}" != ""]?Authenticate(${ARG3}))
exten => s,n,Goto(${ARG1},1)

exten => dorecord,1,GotoIf($["${ARG2}" = ""]?skipremove)
exten => dorecord,n,System(rm ${ASTVARLIBDIR}/sounds/${RECFILE}.*)
exten => dorecord,n(skipremove),Record(${RECFILE}.wav,,,k)
exten => dorecord,n,Wait(1)
exten => dorecord,n,Goto(confmenu,1)

exten => docheck,1,Playback(beep)
exten => docheck,n(dc_start),Background(${RECFILE},m,${CHANNEL(language)},macro-systemrecording)
exten => docheck,n,Wait(1)
exten => docheck,n,Goto(confmenu,1)

exten => confmenu,1,Background(to-listen-to-it&press-1&to-rerecord-it&press-star&astcc-followed-by-pound,m,${CHANNEL(language)},macro-systemrecording)
exten => confmenu,n,Read(RECRESULT,,1,,,4)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x*"]?dorecord,1)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x1"]?docheck,2)
exten => confmenu,n,Goto(1)

exten => 1,1,Goto(docheck,dc_start)

exten => *,1,Goto(dorecord,1)

exten => t,1,Playback(goodbye)
exten => t,n,Hangup

exten => i,1,Playback(pm-invalid-option)
exten => i,n,Goto(confmenu,1)

exten => h,1,Hangup

;--== end of [macro-systemrecording] ==--;


[ext-fax]
include => ext-fax-custom
exten => s,1,Macro(user-callerid,)
exten => s,n,Noop(Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => s,n(receivefax),StopPlaytones
exten => s,n,ReceiveFAX(${ASTSPOOLDIR}/fax/${UNIQUEID}.tif,f)
exten => s,n,ExecIf($["${FAXSTATUS:0:6}"="FAILED" && "${FAXERROR}"!="INIT_ERROR"]?Set(FAXSTATUS="FAILED: error: ${FAXERROR} statusstr: ${FAXOPT(statusstr)}"))
exten => s,n,Hangup

exten => h,1,GotoIf($[${STAT(e,${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)} = 0]?failed)
exten => h,n(process),GotoIf($[${LEN(${FAX_RX_EMAIL})} = 0]?noemail)
exten => h,n(delete_opt),Set(DELETE_AFTER_SEND=true)
exten => h,n,System(${ASTVARLIBDIR}/bin/fax2mail.php --to "${FAX_RX_EMAIL}" --dest "${FROM_DID}" --callerid '${STRREPLACE(CALLERID(all),',\\')}' --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --exten "${FAX_FOR}" --delete "${DELETE_AFTER_SEND}" --attachformat "${FAX_ATTACH_FORMAT}")
exten => h,n(end),Macro(hangupcall,)
exten => h,n(noemail),Noop(ERROR: No Email Address to send FAX: status: [${FAXSTATUS}],  From: [${CALLERID(all)}])
exten => h,n,Macro(hangupcall,)
exten => h,process+101(failed),Noop(FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => h,n,Macro(hangupcall,)

;--== end of [ext-fax] ==--;


[app-fax]
include => app-fax-custom
exten => 666,1,Set(FAX_RX_EMAIL=fax@mydomain.com)
exten => 666,n,Goto(ext-fax,s,1)

exten => h,1,Macro(hangupcall,)

;--== end of [app-fax] ==--;


[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)})

;--== end of [ext-did-0001] ==--;


[ext-did-0002]
include => ext-did-0002-custom
exten => fax,1,Goto(${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)})

exten => 2106528457,1,Set(__FROM_DID=${EXTEN})
exten => 2106528457,n,Gosub(app-blacklist-check,s,1())
exten => 2106528457,n,Set(CDR(did)=${FROM_DID})
exten => 2106528457,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 2106528457,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 2106528457,n,Set(CALLERPRES()=allowed_not_screened)
exten => 2106528457,n(dest-ext),Goto(from-did-direct,5123,1)

;--== end of [ext-did-0002] ==--;


[app-dialvm]
include => app-dialvm-custom
exten => *98,1,Answer
exten => *98,n(start),Wait(1)
exten => *98,n,Noop(app-dialvm: Asking for mailbox)
exten => *98,n,Read(MAILBOX,vm-login,,,3,2)
exten => *98,n(check),Noop(app-dialvm: Got Mailbox ${MAILBOX})
exten => *98,n,Macro(get-vmcontext,${MAILBOX})
exten => *98,n,Set(VMBOXEXISTSSTATUS=${IF(${MAILBOX_EXISTS(${MAILBOX}@${VMCONTEXT})}?SUCCESS:FAILED)})
exten => *98,n,GotoIf($["${VMBOXEXISTSSTATUS}" = "SUCCESS"]?good:bad)
exten => *98,n,Macro(hangupcall,)
exten => *98,n(good),Noop(app-dialvm: Good mailbox ${MAILBOX}@${VMCONTEXT})
exten => *98,n,VoiceMailMain(${MAILBOX}@${VMCONTEXT})
exten => *98,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?playret)
exten => *98,n,Macro(hangupcall,)
exten => *98,n(bad),Noop(app-dialvm: BAD mailbox ${MAILBOX}@${VMCONTEXT})
exten => *98,n,Wait(1)
exten => *98,n,Noop(app-dialvm: Asking for password so people can't probe for existence of a mailbox)
exten => *98,n,Read(FAKEPW,vm-password,,,3,2)
exten => *98,n,Noop(app-dialvm: Asking for mailbox again)
exten => *98,n,Read(MAILBOX,vm-incorrect-mailbox,,,3,2)
exten => *98,n,Goto(check)
exten => *98,n,Macro(hangupcall,)
exten => *98,n(playret),Playback(beep&you-will-be-transfered-menu&silence/1)
exten => *98,n,Goto(${IVR_CONTEXT},return,1)

exten => _*98.,1,Answer
exten => _*98.,n,Wait(1)
exten => _*98.,n,Macro(get-vmcontext,${EXTEN:3})
exten => _*98.,n,VoiceMailMain(${EXTEN:3}@${VMCONTEXT})
exten => _*98.,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?${IVR_CONTEXT},return,1)
exten => _*98.,n,Macro(hangupcall,)

;--== end of [app-dialvm] ==--;


[app-vmmain]
include => app-vmmain-custom
exten => *97,1,Answer
exten => *97,n,Wait(1)
exten => *97,n,Macro(user-callerid,)
exten => *97,n,Macro(get-vmcontext,${AMPUSER})
exten => *97,n(check),Set(VMBOXEXISTSSTATUS=${IF(${MAILBOX_EXISTS(${AMPUSER}@${VMCONTEXT})}?SUCCESS:FAILED)})
exten => *97,n,GotoIf($["${VMBOXEXISTSSTATUS}" = "SUCCESS"]?mbexist)
exten => *97,n,VoiceMailMain()
exten => *97,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?playret)
exten => *97,n,Macro(hangupcall,)
exten => *97,check+101(mbexist),VoiceMailMain(${AMPUSER}@${VMCONTEXT})
exten => *97,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?playret)
exten => *97,n,Macro(hangupcall,)
exten => *97,n(playret),Playback(beep&you-will-be-transfered-menu&silence/1)
exten => *97,n,Goto(${IVR_CONTEXT},return,1)

;--== end of [app-vmmain] ==--;


[ext-group]
include => ext-group-custom
exten => h,1,Macro(hangupcall,)

;--== end of [ext-group] ==--;


[app-blacklist-check]
include => app-blacklist-check-custom
exten => s,1(check),GotoIf($["${BLACKLIST()}"="1"]?blacklisted)
exten => s,n,Set(CALLED_BLACKLIST=1)
exten => s,n,Return()
exten => s,n(blacklisted),Answer
exten => s,n,Wait(1)
exten => s,n,Zapateller()
exten => s,n,Playback(ss-noservice)
exten => s,n,Hangup

;--== end of [app-blacklist-check] ==--;


[app-blacklist]
include => app-blacklist-custom
exten => *30,1,Goto(app-blacklist-add,s,1)

exten => *32,1,Goto(app-blacklist-last,s,1)

exten => *31,1,Goto(app-blacklist-remove,s,1)

;--== end of [app-blacklist] ==--;


[app-blacklist-add]
include => app-blacklist-add-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(NumLoops=0)
exten => s,n(start),Playback(enter-num-blacklist)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=60)
exten => s,n,Read(blacknr,then-press-pound,,,,)
exten => s,n,SayDigits(${blacknr})
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)

exten => 1,1,GotoIf($[ "${blacknr}" != ""]?:app-blacklist-add-invalid,s,1)
exten => 1,n,Set(DB(blacklist/${blacknr})=1)
exten => 1,n,Playback(num-was-successfully&added)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

;--== end of [app-blacklist-add] ==--;


[app-blacklist-add-invalid]
include => app-blacklist-add-invalid-custom
exten => s,1,Set(NumLoops=$[${NumLoops} + 1])
exten => s,n,Playback(pm-invalid-option)
exten => s,n,GotoIf($[${NumLoops} < 3]?app-blacklist-add,s,start)
exten => s,n,Playback(goodbye)
exten => s,n,Hangup

;--== end of [app-blacklist-add-invalid] ==--;


[app-blacklist-last]
include => app-blacklist-last-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(lastcaller=${DB(CALLTRACE/${CALLERID(number)})})
exten => s,n,GotoIf($[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]?noinfo)
exten => s,n,Playback(privacy-to-blacklist-last-caller&telephone-number)
exten => s,n,SayDigits(${lastcaller})
exten => s,n,Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=7)
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Goto(end)
exten => s,n(noinfo),Playback(unidentified-no-callback)
exten => s,n,Hangup
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)

exten => 1,1,Set(DB(blacklist/${lastcaller})=1)
exten => 1,n,Playback(num-was-successfully)
exten => 1,n,Playback(added)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

;--== end of [app-blacklist-last] ==--;


[app-blacklist-remove]
include => app-blacklist-remove-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(entr-num-rmv-blklist)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=60)
exten => s,n,Read(blacknr,then-press-pound,,,,)
exten => s,n,SayDigits(${blacknr})
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)

exten => 1,1,Noop(Deleting: blacklist/${blacknr} ${DB_DELETE(blacklist/${blacknr})})
exten => 1,n,Playback(num-was-successfully&removed)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

;--== end of [app-blacklist-remove] ==--;


[app-dictate-record]
include => app-dictate-record-custom
exten => *34,1,Answer
exten => *34,n,Macro(user-callerid,)
exten => *34,n,Noop(CallerID is ${AMPUSER})
exten => *34,n,Set(DICTENABLED=${DB(AMPUSER/${AMPUSER}/dictate/enabled)})
exten => *34,n,GotoIf($[$["x${DICTENABLED}"="x"]|$["x${DICTENABLED}"="xdisabled"]]?nodict:dictok)
exten => *34,n(nodict),Playback(feature-not-avail-line)
exten => *34,n,Hangup
exten => *34,n(dictok),Dictate(/var/lib/asterisk/sounds/dictate/${AMPUSER})
exten => *34,n,Macro(hangupcall,)

;--== end of [app-dictate-record] ==--;


[app-dictate-send]
include => app-dictate-send-custom
exten => *35,1,Answer
exten => *35,n,Macro(user-callerid,)
exten => *35,n,Noop(CallerID is ${AMPUSER})
exten => *35,n,Set(DICTENABLED=${DB(AMPUSER/${AMPUSER}/dictate/enabled)})
exten => *35,n,GotoIf($[$["x${DICTENABLED}"="x"]|$["x${DICTENABLED}"="xdisabled"]]?nodict:dictok)
exten => *35,n(nodict),Playback(feature-not-avail-line)
exten => *35,n,Hangup
exten => *35,n(dictok),Read(DICTFILE,enter-filename-short,,,,)
exten => *35,n,Set(DICTEMAIL=${DB(AMPUSER/${AMPUSER}/dictate/email)})
exten => *35,n,Set(DICTFMT=${DB(AMPUSER/${AMPUSER}/dictate/format)})
exten => *35,n,Set(NAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => *35,n,Playback(dictation-being-processed)
exten => *35,n,System(/var/lib/asterisk/bin/audio-email.pl --file /var/lib/asterisk/sounds/dictate/${AMPUSER}/${DICTFILE}.raw --attachment dict-${DICTFILE} --format ${DICTFMT} --to ${DICTEMAIL} --subject "Dictation from ${NAME} Attached")
exten => *35,n,Playback(dictation-sent)
exten => *35,n,Macro(hangupcall,)

;--== end of [app-dictate-send] ==--;


[app-userlogonoff]
include => app-userlogonoff-custom
exten => *12,1,Macro(user-logoff,)
exten => *12,n(hook_off),Hangup

exten => *11,1,Macro(user-logon,)
exten => *11,n(hook_on_1),Hangup

exten => _*11.,1,Macro(user-logon,${EXTEN:3},)
exten => _*11.,n(hook_on_2),Hangup

;--== end of [app-userlogonoff] ==--;


[ext-local-confirm]
include => ext-local-confirm-custom
exten => _LC-.,1,ExecIf($["${ALERT_INFO}"!=""]?SIPAddHeader(Alert-Info: ${ALERT_INFO}))
exten => _LC-.,n,Dial(${DB(DEVICE/${EXTEN:3}/dial)},${RT},${DIAL_OPTIONS}M(auto-confirm^${RG_IDX}))

;--== end of [ext-local-confirm] ==--;


[findmefollow-ringallv2]
include => findmefollow-ringallv2-custom
exten => _FMPR-.,1,NoCDR()
exten => _FMPR-.,n,Set(RingGroupMethod=)
exten => _FMPR-.,n,Set(USE_CONFIRMATION=)
exten => _FMPR-.,n,Set(RINGGROUP_INDEX=)
exten => _FMPR-.,n,Macro(simple-dial,${EXTEN:5},${FMREALPRERING})
exten => _FMPR-.,n,ExecIf($["${DIALSTATUS}" = "BUSY"]?Set(SHARED(FM_DND,${FMUNIQUE})=DND))
exten => _FMPR-.,n,Hangup

exten => _FMGL-.,1,NoCDR()
exten => _FMGL-.,n,Set(ENDLOOP=$[${EPOCH} + ${FMPRERING} + 2])
exten => _FMGL-.,n(start),GotoIf($["${SHARED(FM_DND,${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(1)
exten => _FMGL-.,n,GotoIf($[${EPOCH} < ${ENDLOOP}]?start)
exten => _FMGL-.,n,Set(SHARED(FM_DND,${FMUNIQUE})=)
exten => _FMGL-.,n(dodial),Macro(dial,${FMGRPTIME},${DIAL_OPTIONS},${EXTEN:5})
exten => _FMGL-.,n,Hangup
exten => _FMGL-.,n+10(dodnd),Set(SHARED(FM_DND,${FMUNIQUE})=)
exten => _FMGL-.,n,GotoIf($["${FMPRIME}" = "FALSE"]?dodial)
exten => _FMGL-.,n,Hangup

;--== end of [findmefollow-ringallv2] ==--;


[app-pickup]
include => app-pickup-custom
exten => _**.,1,Macro(user-callerid,)
exten => _**.,n,Set(PICKUP_EXTEN=${AMPUSER})
exten => _**.,n,Pickup(${EXTEN:2}&${EXTEN:2}@PICKUPMARK)
exten => _**.,n,Hangup

;--== end of [app-pickup] ==--;


[app-zapbarge]
include => app-zapbarge-custom
exten => 888,1,Macro(user-callerid,)
exten => 888,n,Set(GROUP()=${CALLERID(number)})
exten => 888,n,Answer
exten => 888,n,Wait(1)
exten => 888,n,DAHDIBarge()
exten => 888,n,Hangup

;--== end of [app-zapbarge] ==--;


[app-chanspy]
include => app-chanspy-custom
exten => 555,1,Macro(user-callerid,)
exten => 555,n,Answer
exten => 555,n,Wait(1)
exten => 555,n,ChanSpy()
exten => 555,n,Hangup

;--== end of [app-chanspy] ==--;


[ext-test]
include => ext-test-custom
exten => 7777,1,Goto(from-pstn,${EXTEN},1)

exten => h,1,Macro(hangupcall,)

;--== end of [ext-test] ==--;


[ext-did]
include => ext-did-custom
include => ext-did-0001
include => ext-did-0002
exten => foo,1,Noop(bar)

;--== end of [ext-did] ==--;


[ext-did-catchall]
include => ext-did-catchall-custom
exten => s,1,Noop(No DID or CID Match)
exten => s,n(a2),Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,SayAlpha(${FROM_DID})
exten => s,n,Hangup

exten => _.,1,Set(__FROM_DID=${EXTEN})
exten => _.,n,Noop(Received an unknown call with DID set to ${EXTEN})
exten => _.,n,Goto(s,a2)

exten => h,1,Hangup

;--== end of [ext-did-catchall] ==--;


[ext-local]
include => ext-local-custom
exten => 3050,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3050/ringtimer)} > 0]?${DB(AMPUSER/3050/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3050,n,Macro(exten-vm,novm,3050,0,0,0)
exten => 3050,n(dest),Set(__PICKUPMARK=)
exten => 3050,n,Goto(${IVR_CONTEXT},return,1)
exten => 3050,hint,IAX2/3050&Custom:DND3050

exten => 3051,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3051/ringtimer)} > 0]?${DB(AMPUSER/3051/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3051,n,Macro(exten-vm,novm,3051,0,0,0)
exten => 3051,n(dest),Set(__PICKUPMARK=)
exten => 3051,n,Goto(${IVR_CONTEXT},return,1)
exten => 3051,hint,IAX2/3051&Custom:DND3051

exten => 3301,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3301/ringtimer)} > 0]?${DB(AMPUSER/3301/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3301,n,Macro(exten-vm,novm,3301,0,0,0)
exten => 3301,n(dest),Set(__PICKUPMARK=)
exten => 3301,n,Goto(${IVR_CONTEXT},return,1)
exten => 3301,hint,SIP/3301&Custom:DND3301

exten => 3302,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3302/ringtimer)} > 0]?${DB(AMPUSER/3302/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3302,n,Macro(exten-vm,novm,3302,0,0,0)
exten => 3302,n(dest),Set(__PICKUPMARK=)
exten => 3302,n,Goto(${IVR_CONTEXT},return,1)
exten => 3302,hint,SIP/3302&Custom:DND3302

exten => 3303,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3303/ringtimer)} > 0]?${DB(AMPUSER/3303/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3303,n,Macro(exten-vm,novm,3303,0,0,0)
exten => 3303,n(dest),Set(__PICKUPMARK=)
exten => 3303,n,Goto(${IVR_CONTEXT},return,1)
exten => 3303,hint,SIP/3303&Custom:DND3303

exten => 3304,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3304/ringtimer)} > 0]?${DB(AMPUSER/3304/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3304,n,Macro(exten-vm,novm,3304,0,0,0)
exten => 3304,n(dest),Set(__PICKUPMARK=)
exten => 3304,n,Goto(${IVR_CONTEXT},return,1)
exten => 3304,hint,SIP/3304&Custom:DND3304

exten => 3307,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3307/ringtimer)} > 0]?${DB(AMPUSER/3307/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3307,n,Macro(exten-vm,novm,3307,0,0,0)
exten => 3307,n(dest),Set(__PICKUPMARK=)
exten => 3307,n,Goto(${IVR_CONTEXT},return,1)
exten => 3307,hint,SIP/3307&Custom:DND3307

exten => 3310,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3310/ringtimer)} > 0]?${DB(AMPUSER/3310/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3310,n,Macro(exten-vm,novm,3310,0,0,0)
exten => 3310,n(dest),Set(__PICKUPMARK=)
exten => 3310,n,Goto(${IVR_CONTEXT},return,1)
exten => 3310,hint,SIP/3310&Custom:DND3310

exten => 3311,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3311/ringtimer)} > 0]?${DB(AMPUSER/3311/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3311,n,Macro(exten-vm,novm,3311,0,0,0)
exten => 3311,n(dest),Set(__PICKUPMARK=)
exten => 3311,n,Goto(${IVR_CONTEXT},return,1)
exten => 3311,hint,SIP/3311&Custom:DND3311

exten => 3312,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3312/ringtimer)} > 0]?${DB(AMPUSER/3312/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3312,n,Macro(exten-vm,novm,3312,0,0,0)
exten => 3312,n(dest),Set(__PICKUPMARK=)
exten => 3312,n,Goto(${IVR_CONTEXT},return,1)
exten => 3312,hint,SIP/3312&Custom:DND3312

exten => 3313,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3313/ringtimer)} > 0]?${DB(AMPUSER/3313/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3313,n,Macro(exten-vm,novm,3313,0,0,0)
exten => 3313,n(dest),Set(__PICKUPMARK=)
exten => 3313,n,Goto(${IVR_CONTEXT},return,1)
exten => 3313,hint,SIP/3313&Custom:DND3313

exten => 3314,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/3314/ringtimer)} > 0]?${DB(AMPUSER/3314/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 3314,n,Macro(exten-vm,novm,3314,0,0,0)
exten => 3314,n(dest),Set(__PICKUPMARK=)
exten => 3314,n,Goto(${IVR_CONTEXT},return,1)
exten => 3314,hint,SIP/3314&Custom:DND3314

exten => 4444,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/4444/ringtimer)} > 0]?${DB(AMPUSER/4444/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 4444,n,Macro(exten-vm,novm,4444,0,0,0)
exten => 4444,n(dest),Set(__PICKUPMARK=)
exten => 4444,n,Goto(${IVR_CONTEXT},return,1)
exten => 4444,hint,SIP/4444&Custom:DND4444

exten => 5123,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/5123/ringtimer)} > 0]?${DB(AMPUSER/5123/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 5123,n,Macro(exten-vm,novm,5123,0,0,0)
exten => 5123,n(dest),Set(__PICKUPMARK=)
exten => 5123,n,Goto(${IVR_CONTEXT},return,1)
exten => 5123,hint,SIP/5123&Custom:DND5123

exten => vmret,1,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?playret)
exten => vmret,n,Hangup
exten => vmret,n(playret),Playback(exited-vm-will-be-transfered&silence/1)
exten => vmret,n,Goto(${IVR_CONTEXT},return,1)

exten => h,1,Macro(hangupcall,)

;--== end of [ext-local] ==--;


[from-did-direct-ivr]
include => from-did-direct-ivr-custom
exten => 3050,1,Macro(blkvm-clr,)
exten => 3050,n,Set(__NODEST=)
exten => 3050,n,Goto(from-did-direct,3050,1)

exten => 3051,1,Macro(blkvm-clr,)
exten => 3051,n,Set(__NODEST=)
exten => 3051,n,Goto(from-did-direct,3051,1)

exten => 3301,1,Macro(blkvm-clr,)
exten => 3301,n,Set(__NODEST=)
exten => 3301,n,Goto(from-did-direct,3301,1)

exten => 3302,1,Macro(blkvm-clr,)
exten => 3302,n,Set(__NODEST=)
exten => 3302,n,Goto(from-did-direct,3302,1)

exten => 3303,1,Macro(blkvm-clr,)
exten => 3303,n,Set(__NODEST=)
exten => 3303,n,Goto(from-did-direct,3303,1)

exten => 3304,1,Macro(blkvm-clr,)
exten => 3304,n,Set(__NODEST=)
exten => 3304,n,Goto(from-did-direct,3304,1)

exten => 3307,1,Macro(blkvm-clr,)
exten => 3307,n,Set(__NODEST=)
exten => 3307,n,Goto(from-did-direct,3307,1)

exten => 3310,1,Macro(blkvm-clr,)
exten => 3310,n,Set(__NODEST=)
exten => 3310,n,Goto(from-did-direct,3310,1)

exten => 3311,1,Macro(blkvm-clr,)
exten => 3311,n,Set(__NODEST=)
exten => 3311,n,Goto(from-did-direct,3311,1)

exten => 3312,1,Macro(blkvm-clr,)
exten => 3312,n,Set(__NODEST=)
exten => 3312,n,Goto(from-did-direct,3312,1)

exten => 3313,1,Macro(blkvm-clr,)
exten => 3313,n,Set(__NODEST=)
exten => 3313,n,Goto(from-did-direct,3313,1)

exten => 3314,1,Macro(blkvm-clr,)
exten => 3314,n,Set(__NODEST=)
exten => 3314,n,Goto(from-did-direct,3314,1)

exten => 4444,1,Macro(blkvm-clr,)
exten => 4444,n,Set(__NODEST=)
exten => 4444,n,Goto(from-did-direct,4444,1)

exten => 5123,1,Macro(blkvm-clr,)
exten => 5123,n,Set(__NODEST=)
exten => 5123,n,Goto(from-did-direct,5123,1)

;--== end of [from-did-direct-ivr] ==--;


[sub-record-cancel]
include => sub-record-cancel-custom
exten => s,1,Set(__REC_POLICY_MODE=${REC_POLICY_MODE_SAVE})
exten => s,n,ExecIf($["${REC_STATUS}"!="RECORDING"]?Return())
exten => s,n,StopMixMonitor()
exten => s,n,Set(__REC_STATUS=)
exten => s,n,Set(MON_BASE=${IF($[${LEN(${MIXMON_DIR})}]?${MIXMON_DIR}:${ASTSPOOLDIR}/monitor/)}${YEAR}/${MONTH}/${DAY}/)
exten => s,n,Set(__MON_FMT=${IF($[${LEN(${MIXMON_FORMAT})}]?${IF($["${MIXMON_FORMAT}"="wav49"]?WAV:${MIXMON_FORMAT})}:wav)})
exten => s,n,ExecIf($[${LEN(${CALLFILENAME})} & ${STAT(f,${MON_BASE}${CALLFILENAME}.${MON_FMT})}]?System(rm -f ${MON_BASE}${CALLFILENAME}.${MON_FMT}))
exten => s,n,Set(__CALLFILENAME=)
exten => s,n,Set(CDR(recordingfile)=)
exten => s,n,Return()

;--== end of [sub-record-cancel] ==--;


[sub-record-check]
include => sub-record-check-custom
exten => s,1,Set(REC_POLICY_MODE_SAVE=${REC_POLICY_MODE})
exten => s,n,GotoIf($["${BLINDTRANSFER}" = ""]?check)
exten => s,n,ResetCDR()
exten => s,n,GotoIf($["${REC_STATUS}" != "RECORDING"]?check)
exten => s,n,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => s,n,MixMonitor(${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT},a,${MIXMON_POST})
exten => s,n(check),Set(__MON_FMT=${IF($["${MIXMON_FORMAT}"="wav49"]?WAV:${MIXMON_FORMAT})})
exten => s,n,GotoIf($["${REC_STATUS}"!="RECORDING"]?next)
exten => s,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => s,n,Return()
exten => s,n(next),ExecIf($[!${LEN(${ARG1})}]?Return())
exten => s,n,ExecIf($["${REC_POLICY_MODE}"="" & "${ARG3}"!=""]?Set(__REC_POLICY_MODE=${ARG3}))
exten => s,n,GotoIf($["${REC_STATUS}"!=""]?${ARG1},1)
exten => s,n,Set(__REC_STATUS=INITIALIZED)
exten => s,n,Set(NOW=${EPOCH})
exten => s,n,Set(__DAY=${STRFTIME(${NOW},,%d)})
exten => s,n,Set(__MONTH=${STRFTIME(${NOW},,%m)})
exten => s,n,Set(__YEAR=${STRFTIME(${NOW},,%Y)})
exten => s,n,Set(__TIMESTR=${YEAR}${MONTH}${DAY}-${STRFTIME(${NOW},,%H%M%S)})
exten => s,n,Set(__FROMEXTEN=${IF($[${LEN(${AMPUSER})}]?${AMPUSER}:${IF($[${LEN(${REALCALLERIDNUM})}]?${REALCALLERIDNUM}:unknown)})})
exten => s,n,Set(__CALLFILENAME=${ARG1}-${ARG2}-${FROMEXTEN}-${TIMESTR}-${UNIQUEID})
exten => s,n,Goto(${ARG1},1)

exten => rg,1,GosubIf($["${REC_POLICY_MODE}"="always"]?record,1(${EXTEN},${REC_POLICY_MODE},${FROMEXTEN}))
exten => rg,n,Return()

exten => force,1,GosubIf($["${REC_POLICY_MODE}"="always"]?record,1(${EXTEN},${REC_POLICY_MODE},${FROMEXTEN}))
exten => force,n,Return()

exten => q,1,GosubIf($["${REC_POLICY_MODE}"="always"]?recq,1(${EXTEN},${ARG2},${FROMEXTEN}))
exten => q,n,Return()

exten => out,1,ExecIf($["${REC_POLICY_MODE}"=""]?Set(__REC_POLICY_MODE=${DB(AMPUSER/${FROMEXTEN}/recording/out/external)}))
exten => out,n,GosubIf($["${REC_POLICY_MODE}"="always"]?record,1(exten,${ARG2},${FROMEXTEN}))
exten => out,n,Return()

exten => exten,1,GotoIf($["${REC_POLICY_MODE}"!=""]?callee)
exten => exten,n,Set(__REC_POLICY_MODE=${IF($[${LEN(${FROM_DID})}]?${DB(AMPUSER/${ARG2}/recording/in/external)}:${DB(AMPUSER/${ARG2}/recording/in/internal)})})
exten => exten,n,GotoIf($["${REC_POLICY_MODE}"="dontcare"]?caller)
exten => exten,n,GotoIf($["${DB(AMPUSER/${FROMEXTEN}/recording/out/internal)}"="dontcare" | "${FROM_DID}"!=""]?callee)
exten => exten,n,ExecIf($[${LEN(${DB(AMPUSER/${FROMEXTEN}/recording/priority)})}]?Set(CALLER_PRI=${DB(AMPUSER/${FROMEXTEN}/recording/priority)}):Set(CALLER_PRI=0))
exten => exten,n,ExecIf($[${LEN(${DB(AMPUSER/${ARG2}/recording/priority)})}]?Set(CALLEE_PRI=${DB(AMPUSER/${ARG2}/recording/priority)}):Set(CALLEE_PRI=0))
exten => exten,n,GotoIf($["${CALLER_PRI}"="${CALLEE_PRI}"]?${REC_POLICY}:${IF($[${CALLER_PRI}>${CALLEE_PRI}]?caller:callee)})
exten => exten,n(callee),GosubIf($["${REC_POLICY_MODE}"="always"]?record,1(${EXTEN},${ARG2},${FROMEXTEN}))
exten => exten,n,Return()
exten => exten,n(caller),Set(__REC_POLICY_MODE=${DB(AMPUSER/${FROMEXTEN}/recording/out/internal)})
exten => exten,n,GosubIf($["${REC_POLICY_MODE}"="always"]?record,1(${EXTEN},${ARG2},${FROMEXTEN}))
exten => exten,n,Return()

exten => conf,1,Gosub(recconf,1(${EXTEN},${ARG2},${ARG2}))
exten => conf,n,Return()

exten => page,1,GosubIf($["${REC_POLICY_MODE}"="always"]?recconf,1(${EXTEN},${ARG2},${FROMEXTEN}))
exten => page,n,Return()

exten => record,1,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => record,n,MixMonitor(${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT},,${MIXMON_POST})
exten => record,n,Set(__REC_STATUS=RECORDING)
exten => record,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => record,n,Return()

exten => recq,1,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => recq,n,Set(MONITOR_FILENAME=${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME})
exten => recq,n,MixMonitor(${MONITOR_FILENAME}.${MIXMON_FORMAT},${MONITOR_OPTIONS},${MIXMON_POST})
exten => recq,n,Set(__REC_STATUS=RECORDING)
exten => recq,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => recq,n,Return()

exten => recconf,1,Set(__CALLFILENAME=${IF($[${MEETME_INFO(parties,${ARG2})}]?${DB(RECCONF/${ARG2})}:${ARG1}-${ARG2}-${ARG3}-${TIMESTR}-${UNIQUEID})})
exten => recconf,n,ExecIf($[!${MEETME_INFO(parties,${ARG2})}]?Set(DB(RECCONF/${ARG2})=${CALLFILENAME}))
exten => recconf,n,Set(MEETME_RECORDINGFILE=${IF($[${LEN(${MIXMON_DIR})}]?${MIXMON_DIR}:${ASTSPOOLDIR}/monitor/)}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME})
exten => recconf,n,Set(MEETME_RECORDINGFORMAT=${MIXMON_FORMAT})
exten => recconf,n,ExecIf($["${REC_POLICY_MODE}"!="always"]?Return())
exten => recconf,n,Set(__REC_STATUS=RECORDING)
exten => recconf,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => recconf,n,Return()

;--== end of [sub-record-check] ==--;


[macro-one-touch-record]
include => macro-one-touch-record-custom
exten => s,1,Set(ONETOUCH_REC_SCRIPT_STATUS=)
exten => s,n,System(/var/lib/asterisk/bin/one_touch_record.php ${CHANNEL(name)})
exten => s,n,Noop(ONETOUCH_REC_SCRIPT_STATUS: [${ONETOUCH_REC_SCRIPT_STATUS}])
exten => s,n,ExecIf($["${ONETOUCH_REC}"="RECORDING"]?Playback(beep))
exten => s,n,ExecIf($["${ONETOUCH_REC}"="PAUSED"]?Playback(beep&beep))
exten => s,n,MacroExit()

;--== end of [macro-one-touch-record] ==--;


[macro-prepend-cid]
include => macro-prepend-cid-custom
exten => s,1,GotoIf($["${RGPREFIX}" = ""]?REPCID)
exten => s,n,GotoIf($["${RGPREFIX}" != "${CALLERID(name):0:${LEN(${RGPREFIX})}}"]?REPCID)
exten => s,n,Set(CALLERID(name)=${CALLERID(name):${LEN(${RGPREFIX})}})
exten => s,n,Set(_RGPREFIX=)
exten => s,n(REPCID),Set(_RGPREFIX=${ARG1})
exten => s,n,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)})

;--== end of [macro-prepend-cid] ==--;


[outbound-allroutes]
include => outbound-allroutes-custom
include => outrt-1 ; 0_outside
exten => foo,1,Noop(bar)

;--== end of [outbound-allroutes] ==--;


[outrt-1] ; 0_outside
include => outrt-1-custom
exten => _0.,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _0.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _0.,n,Set(_NODEST=)
exten => _0.,n,Gosub(sub-record-check,s,1(out,${EXTEN},))
exten => _0.,n,Macro(dialout-trunk,2,${EXTEN:1},,off)
exten => _0.,n,Macro(outisbusy,)

;--== end of [outrt-1] ==--;


[app-blackhole]
include => app-blackhole-custom
exten => hangup,1,Noop(Blackhole Dest: Hangup)
exten => hangup,n,Hangup

exten => zapateller,1,Noop(Blackhole Dest: Play SIT Tone)
exten => zapateller,n,Answer
exten => zapateller,n,Zapateller()

exten => musiconhold,1,Noop(Blackhole Dest: Put caller on hold forever)
exten => musiconhold,n,Answer
exten => musiconhold,n,MusicOnHold()

exten => congestion,1,Noop(Blackhole Dest: Congestion)
exten => congestion,n,Playtones(congestion)
exten => congestion,n,Congestion(20)
exten => congestion,n,Hangup

exten => busy,1,Noop(Blackhole Dest: Busy)
exten => busy,n,Busy(20)
exten => busy,n,Hangup

exten => ring,1,Noop(Blackhole Dest: Ring)
exten => ring,n,Answer
exten => ring,n,Playtones(ring)
exten => ring,n,Wait(300)
exten => ring,n,Hangup

;--== end of [app-blackhole] ==--;


[bad-number]
include => bad-number-custom
exten => _X.,1,ResetCDR()
exten => _X.,n,NoCDR()
exten => _X.,n,Progress
exten => _X.,n,Wait(1)
exten => _X.,n,Progress
exten => _X.,n,Playback(silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer)
exten => _X.,n,Wait(1)
exten => _X.,n,Congestion(20)
exten => _X.,n,Hangup

;--== end of [bad-number] ==--;


[macro-confirm]
include => macro-confirm-custom
exten => s,1,Set(LOOPCOUNT=0)
exten => s,n,Set(__MACRO_RESULT=ABORT)
exten => s,n,Set(MSG1=${IF($["${ARG1}${ALT_CONFIRM_MSG}"=""]?incoming-call-1-accept-2-decline:${IF($[${LEN(${ALT_CONFIRM_MSG})}>0]?${ALT_CONFIRM_MSG}:${ARG1})})})
exten => s,n(start),Background(${MSG1},m,${CHANNEL(language)},macro-confirm)
exten => s,n,Read(INPUT,,1,,,4)
exten => s,n,GotoIf($[${LEN(${INPUT})} > 0]?${INPUT},1:t,1)

exten => 1,1,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"="0" & "${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}"=""]?toolate,1)
exten => 1,n,Noop(Deleting: RG/${ARG3}/${UNIQCHAN} ${DB_DELETE(RG/${ARG3}/${UNIQCHAN})})
exten => 1,n,Macro(blkvm-clr,)
exten => 1,n,Set(SHARED(ANSWER_STATUS,${FORCE_CONFIRM})=)
exten => 1,n(skip),Set(__MACRO_RESULT=)
exten => 1,n,ExecIf($[("${MOHCLASS}"!="default") & ("${MOHCLASS}"!="")]?Set(CHANNEL(musicclass)=${MOHCLASS}))
exten => 1,n(exitopt1),MacroExit()

exten => 2,1,Goto(noanswer,1)

exten => 3,1,SayDigits(${CALLCONFIRMCID})
exten => 3,n,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"="0" & "${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}"=""]?toolate,1:s,start)

exten => t,1,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"="0" & "${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}"=""]?toolate,1)
exten => t,n,Set(LOOPCOUNT=$[ ${LOOPCOUNT} + 1 ])
exten => t,n,GotoIf($[ ${LOOPCOUNT} < 5 ]?s,start:noanswer,1)

exten => _X,1,Background(invalid,m,${CHANNEL(language)},macro-confirm)
exten => _X,n,GotoIf($["${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}"="0" | "${SHARED(ANSWER_STATUS,${FORCE_CONFIRM})}"=""]?toolate,1)
exten => _X,n,Set(LOOPCOUNT=$[ ${LOOPCOUNT} + 1 ])
exten => _X,n,GotoIf($[ ${LOOPCOUNT} < 5 ]?s,start:noanswer,1)

exten => noanswer,1,Set(__MACRO_RESULT=ABORT)
exten => noanswer,n(exitnoanswer),MacroExit()

exten => toolate,1,Set(MSG2=${IF($["foo${ARG2}" != "foo"]?${ARG2}:"incoming-call-no-longer-avail")})
exten => toolate,n,Playback(${MSG2})
exten => toolate,n,Set(__MACRO_RESULT=ABORT)
exten => toolate,n(exittoolate),MacroExit()

exten => h,1,Macro(hangupcall,)

;--== end of [macro-confirm] ==--;


[macro-auto-confirm]
include => macro-auto-confirm-custom
exten => s,1,Set(__MACRO_RESULT=)
exten => s,n,Set(CFIGNORE=)
exten => s,n,Set(MASTER_CHANNEL(CFIGNORE)=)
exten => s,n,Set(FORWARD_CONTEXT=from-internal)
exten => s,n,Set(MASTER_CHANNEL(FORWARD_CONTEXT)=from-internal)
exten => s,n,Macro(blkvm-clr,)
exten => s,n,Noop(Deleting: RG/${ARG1}/${UNIQCHAN} ${DB_DELETE(RG/${ARG1}/${UNIQCHAN})})
exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && "${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(MASTER_CHANNEL(CONNECTEDLINE(num))=${DIALEDPEERNUMBER}))
exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && "${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(MASTER_CHANNEL(CONNECTEDLINE(name))=${DB(AMPUSER/${DIALEDPEERNUMBER}/cidname)}))

;--== end of [macro-auto-confirm] ==--;


[macro-auto-blkvm]
include => macro-auto-blkvm-custom
exten => s,1,Set(__MACRO_RESULT=)
exten => s,n,Set(CFIGNORE=)
exten => s,n,Set(MASTER_CHANNEL(CFIGNORE)=)
exten => s,n,Set(FORWARD_CONTEXT=from-internal)
exten => s,n,Set(MASTER_CHANNEL(FORWARD_CONTEXT)=from-internal)
exten => s,n,Macro(blkvm-clr,)
exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && "${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(MASTER_CHANNEL(CONNECTEDLINE(num))=${DIALEDPEERNUMBER}))
exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && "${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(MASTER_CHANNEL(CONNECTEDLINE(name))=${DB(AMPUSER/${DIALEDPEERNUMBER}/cidname)}))

;--== end of [macro-auto-blkvm] ==--;


[sub-pincheck]
include => sub-pincheck-custom
exten => s,1,Authenticate(${ARG3},)
exten => s,n,ResetCDR()
exten => s,n,Return()

;--== end of [sub-pincheck] ==--;


[macro-dialout-trunk]
include => macro-dialout-trunk-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,GosubIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]?sub-pincheck,s,1())
exten => s,n,GotoIf($["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(OUTBOUND_GROUP=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${IF($["${DB_EXISTS(TRUNK/${DIAL_TRUNK}/dialopts)}" = "1"]?${DB_RESULT}:${TRUNK_OPTIONS})})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),GosubIf($["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""]?sub-flp-${DIAL_TRUNK},s,1())
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)})
exten => s,n,ExecIf($["${MOHCLASS}"!="default" & "${MOHCLASS}"!="" & "${FORCE_CONFIRM}"="" ]?Set(DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS}))
exten => s,n,ExecIf($["${FORCE_CONFIRM}"!="" ]?Set(DIAL_TRUNK_OPTIONS=${DIAL_TRUNK_OPTIONS}M(confirm)))
exten => s,n(gocall),Macro(dialout-trunk-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = "BYPASS"]?bypass,1)
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(CONNECTEDLINE(num,i)=${DIAL_NUMBER}))
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(CONNECTEDLINE(name,i)=CID:${CALLERID(number)}))
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},${TRUNK_RING_TIMER},${DIAL_TRUNK_OPTIONS})
exten => s,n,Noop(Dial failed for some reason with DIALSTATUS = ${DIALSTATUS} and HANGUPCAUSE = ${HANGUPCAUSE})
exten => s,n,GotoIf($["${ARG4}" = "on"]?continue,1:s-${DIALSTATUS},1)
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)})
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum)
exten => s,n(outnum),Set(the_num=${OUTNUM})
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},${TRUNK_RING_TIMER},${DIAL_TRUNK_OPTIONS})
exten => s,n,Noop(Dial failed for some reason with DIALSTATUS = ${DIALSTATUS} and HANGUPCAUSE = ${HANGUPCAUSE})
exten => s,n,GotoIf($["${ARG4}" = "on"]?continue,1:s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)

exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)

exten => s-ANSWER,1,Noop(Call successfully answered - Hanging up now)
exten => s-ANSWER,n,Macro(hangupcall,)

exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Progress
exten => s-NOANSWER,n,Playback(number-not-answering,noanswer)
exten => s-NOANSWER,n,Congestion(20)

exten => s-INVALIDNMBR,1,Noop(Dial failed due to trunk reporting Address Incomplete - giving up)
exten => s-INVALIDNMBR,n,Progress
exten => s-INVALIDNMBR,n,Playback(ss-noservice,noanswer)
exten => s-INVALIDNMBR,n,Busy(20)

exten => s-CHANGED,1,Noop(Dial failed due to trunk reporting Number Changed - giving up)
exten => s-CHANGED,n,Playtones(busy)
exten => s-CHANGED,n,Busy(20)

exten => _s-.,1,Set(RC=${IF($[${ISNULL(${HANGUPCAUSE})}]?0:${HANGUPCAUSE})})
exten => _s-.,n,Goto(${RC},1)

exten => 17,1,Goto(s-BUSY,1)

exten => 18,1,Goto(s-NOANSWER,1)

exten => 22,1,Goto(s-CHANGED,1)

exten => 23,1,Goto(s-CHANGED,1)

exten => 28,1,Goto(s-INVALIDNMBR,1)

exten => _X,1,Goto(continue,1)

exten => _X.,1,Goto(continue,1)

exten => continue,1(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} HANGUPCAUSE: ${HANGUPCAUSE} - failing through to other trunks)
exten => continue,n,Set(CALLERID(number)=${AMPUSER})

exten => disabletrunk,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk)

exten => bypass,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook)

exten => h,1,Macro(hangupcall,)

;--== end of [macro-dialout-trunk] ==--;


[macro-privacy-mgr]
include => macro-privacy-mgr-custom
exten => s,1,Set(KEEPCID=${CALLERID(num)})
exten => s,n,Set(TESTCID=${IF($["${CALLERID(num):0:1}"="+"]?${MATH(1+${CALLERID(num):1})}:${MATH(1+${CALLERID(num)})})})
exten => s,n,ExecIf($[${LEN(${TESTCID})}=0]?Set(CALLERID(num)=))
exten => s,n,PrivacyManager(${ARG1},${ARG2})
exten => s,n,GotoIf($["${PRIVACYMGRSTATUS}"="FAILED"]?fail)
exten => s,n,GosubIf($["${CALLED_BLACKLIST}"="1"]?app-blacklist-check,s,1())
exten => s,n,Set(CALLERID(num-pres)=allowed_passed_screen)
exten => s,n,MacroExit()
exten => s,n(fail),Noop(STATUS: ${PRIVACYMGRSTATUS} CID: ${CALLERID(num)} ${CALLERID(name)} CALLPRES: ${CALLLINGPRES})
exten => s,n,Playback(sorry-youre-having-problems&goodbye)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(20)

exten => h,1,Hangup

;--== end of [macro-privacy-mgr] ==--;


[macro-user-callerid]
include => macro-user-callerid-custom
exten => s,1,Set(TOUCH_MONITOR=${UNIQUEID})
exten => s,n,Set(AMPUSER=${IF($["foo${AMPUSER}" = "foo"]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,GotoIf($["${CUT(CHANNEL,@,2):5:5}"="queue" | ${LEN(${AMPUSERCIDNAME})}]?report)
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,GotoIf($["x${AMPUSERCIDNAME:1:2}" = "x"]?report)
exten => s,n,Set(AMPUSERCID=${IF($["${ARG2}" != "EXTERNAL" & "${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})})
exten => s,n,Set(__DIAL_OPTIONS=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/dialopts)}" = "1"]?${DB_RESULT}:${DIAL_OPTIONS})})
exten => s,n,Set(CALLERID(all)="${AMPUSERCIDNAME}" <${AMPUSERCID}>)
exten => s,n,GotoIf($["${ARG1}"="LIMIT" & ${LEN(${AMPUSER})} & "${DB(AMPUSER/${AMPUSER}/concurrency_limit)}">"0" & "${GROUP_COUNT(${AMPUSER}@concurrency_limit)}">="${DB(AMPUSER/${AMPUSER}/concurrency_limit)}"]?limit)
exten => s,n,ExecIf($["${ARG1}"="LIMIT" & ${LEN(${AMPUSER})}]?Set(GROUP(concurrency_limit)=${AMPUSER}))
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/language)}" != ""]?Set(CHANNEL(language)=${DB(AMPUSER/${AMPUSER}/language)}))
exten => s,n(report),GotoIf($[ "${ARG1}" = "SKIPTTL" | "${ARG1}" = "LIMIT" ]?continue)
exten => s,n(report2),Set(__TTL=${IF($["foo${TTL}" = "foo"]?64:$[ ${TTL} - 1 ])})
exten => s,n,GotoIf($[ ${TTL} > 0 ]?continue)
exten => s,n,Wait(${RINGTIMER})
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(im-sorry&an-error-has-occured&with&call-forwarding)
exten => s,n,Macro(hangupcall,)
exten => s,n(limit),Answer
exten => s,n,Wait(1)
exten => s,n,Playback(beep&im-sorry&your&simul-call-limit-reached&goodbye)
exten => s,n,Macro(hangupcall,)
exten => s,n,Congestion(20)
exten => s,n(continue),Set(CALLERID(number)=${CALLERID(number):0:40})
exten => s,n,Set(CALLERID(name)=${CALLERID(name):0:40})
exten => s,n,Set(CDR(cnum)=${CALLERID(num)})
exten => s,n,Set(CDR(cnam)=${CALLERID(name)})
exten => s,n,Set(CHANNEL(language)=${MASTER_CHANNEL(CHANNEL(language))})

exten => h,1,Macro(hangupcall,)

;--== end of [macro-user-callerid] ==--;


[macro-outbound-callerid]
include => macro-outbound-callerid-custom
exten => s,1,ExecIf($["${CALLINGPRES_SV}" != ""]?Set(CALLERPRES()=${CALLINGPRES_SV}))
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n(start),GotoIf($[ $["${REALCALLERIDNUM}" = ""] | $["${KEEPCID}" != "TRUE"] | $["${OUTKEEPCID_${ARG1}}" = "on"] ]?normcid)
exten => s,n,Set(USEROUTCID=${REALCALLERIDNUM})
exten => s,n,GotoIf($["foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}" = "foo"]?bypass)
exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${AMPUSER}/outboundcid)})
exten => s,n(bypass),Set(EMERGENCYCID=${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)})
exten => s,n,Set(TRUNKOUTCID=${OUTCID_${ARG1}})
exten => s,n,GotoIf($["${EMERGENCYROUTE:1:2}" = "" | "${EMERGENCYCID:1:2}" = ""]?trunkcid)
exten => s,n,Set(CALLERID(all)=${EMERGENCYCID})
exten => s,n,Set(CDR(outbound_cnum)=${CALLERID(num)})
exten => s,n,Set(CDR(outbound_cnam)=${CALLERID(name)})
exten => s,n(exit),MacroExit()
exten => s,n(trunkcid),ExecIf($[${LEN(${TRUNKOUTCID})} != 0]?Set(CALLERID(all)=${TRUNKOUTCID}))
exten => s,n(usercid),ExecIf($[${LEN(${USEROUTCID})} != 0]?Set(CALLERID(all)=${USEROUTCID}))
exten => s,n,ExecIf($[${LEN(${TRUNKCIDOVERRIDE})} != 0 | ${LEN(${FORCEDOUTCID_${ARG1}})} != 0]?Set(CALLERID(all)=${IF($[${LEN(${FORCEDOUTCID_${ARG1}})}=0]?${TRUNKCIDOVERRIDE}:${FORCEDOUTCID_${ARG1}})}))
exten => s,n(hidecid),ExecIf($["${CALLERID(name)}"="hidden"]?Set(CALLERPRES()=prohib_passed_screen))
exten => s,n,Set(CDR(outbound_cnum)=${CALLERID(num)})
exten => s,n,Set(CDR(outbound_cnam)=${CALLERID(name)})

;--== end of [macro-outbound-callerid] ==--;


[from-zaptel]
include => from-zaptel-custom
include => from-dahdi
exten => foo,1,Noop(bar)

;--== end of [from-zaptel] ==--;


[from-dahdi]
include => from-dahdi-custom
exten => _X.,1,Set(DID=${EXTEN})
exten => _X.,n,Goto(s,1)

exten => s,1,Noop(Entering from-dahdi with DID == ${DID})
exten => s,n,Ringing()
exten => s,n,Set(DID=${IF($["${DID}"= ""]?s:${DID})})
exten => s,n,Noop(DID is now ${DID})
exten => s,n,GotoIf($["${CHANNEL:0:5}"="DAHDI"]?dahdiok:checkzap)
exten => s,n(checkzap),GotoIf($["${CHANNEL:0:3}"="Zap"]?zapok:neither)
exten => s,n(neither),Goto(from-pstn,${DID},1)
exten => s,n,Macro(Hangupcall,dummy)
exten => s,n(dahdiok),Noop(Is a DAHDi Channel)
exten => s,n,Set(CHAN=${CHANNEL:6})
exten => s,n,Set(CHAN=${CUT(CHAN,-,1)})
exten => s,n,Macro(from-dahdi-${CHAN},${DID},1)
exten => s,n,Noop(Returned from Macro from-dahdi-${CHAN})
exten => s,n,Goto(from-pstn,${DID},1)
exten => s,n(zapok),Noop(Is a Zaptel Channel)
exten => s,n,Set(CHAN=${CHANNEL:4})
exten => s,n,Set(CHAN=${CUT(CHAN,-,1)})
exten => s,n,Macro(from-dahdi-${CHAN},${DID},1)
exten => s,n,Noop(Returned from Macro from-dahdi-${CHAN})
exten => s,n,Goto(from-pstn,${DID},1)

;--== end of [from-dahdi] ==--;


[vm-callme]
include => vm-callme-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n(repeat),Background(${MSG}&silence/2&vm-repeat&vm-starmain)
exten => s,n,WaitExten(15,)

exten => 5,1,Goto(s,repeat)

exten => #,1,Playback(vm-goodbye)
exten => #,n,Hangup

exten => *,1,Macro(get-vmcontext,${MBOX})
exten => *,n,VoiceMailMain(${MBOX}@${VMCONTEXT},s)

exten => i,1,Playback(pm-invalid-option)
exten => i,n,Goto(s,repeat)

exten => t,1,Playback(vm-goodbye)
exten => t,n,Hangup

exten => h,1,Hangup

;--== end of [vm-callme] ==--;


[macro-dial-confirm]
include => macro-dial-confirm-custom
exten => s,1,Set(DB(RG/${ARG4}/${CHANNEL})=RINGING)
exten => s,n,Set(__UNIQCHAN=${CHANNEL})
exten => s,n,Set(USE_CONFIRMATION=TRUE)
exten => s,n,Set(RINGGROUP_INDEX=${ARG4})
exten => s,n,Set(FORCE_CONFIRM=)
exten => s,n,Set(ARG4=)
exten => s,n,Macro(dial,${ARG1},${ARG2},${ARG3})
exten => s,n,Noop(Deleting: RG/${RINGGROUP_INDEX}/${CHANNEL} ${DB_DELETE(RG/${RINGGROUP_INDEX}/${CHANNEL})})
exten => s,n,Set(USE_CONFIRMATION=)
exten => s,n,Set(RINGGROUP_INDEX=)

;--== end of [macro-dial-confirm] ==--;


[macro-setmusic]
include => macro-setmusic-custom
exten => s,1,Set(CHANNEL(musicclass)=${ARG1})

;--== end of [macro-setmusic] ==--;


[macro-block-cf]
include => macro-block-cf-custom
exten => _X.,1,Hangup

exten => s-ANSWER,1,Noop(Call successfully answered - Hanging up now)
exten => s-ANSWER,n,Macro(hangupcall,)

;--== end of [macro-block-cf] ==--;


[macro-vm]
include => macro-vm-custom
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,n,Set(VMGAIN=${IF($["foo${VM_GAIN}"!="foo"]?"g(${VM_GAIN})": )})
exten => s,n,Macro(blkvm-check,)
exten => s,n,GotoIf($["${GOSUB_RETVAL}" != "TRUE"]?vmx,1)
exten => s,n,Hangup

exten => vmx,1,Set(MEXTEN=${ARG1})
exten => vmx,n,Set(MMODE=${ARG2})
exten => vmx,n,Set(RETVM=${ARG3})
exten => vmx,n,Set(MODE=${IF($["${MMODE}"="BUSY"]?busy:unavail)})
exten => vmx,n,GotoIf($["${DB(AMPUSER/${MEXTEN}/vmx/${MODE}/state)}" != "enabled"]?chknomsg)
exten => vmx,n,Set(VM_OPTS=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/vmxopts/timeout)}" = "1"]?${DB_RESULT}:${VM_OPTS})})
exten => vmx,n(chknomsg),GotoIf($["${MMODE}"="NOMESSAGE"]?s-${MMODE},1)
exten => vmx,n,GotoIf($["${MMODE}" != "DIRECTDIAL"]?notdirect)
exten => vmx,n,Set(MODE=${IF($["${REGEX("[b]" ${VM_DDTYPE})}" = "1"]?busy:${MODE})})
exten => vmx,n(notdirect),Noop(Checking if ext ${MEXTEN} is enabled: ${DB(AMPUSER/${MEXTEN}/vmx/${MODE}/state)})
exten => vmx,n,GotoIf($["${DB(AMPUSER/${MEXTEN}/vmx/${MODE}/state)}" != "enabled"]?s-${MMODE},1)
exten => vmx,n,Macro(get-vmcontext,${MEXTEN})
exten => vmx,n,GotoIf($[(${STAT(f,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${MEXTEN}/temp.wav)} = 1) || (${STAT(f,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${MEXTEN}/temp.WAV)} = 1)]?tmpgreet)
exten => vmx,n,GotoIf($[(${STAT(f,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${MEXTEN}/${MODE}.wav)} = 0) && (${STAT(f,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${MEXTEN}/${MODE}.WAV)} = 0)]?nofile)
exten => vmx,n,Set(LOOPCOUNT=0)
exten => vmx,n,Set(VMX_REPEAT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/repeat)}" = "1"]?${DB_RESULT}:${VMX_REPEAT})})
exten => vmx,n(vmxtime),Set(VMX_TIMEOUT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/timeout)}" = "1"]?${DB_RESULT}:${VMX_TIMEOUT})})
exten => vmx,n(vmxloops),Set(VMX_LOOPS=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/loops)}" = "1"]?${DB_RESULT}:${VMX_LOOPS})})
exten => vmx,n(vmxanswer),Answer
exten => vmx,n(loopstart),Read(ACTION,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${MEXTEN}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT})
exten => vmx,n,GotoIf($["${EXISTS(${ACTION})}" = "1"]?checkopt)
exten => vmx,n(noopt),Noop(Timeout: going to timeout dest)
exten => vmx,n,Set(VMX_OPTS=${DB(AMPUSER/${MEXTEN}/vmx/${MODE}/vmxopts/timeout)})
exten => vmx,n(chktime),GotoIf($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/timedest/ext)}" = "0"]?dotime)
exten => vmx,n,Set(VMX_TIMEDEST_EXT=${DB_RESULT})
exten => vmx,n,Set(VMX_TIMEDEST_CONTEXT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/timedest/context)}" = "1"]?${DB_RESULT}:${VMX_TIMEDEST_CONTEXT})})
exten => vmx,n(timepri),Set(VMX_TIMEDEST_PRI=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/timedest/pri)}" = "1"]?${DB_RESULT}:${VMX_TIMEDEST_PRI})})
exten => vmx,n(dotime),Goto(${VMX_TIMEDEST_CONTEXT},${VMX_TIMEDEST_EXT},${VMX_TIMEDEST_PRI})
exten => vmx,n(checkopt),GotoIf($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/${ACTION}/ext)}" = "1"]?doopt)
exten => vmx,n,GotoIf($["${ACTION}" = "0"]?o,1)
exten => vmx,n,GotoIf($["${ACTION}" = "*"]?adef,1)
exten => vmx,n,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten => vmx,n,GotoIf($[${LOOPCOUNT} > ${VMX_LOOPS}]?toomany)
exten => vmx,n,Playback(pm-invalid-option&please-try-again)
exten => vmx,n,Goto(loopstart)
exten => vmx,n(toomany),Noop(Too Many invalid entries, got to invalid dest)
exten => vmx,n,Set(VMX_OPTS=${VMX_OPTS_LOOP})
exten => vmx,n,Set(VMX_OPTS=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/vmxopts/loops)}" = "1"]?${DB_RESULT}:${VMX_OPTS})})
exten => vmx,n(chkloop),GotoIf($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/loopdest/ext)}" = "0"]?doloop)
exten => vmx,n,Set(VMX_LOOPDEST_EXT=${DB_RESULT})
exten => vmx,n,Set(VMX_LOOPDEST_CONTEXT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/loopdest/context)}" = "1"]?${DB_RESULT}:${VMX_LOOPDEST_CONTEXT})})
exten => vmx,n(looppri),Set(VMX_LOOPDEST_PRI=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/loopdest/pri)}" = "1"]?${DB_RESULT}:${VMX_LOOPDEST_PRI})})
exten => vmx,n(doloop),Goto(${VMX_LOOPDEST_CONTEXT},${VMX_LOOPDEST_EXT},${VMX_LOOPDEST_PRI})
exten => vmx,n(doopt),Noop(Got a valid option: ${DB_RESULT})
exten => vmx,n,Set(VMX_EXT=${DB_RESULT})
exten => vmx,n,GotoIf($["${VMX_EXT}" != "dovm"]?getdest)
exten => vmx,n(vmxopts),Set(VMX_OPTS=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/vmxopts/dovm)}" = "1"]?${DB_RESULT}:${VMX_OPTS_DOVM})})
exten => vmx,n(vmxdovm),Goto(dovm,1)
exten => vmx,n(getdest),Set(VMX_CONTEXT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/${ACTION}/context)}" = "1"]?${DB_RESULT}:${VMX_CONTEXT})})
exten => vmx,n(vmxpri),Set(VMX_PRI=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/${ACTION}/pri)}" = "1"]?${DB_RESULT}:${VMX_PRI})})
exten => vmx,n(vmxgoto),Goto(${VMX_CONTEXT},${VMX_EXT},${VMX_PRI})
exten => vmx,n(nofile),Noop(File for mode: ${MODE} does not exist, SYSTEMSTATUS: ${SYSTEMSTATUS}, going to normal voicemail)
exten => vmx,n,Goto(s-${MMODE},1)
exten => vmx,n(tmpgreet),Noop(Temporary Greeting Detected, going to normal voicemail)
exten => vmx,n,Goto(s-${MMODE},1)

exten => dovm,1,Noop(VMX Timeout - go to voicemail)
exten => dovm,n,VoiceMail(${MEXTEN}@${VMCONTEXT},${VMX_OPTS}${VMGAIN})
exten => dovm,n,Goto(exit-${VMSTATUS},1)

exten => s-BUSY,1,Noop(BUSY voicemail)
exten => s-BUSY,n,Macro(get-vmcontext,${MEXTEN})
exten => s-BUSY,n,VoiceMail(${MEXTEN}@${VMCONTEXT},${VM_OPTS}b${VMGAIN})
exten => s-BUSY,n,Goto(exit-${VMSTATUS},1)

exten => s-NOMESSAGE,1,Noop(NOMESSAGE (beeb only) voicemail)
exten => s-NOMESSAGE,n,Macro(get-vmcontext,${MEXTEN})
exten => s-NOMESSAGE,n,VoiceMail(${MEXTEN}@${VMCONTEXT},s${VM_OPTS}${VMGAIN})
exten => s-NOMESSAGE,n,Goto(exit-${VMSTATUS},1)

exten => s-DIRECTDIAL,1,Noop(DIRECTDIAL voicemail)
exten => s-DIRECTDIAL,n,Macro(get-vmcontext,${MEXTEN})
exten => s-DIRECTDIAL,n,VoiceMail(${MEXTEN}@${VMCONTEXT},${VM_OPTS}${VM_DDTYPE}${VMGAIN})
exten => s-DIRECTDIAL,n,Goto(exit-${VMSTATUS},1)

exten => _s-.,1,Macro(get-vmcontext,${MEXTEN})
exten => _s-.,n,VoiceMail(${MEXTEN}@${VMCONTEXT},${VM_OPTS}u${VMGAIN})
exten => _s-.,n,Goto(exit-${VMSTATUS},1)

exten => o,1,Playback(one-moment-please)
exten => o,n,GotoIf($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/0/ext)}" = "0"]?doopdef)
exten => o,n,Set(VMX_OPDEST_EXT=${DB_RESULT})
exten => o,n(opcontext),Set(VMX_OPDEST_CONTEXT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/0/context)}" = "1"]?${DB_RESULT}:${VMX_CONTEXT})})
exten => o,n(oppri),Set(VMX_OPDEST_PRI=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/0/pri)}" = "1"]?${DB_RESULT}:${VMX_PRI})})
exten => o,n,Goto(${VMX_OPDEST_CONTEXT},${VMX_OPDEST_EXT},${VMX_OPDEST_PRI})
exten => o,n(doopdef),GotoIf($["x${OPERATOR_XTN}"="x"]?nooper:from-internal,${OPERATOR_XTN},1)
exten => o,n(nooper),GotoIf($["x${FROM_DID}"="x"]?nodid)
exten => o,n,Dial(Local/${FROM_DID}@from-pstn,)
exten => o,n,Macro(hangup,)
exten => o,n(nodid),Dial(Local/s@from-pstn,)
exten => o,n,Macro(hangup,)

exten => a,1,Macro(get-vmcontext,${MEXTEN})
exten => a,n,GotoIf($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/*/ext)}" = "0"]?adef,1)
exten => a,n,Set(VMX_ADEST_EXT=${DB_RESULT})
exten => a,n(acontext),Set(VMX_ADEST_CONTEXT=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/*/context)}" = "1"]?${DB_RESULT}:${VMX_CONTEXT})})
exten => a,n(apri),Set(VMX_ADEST_PRI=${IF($["${DB_EXISTS(AMPUSER/${MEXTEN}/vmx/${MODE}/*/pri)}" = "1"]?${DB_RESULT}:${VMX_PRI})})
exten => a,n,Goto(${VMX_ADEST_CONTEXT},${VMX_ADEST_EXT},${VMX_ADEST_PRI})

exten => adef,1,VoiceMailMain(${MEXTEN}@${VMCONTEXT})
exten => adef,n,GotoIf($["${RETVM}" = "RETURN"]?exit-RETURN,1)
exten => adef,n,Hangup

exten => exit-FAILED,1,Playback(im-sorry&an-error-has-occured)
exten => exit-FAILED,n,GotoIf($["${RETVM}" = "RETURN"]?exit-RETURN,1)
exten => exit-FAILED,n,Hangup

exten => exit-SUCCESS,1,GotoIf($["${RETVM}" = "RETURN"]?exit-RETURN,1)
exten => exit-SUCCESS,n,Playback(goodbye)
exten => exit-SUCCESS,n,Hangup

exten => exit-USEREXIT,1,GotoIf($["${RETVM}" = "RETURN"]?exit-RETURN,1)
exten => exit-USEREXIT,n,Playback(goodbye)
exten => exit-USEREXIT,n,Hangup

exten => exit-RETURN,1,Noop(Returning From Voicemail because macro)

exten => t,1,Hangup

;--== end of [macro-vm] ==--;


[macro-exten-vm]
include => macro-exten-vm-custom
exten => s,1,Macro(user-callerid,)
exten => s,n,Set(RingGroupMethod=none)
exten => s,n,Set(__EXTTOCALL=${ARG2})
exten => s,n,Set(__PICKUPMARK=${ARG2})
exten => s,n,Set(RT=${IF($["${ARG1}"!="novm" | "${DB(CFU/${EXTTOCALL})}"!="" | "${DB(CFB/${EXTTOCALL})}"!="" | "${ARG3}"="1" | "${ARG4}"="1" | "${ARG5}"="1"]?${RINGTIMER}:)})
exten => s,n(checkrecord),Gosub(sub-record-check,s,1(exten,${EXTTOCALL},))
exten => s,n(macrodial),Macro(dial-one,${RT},${DIAL_OPTIONS},${EXTTOCALL})
exten => s,n,Set(SV_DIALSTATUS=${DIALSTATUS})
exten => s,n(calldocfu),GosubIf($[("${SV_DIALSTATUS}"="NOANSWER"|"${SV_DIALSTATUS}"="CHANUNAVAIL") & "${DB(CFU/${EXTTOCALL})}"!="" & "${SCREEN}"=""]?docfu,1())
exten => s,n(calldocfb),GosubIf($["${SV_DIALSTATUS}"="BUSY" & "${DB(CFB/${EXTTOCALL})}"!="" & "${SCREEN}"=""]?docfb,1())
exten => s,n,Set(DIALSTATUS=${SV_DIALSTATUS})
exten => s,n,ExecIf($[("${DIALSTATUS}"="NOANSWER"&"${ARG3}"="1")|("${DIALSTATUS}"="BUSY"&"${ARG4}"="1")|("${DIALSTATUS}"="CHANUNAVAIL"&"${ARG5}"="1")]?MacroExit())
exten => s,n,GotoIf($["${ARG1}"="novm"]?s-${DIALSTATUS},1)
exten => s,n,Macro(vm,${ARG1},${DIALSTATUS},${IVR_RETVM})

exten => docfu,1(docfu),ExecIf($["${DB(AMPUSER/${EXTTOCALL}/cfringtimer)}"="-1"|("${ARG1}"="novm"&"${ARG3}"="1")]?StackPop())
exten => docfu,n,GotoIf($["${DB(AMPUSER/${EXTTOCALL}/cfringtimer)}"="-1"|("${ARG1}"="novm"&"${ARG3}"="1")]?from-internal,${DB(CFU/${EXTTOCALL})},1)
exten => docfu,n,Set(RTCF=${IF($["${DB(AMPUSER/${EXTTOCALL}/cfringtimer)}"="0"]?${RT}:${DB(AMPUSER/${EXTTOCALL}/cfringtimer)})})
exten => docfu,n,Dial(Local/${DB(CFU/${EXTTOCALL})}@from-internal/n,${RTCF},${DIAL_OPTIONS})
exten => docfu,n,Return()

exten => docfb,1(docfu),ExecIf($["${DB(AMPUSER/${EXTTOCALL}/cfringtimer)}"="-1"|("${ARG1}"="novm"&"${ARG4}"="1")]?StackPop())
exten => docfb,n,GotoIf($["${DB(AMPUSER/${EXTTOCALL}/cfringtimer)}"="-1"|("${ARG1}"="novm"&"${ARG4}"="1")]?from-internal,${DB(CFB/${EXTTOCALL})},1)
exten => docfb,n,Set(RTCF=${IF($["${DB(AMPUSER/${EXTTOCALL}/cfringtimer)}"="0"]?${RT}:${DB(AMPUSER/${EXTTOCALL}/cfringtimer)})})
exten => docfb,n,Dial(Local/${DB(CFB/${EXTTOCALL})}@from-internal/n,${RTCF},${DIAL_OPTIONS})
exten => docfb,n,Return()

exten => s-BUSY,1,GotoIf($["${IVR_RETVM}"="RETURN" & "${IVR_CONTEXT}"!=""]?exit,1)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)

exten => _s-!,1,GotoIf($["${IVR_RETVM}"="RETURN" & "${IVR_CONTEXT}"!=""]?exit,1)
exten => _s-!,n,Playtones(congestion)
exten => _s-!,n,Congestion(10)

exten => exit,1,Playback(beep&line-busy-transfer-menu&silence/1)
exten => exit,n,MacroExit()

;--== end of [macro-exten-vm] ==--;


[macro-simple-dial]
include => macro-simple-dial-custom
exten => s,1,Set(__EXTTOCALL=${ARG1})
exten => s,n,Set(RT=${ARG2})
exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})})
exten => s,n,Set(CFBEXT=${DB(CFB/${EXTTOCALL})})
exten => s,n,Set(CWI_TMP=${CWIGNORE})
exten => s,n(macrodial),Macro(dial-one,${RT},${DIAL_OPTIONS},${EXTTOCALL})
exten => s,n,Set(__CWIGNORE=${CWI_TMP})
exten => s,n,Set(PR_DIALSTATUS=${DIALSTATUS})
exten => s,n(calldocfu),GosubIf($["${PR_DIALSTATUS}"="NOANSWER" & "${CFUEXT}"!=""]?docfu,1())
exten => s,n(calldocfb),GosubIf($["${PR_DIALSTATUS}"="BUSY" & "${CFBEXT}"!=""]?docfb,1())
exten => s,n,Set(DIALSTATUS=${PR_DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1)

exten => docfu,1,GotoIf($["${DB(AMPUSER/${CFUEXT}/device)}" = "" ]?chlocal)
exten => docfu,n,Dial(Local/${CFUEXT}@ext-local,${RT},${DIAL_OPTIONS})
exten => docfu,n,Return()
exten => docfu,n(chlocal),Dial(Local/${CFUEXT}@from-internal/n,${RT},${DIAL_OPTIONS})
exten => docfu,n,Return()

exten => docfb,1,GotoIf($["${DB(AMPUSER/${CFBEXT}/device)}" = "" ]?chlocal)
exten => docfb,n,Dial(Local/${CFBEXT}@ext-local,${RT},${DIAL_OPTIONS})
exten => docfb,n,Return()
exten => docfb,n(chlocal),Dial(Local/${CFBEXT}@from-internal/n,${RT},${DIAL_OPTIONS})
exten => docfb,n,Return()

exten => _s-.,1,Noop(Extension is reporting ${EXTEN})

;--== end of [macro-simple-dial] ==--;


[macro-blkvm-setifempty]
include => macro-blkvm-setifempty-custom
exten => s,1,GotoIf($[!${EXISTS(${BLKVM_CHANNEL})}]?init)
exten => s,n,Set(GOSUB_RETVAL=${SHARED(BLKVM,${BLKVM_CHANNEL})})
exten => s,n,MacroExit()
exten => s,n(init),Set(__BLKVM_CHANNEL=${CHANNEL})
exten => s,n,Set(SHARED(BLKVM,${BLKVM_CHANNEL})=TRUE)
exten => s,n,Set(GOSUB_RETVAL=TRUE)
exten => s,n,MacroExit()

;--== end of [macro-blkvm-setifempty] ==--;


[macro-blkvm-set]
include => macro-blkvm-set-custom
exten => s,1,ExecIf($[!${EXISTS(${BLKVM_CHANNEL})} | "{ARG1}" = "reset"]?Set(__BLKVM_CHANNEL=${CHANNEL}))
exten => s,n,Set(SHARED(BLKVM,${BLKVM_CHANNEL})=TRUE)
exten => s,n,Set(GOSUB_RETVAL=TRUE)
exten => s,n,MacroExit()

;--== end of [macro-blkvm-set] ==--;


[macro-blkvm-clr]
include => macro-blkvm-clr-custom
exten => s,1,Set(SHARED(BLKVM,${BLKVM_CHANNEL})=)
exten => s,n,Set(GOSUB_RETVAL=)
exten => s,n,MacroExit()

;--== end of [macro-blkvm-clr] ==--;


[macro-blkvm-check]
include => macro-blkvm-check-custom
exten => s,1,Set(GOSUB_RETVAL=${SHARED(BLKVM,${BLKVM_CHANNEL})})
exten => s,n,ExecIf($["${GOSUB_RETVAL}"="" & "${CC_RECALL}"="1"]?Set(GOSUB_RETVAL=TRUE))
exten => s,n,MacroExit()

;--== end of [macro-blkvm-check] ==--;


[macro-hangupcall]
include => macro-hangupcall-custom
exten => s,1(start),GotoIf($["${USE_CONFIRMATION}"="" | "${RINGGROUP_INDEX}"="" | "${CHANNEL}"!="${UNIQCHAN}"]?theend)
exten => s,n(delrgi),Noop(Deleting: RG/${RINGGROUP_INDEX}/${CHANNEL} ${DB_DELETE(RG/${RINGGROUP_INDEX}/${CHANNEL})})
exten => s,n(theend),ExecIf($["${ONETOUCH_RECFILE}"!="" & "${CDR(recordingfile)}"=""]?Set(CDR(recordingfile)=${ONETOUCH_RECFILE}))
exten => s,n,Hangup
exten => s,n,MacroExit()

;--== end of [macro-hangupcall] ==--;


[macro-dial-one]
include => macro-dial-one-custom
exten => s,1,Set(DEXTEN=${ARG3})
exten => s,n,Set(DIALSTATUS_CW=)
exten => s,n,GosubIf($["${FROM_DID}"!="" & "${SCREEN}"="" & "${DB(AMPUSER/${DEXTEN}/screen)}"!=""]?screen,1())
exten => s,n,GosubIf($["${DB(CF/${DEXTEN})}"!=""]?cf,1())
exten => s,n,GotoIf($["${DEXTEN:-1}"="#" | "${DB(DND/${DEXTEN})}"=""]?skip1)
exten => s,n,Set(DEXTEN=)
exten => s,n,Set(DIALSTATUS=BUSY)
exten => s,n(skip1),GotoIf($["${DEXTEN}"=""]?nodial)
exten => s,n,GotoIf($["${DEXTEN:-1}"="#"]?continue)
exten => s,n,Set(EXTHASCW=${IF($["${CWIGNORE}"!=""]? :${DB(CW/${DEXTEN})})})
exten => s,n,GotoIf($["${EXTHASCW}"="" | "${DB(CFB/${DEXTEN})}"!="" | "${DB(CFU/${DEXTEN})}"!=""]?next1:cwinusebusy)
exten => s,n(next1),GotoIf($["${DB(CFU/${DEXTEN})}"!="" & ("${EXTENSION_STATE(${DEXTEN})}"="UNAVAILABLE" | "${EXTENSION_STATE(${DEXTEN})}"="UNKNOWN")]?docfu:skip3)
exten => s,n(docfu),Set(DEXTEN=)
exten => s,n,Set(DIALSTATUS=NOANSWER)
exten => s,n,Goto(nodial)
exten => s,n(skip3),GotoIf($["${EXTHASCW}"="" | "${DB(CFB/${DEXTEN})}"!=""]?next2:continue)
exten => s,n(next2),GotoIf($["${EXTENSION_STATE(${DEXTEN})}"="NOT_INUSE" | "${EXTENSION_STATE(${DEXTEN})}"="UNAVAILABLE" | "${EXTENSION_STATE(${DEXTEN})}"="UNKNOWN"]?continue)
exten => s,n,ExecIf($["${DB(CFB/${DEXTEN})}"!="" & "${CFIGNORE}"=""]?Set(DIALSTATUS=BUSY))
exten => s,n,GotoIf($["${EXTHASCW}"!="" | "${DEXTEN:-1}"="#"]?cwinusebusy)
exten => s,n,Set(DEXTEN=)
exten => s,n,Set(DIALSTATUS=BUSY)
exten => s,n,Goto(nodial)
exten => s,n(cwinusebusy),GotoIf($["${EXTHASCW}"!="" & "${CWINUSEBUSY}"="true"]?next3:continue)
exten => s,n(next3),ExecIf($["${EXTENSION_STATE(${DEXTEN})}"!="UNAVAILABLE" & "${EXTENSION_STATE(${DEXTEN})}"!="NOT_INUSE" & "${EXTENSION_STATE(${DEXTEN})}"!="UNKNOWN"]?Set(DIALSTATUS_CW=BUSY))
exten => s,n(continue),GotoIf($["${DEXTEN}"=""]?nodial)
exten => s,n,GosubIf($["${DEXTEN:-1}"!="#"]?dstring,1():dlocal,1())
exten => s,n,GotoIf($[${LEN(${DSTRING})}=0]?nodial)
exten => s,n,GotoIf($["${DEXTEN:-1}"="#"]?skiptrace)
exten => s,n,GosubIf($[${REGEX("^[\+]?[0-9]+$" ${CALLERID(number)})} = 1]?ctset,1():ctclear,1())
exten => s,n(skiptrace),Set(D_OPTIONS=${IF($["${NODEST}"!="" & ${REGEX("(M[(]auto-blkvm[)])" ${ARG2})} != 1]?${ARG2}M(auto-blkvm):${ARG2})})
exten => s,n,ExecIf($["${ALERT_INFO}"!=""]?SIPAddHeader(Alert-Info: ${ALERT_INFO}))
exten => s,n,ExecIf($["${SIPADDHEADER}"!=""]?SIPAddHeader(${SIPADDHEADER}))
exten => s,n,ExecIf($["${MOHCLASS}"!=""]?Set(CHANNEL(musicclass)=${MOHCLASS}))
exten => s,n,GosubIf($["${QUEUEWAIT}"!=""]?qwait,1())
exten => s,n,Set(__CWIGNORE=${CWIGNORE})
exten => s,n,Set(__KEEPCID=TRUE)
exten => s,n,GotoIf($["${USEGOTO}"="1"]?usegoto,1)
exten => s,n,GotoIf($["${DB(AMPUSER/${EXTTOCALL}/cidname)}" = "" || "${DB(AMPUSER/${AMPUSER}/cidname)}" = ""]?godial)
exten => s,n,Set(CONNECTEDLINE(name,i)=${DB(AMPUSER/${EXTTOCALL}/cidname)})
exten => s,n,Set(CONNECTEDLINE(num)=${EXTTOCALL})
exten => s,n,Set(D_OPTIONS=${D_OPTIONS}I)
exten => s,n(godial),Dial(${DSTRING},${ARG1},${D_OPTIONS})
exten => s,n,ExecIf($["${DIALSTATUS}"="ANSWER" & "${CALLER_DEST}"!=""]?MacroExit())
exten => s,n,ExecIf($["${DIALSTATUS_CW}"!=""]?Set(DIALSTATUS=${DIALSTATUS_CW}))
exten => s,n,GosubIf($[("${SCREEN}"!=""&("${DIALSTATUS}"="TORTURE"|"${DIALSTATUS}"="DONTCALL"))|"${DIALSTATUS}"="ANSWER"]?s-${DIALSTATUS},1())
exten => s,n,MacroExit()
exten => s,n(nodial),ExecIf($["${DIALSTATUS}" = ""]?Set(DIALSTATUS=NOANSWER))
exten => s,n,Noop(Returned from dial-one with nothing to call and DIALSTATUS: ${DIALSTATUS})
exten => s,n,MacroExit()

exten => h,1,Macro(hangupcall,)

exten => usegoto,1,Set(USEGOTO=)
exten => usegoto,n,Goto(from-internal,${DSTRING},1)

exten => screen,1,GotoIf($["${DB(AMPUSER/${DEXTEN}/screen)}"!="nomemory" | "${CALLERID(number)}"=""]?memory)
exten => screen,n,ExecIf($[${REGEX("^[0-9a-zA-Z ]+$" ${CALLERID(number)})} = 1]?System(rm -f ${ASTVARLIBDIR}/sounds/priv-callerintros/${CALLERID(number)}.*))
exten => screen,n(memory),Set(__SCREEN=${DB(AMPUSER/${DEXTEN}/screen)})
exten => screen,n,Set(__SCREEN_EXTEN=${DEXTEN})
exten => screen,n,Set(ARG2=${ARG2}p)
exten => screen,n,Return()

exten => cf,1,Set(CFAMPUSER=${IF($["${AMPUSER}"=""]?${CALLERID(number)}:${AMPUSER})})
exten => cf,n,ExecIf($["${DB(CF/${DEXTEN})}"="${CFAMPUSER}" | "${DB(CF/${DEXTEN})}"="${REALCALLERIDNUM}" | "${CUT(CUT(BLINDTRANSFER,-,1),/,1)}" = "${DB(CF/${DEXTEN})}" | "${DEXTEN}"="${DB(CF/${DEXTEN})}"]?Return())
exten => cf,n,ExecIf($["${DB(AMPUSER/${DEXTEN}/cfringtimer)}" != "0" & "${DB(AMPUSER/${DEXTEN}/cfringtimer)}" != ""]?Set(ARG1=${IF($["${DB(AMPUSER/${DEXTEN}/cfringtimer)}"="-1"]? : ${DB(AMPUSER/${DEXTEN}/cfringtimer)})}))
exten => cf,n,Set(DEXTEN=${IF($["${CFIGNORE}"=""]?"${DB(CF/${DEXTEN})}#": )})
exten => cf,n,ExecIf($["${DEXTEN}"!=""]?Return())
exten => cf,n,Set(DIALSTATUS=NOANSWER)
exten => cf,n,Return()

exten => qwait,1,ExecIf($["${SAVEDCIDNAME}" = ""]?Set(__SAVEDCIDNAME=${CALLERID(name)}))
exten => qwait,n,Set(ELAPSED=${MATH($[${EPOCH}+30-${QUEUEWAIT}]/60,int)})
exten => qwait,n,Set(CALLERID(name)=M${ELAPSED}:${SAVEDCIDNAME})
exten => qwait,n,Return()

exten => ctset,1,Set(DB(CALLTRACE/${DEXTEN})=${CALLERID(number)})
exten => ctset,n,Return()

exten => ctclear,1,Noop(Deleting: CALLTRACE/${DEXTEN} ${DB_DELETE(CALLTRACE/${DEXTEN})})
exten => ctclear,n,Return()

exten => dstring,1,Set(DSTRING=)
exten => dstring,n,Set(DEVICES=${DB(AMPUSER/${DEXTEN}/device)})
exten => dstring,n,ExecIf($["${DEVICES}"=""]?Return())
exten => dstring,n,ExecIf($["${DEVICES:0:1}"="&"]?Set(DEVICES=${DEVICES:1}))
exten => dstring,n,Set(LOOPCNT=${FIELDQTY(DEVICES,&)})
exten => dstring,n,Set(ITER=1)
exten => dstring,n(begin),Set(THISDIAL=${DB(DEVICE/${CUT(DEVICES,&,${ITER})}/dial)})
exten => dstring,n,GosubIf($["${ASTCHANDAHDI}" = "1"]?zap2dahdi,1())
exten => dstring,n,Set(DSTRING=${DSTRING}${THISDIAL}&)
exten => dstring,n,Set(ITER=$[${ITER}+1])
exten => dstring,n,GotoIf($[${ITER}<=${LOOPCNT}]?begin)
exten => dstring,n,Set(DSTRING=${DSTRING:0:$[${LEN(${DSTRING})}-1]})
exten => dstring,n,Return()

exten => dlocal,1,Set(DSTRING=${IF($["${ARG1}"=""]?${DEXTEN:0:${MATH(${LEN(${DEXTEN})}-1,int)}}:Local/${DEXTEN:0:${MATH(${LEN(${DEXTEN})}-1,int)}}@from-internal/n)})
exten => dlocal,n,Set(USEGOTO=${IF($["${ARG1}"=""]?1:0)})
exten => dlocal,n,Return()

exten => zap2dahdi,1,ExecIf($["${THISDIAL}" = ""]?Return())
exten => zap2dahdi,n,Set(NEWDIAL=)
exten => zap2dahdi,n,Set(LOOPCNT2=${FIELDQTY(THISDIAL,&)})
exten => zap2dahdi,n,Set(ITER2=1)
exten => zap2dahdi,n(begin2),Set(THISPART2=${CUT(THISDIAL,&,${ITER2})})
exten => zap2dahdi,n,ExecIf($["${THISPART2:0:3}" = "ZAP"]?Set(THISPART2=DAHDI${THISPART2:3}))
exten => zap2dahdi,n,Set(NEWDIAL=${NEWDIAL}${THISPART2}&)
exten => zap2dahdi,n,Set(ITER2=$[${ITER2} + 1])
exten => zap2dahdi,n,GotoIf($[${ITER2} <= ${LOOPCNT2}]?begin2)
exten => zap2dahdi,n,Set(THISDIAL=${NEWDIAL:0:$[${LEN(${NEWDIAL})}-1]})
exten => zap2dahdi,n,Return()

exten => s-TORTURE,1,Goto(app-blackhole,musiconhold,1)
exten => s-TORTURE,n,Macro(hangupcall,)

exten => s-DONTCALL,1,Answer
exten => s-DONTCALL,n,Wait(1)
exten => s-DONTCALL,n,Zapateller()
exten => s-DONTCALL,n,Playback(ss-noservice)
exten => s-DONTCALL,n,Macro(hangupcall,)

exten => s-CHANUNAVAIL,1,Macro(vm,${SCREEN_EXTEN},BUSY,${IVR_RETVM})
exten => s-CHANUNAVAIL,n,ExecIf($["${IVR_RETVM}"!="RETURN" | "${IVR_CONTEXT}"=""]?Hangup())
exten => s-CHANUNAVAIL,n,Return()

exten => s-NOANSWER,1,Macro(vm,${SCREEN_EXTEN},BUSY,${IVR_RETVM})
exten => s-NOANSWER,n,ExecIf($["${IVR_RETVM}"!="RETURN" | "${IVR_CONTEXT}"=""]?Hangup())
exten => s-NOANSWER,n,Return()

exten => s-BUSY,1,Macro(vm,${SCREEN_EXTEN},BUSY,${IVR_RETVM})
exten => s-BUSY,n,ExecIf($["${IVR_RETVM}"!="RETURN" | "${IVR_CONTEXT}"=""]?Hangup())
exten => s-BUSY,n,Return()

;--== end of [macro-dial-one] ==--;


[from-internal-additional]
include => from-internal-additional-custom
include => park-hints
include => ext-queues
include => app-queue-toggle
include => app-gabcast
include => app-callwaiting-cwoff
include => app-callwaiting-cwon
include => app-calltrace
include => app-echo-test
include => app-speakextennum
include => app-speakingclock
include => app-speeddial
include => app-cf-busy-off
include => app-cf-busy-off-any
include => app-cf-busy-on
include => app-cf-off
include => app-cf-off-any
include => app-cf-on
include => app-cf-unavailable-off
include => app-cf-unavailable-on
include => app-cf-toggle
include => ext-cf-hints
include => app-fmf-toggle
include => ext-findmefollow
include => fmgrps
include => app-dnd-off
include => app-dnd-on
include => app-dnd-toggle
include => ext-dnd-hints
include => vmblast-grp
include => app-pbdirectory
include => app-recordings
include => ext-meetme
include => app-fax
include => app-dialvm
include => app-vmmain
include => ext-group
include => grps
include => app-blacklist
include => app-dictate-record
include => app-dictate-send
include => app-userlogonoff
include => ext-local-confirm
include => findmefollow-ringallv2
include => app-pickup
include => app-zapbarge
include => app-chanspy
include => ext-test
include => ext-local
include => outbound-allroutes
exten => h,1,Hangup

;--== end of [from-internal-additional] ==--;


[from-internal-noxfer-additional]
include => from-internal-noxfer-additional-custom
exten => h,1,Hangup

;--== end of [from-internal-noxfer-additional] ==--;


