All pastes #595895 Raw Edit

Stuff

public text v1 · immutable
#595895 ·published 2007-06-29 18:21 UTC
rendered paste body
;--------------------------------------------------------------------------------------------
;				June 28, 2007
;
;                Dail plan for Asterisk and Asterisk Gui Take 2 ver 1
;
;			Asterisk 1.4.x SVN + Asterisk-Gui SVN
;
;		      Please email changes to r.neese@gmail.com
;
;		    Thanks for your Participation in this project. 
;--------------------------------------------------------------------------------------------
;Some functions have not been mapped in asterisk as of yet and I dont know what the plans for
;them are. So you can remap an of the unused functions for new fuctions. I just hope that 
;any code you add you relist this somewhere where others can find it and use it. This is my 
;work to make a fully functional dialplan for the asterisk-gui & the asterisk pbx. If you see 
;anything wrong please take the time and fix it, And repost it. I did my best to keep it
;orderly I tried to fallow the NANPA lay out but I added some things. I hope this helps in 
;the long run. 
;
;Enjoy
;
;I have split it into parts as you will see as you read. Just to try and keep it clean.
;
;all the agi's used in this dial plan are at the bottom of the page.
;
;This code was developed on FreeBSD and might need the path's reset for Linux installs. 
;
;-------------------------------------------------------------------
;               Begining Of extensions.conf File
;-------------------------------------------------------------------
;-------------------------------------------------------------------
;General Settings
;-------------------------------------------------------------------
[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified.  Remember that all comments
; made in the file will be lost when that happens. 
;
; XXX Not yet implemented XXX
;
static = yes
;
; if static=yes and writeprotect=no, you can save dialplan by
; CLI command 'save dialplan' too
;
writeprotect = no
;
; If autofallthrough is set, then if an extension runs out of
; things to do, it will terminate the call with BUSY, CONGESTION
; or HANGUP depending on Asterisk's best guess. This is the default.
;
; If autofallthrough is not set, then if an extension runs out of 
; things to do, Asterisk will wait for a new extension to be dialed 
; (this is the original behavior of Asterisk 1.0 and earlier).
;
autofallthrough=yes
;
; If clearglobalvars is set, global variables will be cleared 
; and reparsed on an extensions reload, or Asterisk reload.
;
; If clearglobalvars is not set, then global variables will persist
; through reloads, and even if deleted from the extensions.conf or
; one of its included files, will remain set to the previous value.
;
; NOTE: A complication sets in, if you put your global variables into
; the AEL file, instead of the extensions.conf file. With clearglobalvars
; set, a 'reload' will often leave the globals vars cleared, because it
; is not unusual to have extensions.conf (which will have no globals)
; load after the extensions.ael file (where the global vars are stored).
; So, with 'reload' in this particular situation, first the AEL file will
; clear and then set all the global vars, then, later, when the extensions.conf
; file is loaded, the global vars are all cleared, and then not set, because
; they are not stored in the extensions.conf file.
;
clearglobalvars = no
;
; If priorityjumping is set to 'yes', then applications that support
; 'jumping' to a different priority based on the result of their operations
; will do so (this is backwards compatible behavior with pre-1.2 releases
; of Asterisk). Individual applications can also be requested to do this
; by passing a 'j' option in their arguments.
;
;priorityjumping=yes
;
; User context is where entries from users.conf are registered.  The
; default value is 'default'
;
;userscontext=default
;
; You can include other config files, use the #include command
; (without the ';'). Note that this is different from the "include" command
; that includes contexts within other contexts. The #include command works
; in all asterisk configuration files.
;
;#include "filename.conf"
;
; The "Globals" category contains global variables that can be referenced
; in the dialplan with the GLOBAL dialplan function:
;
; ${GLOBAL(VARIABLE)}
;
; ${${GLOBAL(VARIABLE)}} or ${text${GLOBAL(VARIABLE)}} or any hybrid
; Unix/Linux environmental variables can be reached with the ENV dialplan
; function: ${ENV(VARIABLE)}
;
;---------------------------------------------------------------------------------------------
;Start DialPlan Basics
;---------------------------------------------------------------------------------------------
; Any category other than "General" and "Globals" represent 
; extension contexts, which are collections of extensions.  
;
; Extension names may be numbers, letters, or combinations
; thereof. If an extension name is prefixed by a '_'
; character, it is interpreted as a pattern rather than a
; literal.  In patterns, some characters have special meanings:
;
;   X - any digit from 0-9
;   Z - any digit from 1-9
;   N - any digit from 2-9
;   [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
;   . - wildcard, matches anything remaining (e.g. _9011. matches 
;	anything starting with 9011 excluding 9011 itself)
;   ! - wildcard, causes the matching process to complete as soon as
;       it can unambiguously determine that no other matches are possible
;
; For example the extension _NXXXXXX would match normal 7 digit dialings, 
; while _1NXXNXXXXXX would represent an area code plus phone number
; preceded by a one.
;
; Each step of an extension is ordered by priority, which must
; always start with 1 to be considered a valid extension.  The priority
; "next" or "n" means the previous priority plus one, regardless of whether
; the previous priority was associated with the current extension or not.
; The priority "same" or "s" means the same as the previously specified
; priority, again regardless of whether the previous entry was for the
; same extension.  Priorities may be immediately followed by a plus sign
; and another integer to add that amount (most useful with 's' or 'n').  
; Priorities may then also have an alias, or label, in 
; parenthesis after their name which can be used in goto situations
;
; Contexts contain several lines, one for each step of each
; extension, which can take one of two forms as listed below,
; with the first form being preferred.  One may include another
; context in the current one as well, optionally with a
; date and time.  Included contexts are included in the order
; they are listed.
;
;-----------------------------------------------------------------------------
; Magic Extensions to be used within a context
;-----------------------------------------------------------------------------
; s = start
; t = This gets jumped to on timeout waiting for keypress
; i = This gets jumped to on an invalid extension
; h = This gets jumped to when a call in a given context is hung up
; fax = This gets jumped to on fax tone detection
;-----------------------------------------------------------------------------
; Dial Options
;-----------------------------------------------------------------------------
; Dial jumps to priority n+101 on Congestion if n+101 exists
; 't' -- Allow the user to dial # then an extension to transfer
; 'T' -- to allow the calling user to transfer the call
; 'r' -- indicate ringing to the calling party, pass no audio until answer
; 'm' -- provide hold music to the calling party until answered
; 'd' -- data-quality (modem) call (minimum delay)
; 'c' -- clear-channel data call (PRI-PRI only)
; 'H' -- allow caller to hang up by hitting *
; 'C' -- reset call detail record for this call
; 'P[(x)]' -- privacy mode, using 'x' as database if provided
; 'g' -- goes on in context if the destination channel hangs up
;----------------------------------------------------------------------------
;
;
; Note the 'g2' in the TRUNK variable below. It specifies which group (defined
; in zapata.conf) to dial, i.e. group 2, and how to choose a channel to use in
; the specified group. The four possible options are:
;
; g: select the lowest-numbered non-busy Zap channel
;    (aka. ascending sequential hunt group).
; G: select the highest-numbered non-busy Zap channel
;    (aka. descending sequential hunt group).
; r: use a round-robin search, starting at the next highest channel than last
;    time (aka. ascending rotary hunt group).
; R: use a round-robin search, starting at the next lowest channel than last
;    time (aka. descending rotary hunt group).
;
;-----------------------------------------------------
;Start Globals
;-----------------------------------------------------
[globals]
;CONSOLE=Console/dsp                             ; Console interface for demo
;CONSOLE=Zap/1
;CONSOLE=Phone/phone0
;IAXINFO=guest                                   ; IAXtel username/password
;IAXINFO=myuser:mypass
;TRUNK=Zap/g2       
;
TRUNKMSD = 0  ; MSD digits to strip (usually 1 or 0)
;
fwddialup = SIP/fwddialup
sipphone = SIP/sipphone
;
;--------------------------
;asterisk talk show globals exten 501
;-------------------------
MY_PIN = 3232814080
MY_SHOW = 22622
;
;-----------------------------------------------------
;Start DialPlan
;-----------------------------------------------------
;------------------------------------------------------
; Start -  inbound call mapping
;------------------------------------------------------
[inbound]
;switch = Realtime/dialplan@pbx-db-name
;
;This Exten Goes to Automated attendant after putting
;caller ID into the Database
exten = s,1,Set(BD(Last/Caller=${CALLERIDNUM})
exten = s,n,Goto(us-holiday-timerules,s,1)
;exten = s,n,Goto(can-holiday-timerules,s,1)
;
;This exten Dial your ZAP lines 
;exten = s,1,Set(DB(Last/Caller=${CALLERIDNUM})
;exten = s,n,Dial(ZAP/###,30,r) ;replace ### with exten nmbr
;
;------------------------------------------------------
; Basic Time Checking for inbouund routing
;
;I mapped us and canadian holidays. Still needs EU holidays.
;I planb to create a holidays.conf in the future with all the
;diff holidays and their country
;------------------------------------------------------
;
[us-holiday-timerules]
;switch = Realtime/dialplan@pbx-db-name
exten = s,1,GotoIfTime(*|*|31-1|dec-jan?s|HOLIDAY1)
exten = s,n,GotoIfTime(*|*|28|may?s|HOLIDAY2)
exten = s,n,GotoIfTime(*|*|4|jul?s|HOLIDAY3)
exten = s,n,GotoIfTime(*|*|3|sept?s|HOLIDAY4)
exten = s,n,GotoIfTime(*|*|8|oct?s|HOLIDAY5)
exten = s,n,GotoIfTime(*|*|11|nov?s|HOLIDAY6)
exten = s,n,GotoIfTime(*|*|22|nov?s|HOLIDAY7)
exten = s,n,GotoIfTime(*|*|24-26|dec?s|HOLIDAY8)
exten = s,n,Goto(timebasedrules,1,1)
;
exten = s,n(HOLIDAY1),Playback(office-closed&newyears)
exten = s,n,Goto(s,HOURS))
exten = s,n(HOLIDAY2),Playback(office-closed&memorialday)
exten = s,n,Goto(s,HOURS))
exten = s,n(HOLIDAY3),Playback(office-closed&independanceday)
exten = s,n,Goto(s,HOURS))
exten = s,n(HOLIDAY4),Playback(office-closed&Laborday)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY5),Playback(office-closed&ColumbusDay)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY6),Playback(office-closed&vetrans)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY7),Playback(office-closed&thanksgiving)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY8),Playback(office-closed&x-mas)
exten = s,n,Goto(s,HOURS)
;
[can-holiday-timerules]
;switch = Realtime/dialplan@pbx-db-name
exten = s,1,GotoIfTime(*|*|31-1|dec-jan?s|HOLIDAY1)
exten = s,n,GotoIfTime(*|*|6|april?s|HOLIDAY2)
exten = s,n,GotoIfTime(*|*|9|april?s|HOLIDAY3)
exten = s,n,GotoIfTime(*|*|21|may?s|HOLIDAY4)
exten = s,n,GotoIfTime(*|*|25|jun?s|HOLIDAY5)
exten = s,n,GotoIfTime(*|*|1-2|jul?s|HOLIDAY6)
exten = s,n,GotoIfTime(*|*|6|aug?s|HOLIDAY7)
exten = s,n,GotoIfTime(*|*|3|sept?s|HOLIDAY8)
exten = s,n,GotoIfTime(*|*|8|oct?s|HOLIDAY9)
exten = s,n,GotoIfTime(*|*|12|nov?s|HOLIDAY10)
exten = s,n,GotoIfTime(*|*|24-25|dec?s|HOLIDAY11)
exten = s,n,GotoIfTime(*|*|26|dec?s|HOLIDAY12)
exten = s,n,Goto(timebasedrules,1,1)
;
exten = s,n(HOLIDAY1),Playback(office-closed&New-Years)
exten = s,n,Goto(s,HOURS))
exten = s,n(HOLIDAY2),Playback(office-closed&Good-Friday)
exten = s,n,Goto(s,HOURS))
exten = s,n(HOLIDAY3),Playback(office-closed&Easter-Monday)
exten = s,n,Goto(s,HOURS))
exten = s,n(HOLIDAY4),Playback(office-closed&Victoriaday)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY5),Playback(office-closed&SanJuanBaptisteDay)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY6),Playback(office-closed&CanadaDay)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY7),Playback(office-closed&Laborday)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY8),Playback(office-closed&Thanksgiviing)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY9),Playback(office-closed&Remberanceday)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY10),Playback(office-closed&xmas)
exten = s,n,Goto(s,HOURS)
exten = s,n(HOLIDAY11),Playback(office-closed&boxingday)
exten = s,n,Goto(office-hours,s,1)
;
[office-hours]
exten = s,1,Playback(office-hours&vm-goodbye))
exten = s,n,Macro(hangupcall))
;
[timebasedrules]
;switch = Realtime/dialplan@pbx-db-name
exten = 1,1,NoOp(Office Open)
exten = 1,n,GotoIfTime(08:00-20:00|mon-fri|*|jan-dec?main-irv-menu,s,1)
exten = 1,n,Goto(office-hours,s,1)
;
;-------------------------------------------------------------------
; Basic Inbound - IVR Menu 
;-------------------------------------------------------------------
[main-ivr-menu]
;switch = Realtime/dialplan@pbx-db-name
exten = s,1,Answer()
exten = s,n,Background(ivr-menu-gsm-or-wav-file)
exten = s,n,DigitTimeout(5)
exten = s,n,ResponseTimeout(10)
;
exten = i,1,Background(pbx-invalid)  ; "That's not valid, try again" 
exten = i,2,Wait(1)
exten = i,3,Goto(s,9)
;
exten = t,1,Playback(pls-wait-connect-call)
exten = t,n,Goto(operator-queue,s,1)
;
;1 Sales Dept
exten = 1,1,GotoIfTime(08:00-16:59|mon-fri|*|*?selection,5,2)
exten = 1,2,Playback(sales-closed)
exten = 1,3,Playback(vm-goodbye)
exten = 1,4,Hangup
exten = 1,5,Playback(pls-wait-connect-call)
exten = 1,6,Goto(basic-queues|100|1)
;
;2 Billing Dept
exten = 2,1,GotoIfTime(08:00-16:59|mon-fri|*|*?selection,5,2)
exten = 2,2,Playback(biling-closed)
exten = 2,3,Playback(vm-goodbye)
exten = 2,4,Hangup
exten = 2,5,Playback(pls-wait-connect-call)
exten = 2,6,Goto(basic-queues|101|1)
;
;3 Technical Support Dept
exten = 3,1,GotoIfTime(08:00-22:59|mon-fri|*|*?selection,5,2)
exten = 3,2,Playback(techsupport-closed)
exten = 3,3,Playback(vm-goodbye)
exten = 3,4,Hangup
exten = 3,5,Playback(pls-wait-connect-call)
exten = 3,6,Goto(basic-queues|102|1)
;
;4
;exten = 4,1,Playback()
;exten = 4,n,Hangup
;5
;exten = 5,1,Playback()
;exten = 5,n,Hangup
;
;6
;exten = 6,1,Playback()
;exten = 6,n,Hangup
;
;7
;exten = 7,1,Playback()
;exten = 7,n,Hangup
;
;8 
;exten = 8,1,Playback()
;exten = 8,n,Hangup
;
;9 Fax Extension
exten = 9,1,Set(CALLEDFAX=${EXTEN})
exten = 9,2,Answer
exten = 9,3,Goto(fax,${EXTEN},1)
;
exten = fax,1,Goto(ext-fax,in_fax,1)
;
;-----------------------------------------------------
;Basic Sip / IAX2 Outbound Proviver setup
;change provider to your sip/iax2 provider
;-----------------------------------------------------
;[provider]
;switch = Realtime/dialplan@pbx-db-name
;US LD & Canada 11 digit Dialing
;exten = _1NXXNXXXXXX,1,Macro(user-callerid)
;exten = _1XXXXXXXXXX,n,DIAL(SIP or IAX2/${username}:$password}@${provider}/${EXTEN})
;exten = _1NXXNXXXXXX,n,Hangup
;
;10 digit us dialing
;exten = _NXXNXXXXXX,1,Macro(user-callerid)
;exten = _NXXNXXXXXX,n,DIAL(SIP or IAX2/username@provider/${EXTEN})
;exten = _NXXNXXXXXX,n,Hangup
;
;us local 7 digit dialing
;exten = _NXXXXXX,1,Macro(user-callerid)
;exten = _NXXXXXX,n,DIAL(SIP or IAX2 /${username}:$password}@${provider}/###${EXTEN})  ; ### change to areacode for 7 digit dialing
;exten = _NXXXXXX,n,Hangup
;
;International Dialing
;exten = _011.,1,Macro(user-callerid)
;exten = _011.,n,DIAL(SIP or IAX2 /${username}:$password}@${provider}/${EXTEN})
;exten = _011.,n,Hangup
;
;---------------------------------------------
;Spipphone.com Ooutboune Setup
;---------------------------------------------
;[sipphone]
;switch = Realtime/dialplan@pbx-db-name
;exten = _1747NXXXXXX,1,Macro(user-callerid)
;exten = _1747NXXXXXX,n,Dial(SIP/${EXTEN}@sipphone)
;exten = _1747NXXXXXX,n,Playback(invalid)
;exten = _1747NXXXXXX,n,Congestion
;exten = _1747NXXXXXX,n,Hangup
;
;--------------------------------------------
;Free world Dialup outbound
;--------------------------------------------
;[fwddialup]
;switch = Realtime/dialplan@pbx-db-name
;exten = _#6.,1,Macro(user-callerid)
;exten = _#6.,n,Dial(SIP/${FWDNUMBER}:${FWDPASSWORD}@fwd.pulver.com/${EXTEN:2},60,r)
;exten = _#6.,n,Hangup
;
;----------------------------------------------
;Master Dialplan
;Need to add active feature checking and status checking.
;----------------------------------------------
[macro-trunkdial]
;
; Standard trunk dial macro (hangs up on a dialstatus that shoul terminate call)
;   ${ARG1} - What to dial
;
exten => s,1,Dial(${ARG1})
exten => s,n,Goto(s-${DIALSTATUS},1,)
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Hangup
exten => _s-.,1,NoOp
;
[macro-stdexten]
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;
exten => s,1,Dial(${ARG2},20)  ; Ring the interface, 20 seconds maximum
exten => s,2,Goto(s-${DIALSTATUS},1)  ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s-NOANSWER,1,Voicemail(${ARG1},u)  ; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)  ; If they press #, return to start
exten => s-BUSY,1,Voicemail(${ARG1},b)  ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)  ; If they press #, return to start
exten => _s-.,1,Goto(s-NOANSWER,1)  ; Treat anything else as no answer
exten => a,1,VoicemailMain(${ARG1})  ; If they press *, send the user into VoicemailMain
;
[macro-stdPrivacyexten];
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;   ${ARG3} - Optional DONTCALL context name to jump to (assumes the s,1 extension-priority)
;   ${ARG4} - Optional TORTURE context name to jump to (assumes the s,1 extension-priority)`
;
exten => s,1,Dial(${ARG2},20|p)  ; Ring the interface, 20 seconds maximum, call screening 
; option (or use P for databased call screening)
exten => s,2,Goto(s-${DIALSTATUS},1)  ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s-NOANSWER,1,Voicemail(${ARG1},u)  ; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)  ; If they press #, return to start
exten => s-BUSY,1,Voicemail(${ARG1},b)  ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)  ; If they press #, return to start
exten => s-DONTCALL,1,Goto(${ARG3},s,1)  ; Callee chose to send this call to a polite "Don't call again" script.
exten => s-TORTURE,1,Goto(${ARG4},s,1)  ; Callee chose to send this call to a telemarketer torture script.
exten => _s-.,1,Goto(s-NOANSWER,1)  ; Treat anything else as no answer
exten => a,1,VoicemailMain(${ARG1})  ; If they press *, send the user into VoicemailMain
;
;------------------------------------------------
;Vertical Service Code & Definitions
;-----------------------------------------------------
;This is Nanpa vertical service codes + Codes I added to the setup for functionality. Some of these functions have not been mapped in
;asterisk. Some of them can be remapped or changed, but for the most part the layout fallows Nanpa.  
;
;I would like to see all the vsc code move to a ?????.conf file and just use a #include = ?????.conf
;
;-----------------------------------------------------
; # - Company directory
;-----------------------------------------------------
[app-directory]
exten = ##,1,Answer
exten = ##,n,Wait(1)
exten = ##,n,AGI(directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS}o)
exten = ##,n,Playback(vm-goodbye)
exten = ##,n,Hangup
; Taken from Freepbx for GXP2000 phones.
;-----------------------------------------------------
;Remote Line Pickup  ** is used so that gxp2000 can use this function.
;-----------------------------------------------------
[app-pickup]
exten = _**.,1,Noop(Attempt to Pickup ${EXTEN:2} by ${CALLERID(num)})
exten = _**.,n,Pickup(${EXTEN:2})
;
;--------------------------------------------------------------------------------------------------------------------------------
;Inward Voice Activated Services (*00 English, *01 French)
;IVAS enables a subscribing business to provide automated voice activated routing for inbound English or French speaking calls 
;(i.e., separate codes for the same service in each language). IVAS will initially consist of the following services:
;
;* Voice Activated Premier Dialing (VAPD) which allows customers to contact subscribing businesses by speaking the business 
;  name or service.
;
;* Voice Activated Blue Pages (VABP) which allows customers to request access to government services.
;
;* Voice Activated Auto Attendant (VAAA) which provides enhancements to Auto Attendant applications by providing a voice
;  recognition interface in place of Touch Tone.
;
;* Voice Activated Audio Text (VAAT) provides users ability to request specific information from a business.
;
;* Voice Activated Interactive Voice Response (VAIVR) which allows the caller to interact with a subscriber's specific 
;  application in a prescribed manner.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Deactivation/Activation of In-Session Activation (ISA) on a per line basis (*02)
;Allows a subscriber to deactivate or activate (i.e., toggle) the In-Session Activation feature on a per line basis. ISA 
;is feature that gives the caller a menu of call completion services using voice prompts when the call encounters a busy 
;or no-answer condition.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Deactivation of In-Session Activation (ISA) on a per call basis (*03)
;Allows a subscriber to deactivate the In-Session Activation feature on a per call basis. When the call is completed, ISA 
;reverts back to the active state. ISA is a feature that gives the caller a menu of call completion services using voice 
;prompts when the call encounters a busy or no-answer condition.
;--------------------------------------------------------------------------------------------------------------------------------
;----------------------------------------------------
; *1 - System Status recorded file
;----------------------------------------------------
[app-sysstat]
; *1 - System Status
exten = *1,1,Answer
exten = *1,n,Wait(.5)
exten = *1,n,Playback(/var/lib/asterisk/sounds/custom/systemstatus)
exten = *1,n,Wait(.5)
exten = *1,n,Macro(hangupcall)
;
; *1* - System status record
exten = *1*,1,Answer
exten = *1*,n,Wait(2)
exten = *1*,n,Record(/var/lib/sounds/custom/systemstatus:gsm)
exten = *1*,n,Wait(2)
exten = *1*,n,Playback(/var/lib/asterisk/sounds/custom/systemstatus)
exten = *1*,n,Wait(2)
exten = *1*,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *2 - Say Phone Number
;-----------------------------------------------------------
[app-say-exten]
exten = *2,1,Answer
exten = *2,n,Playback(your-exten-num-is)
exten = *2,n,SayDigits(${CALLERID(number)})
exten = *2,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *3  - Say Date and Time
;-----------------------------------------------------------
[app-say-date]
exten = *3,1,Answer
exten = *3,2,Playback(at-tone-time-exactly)
exten = *3,3,SayUnixTime(,,IMp)
exten = *3,4,Playback(beep)
exten = *3,5,Macro(hangupcall)
;
;-----------------------------------------------------------
; *4 - Echo Test
;-----------------------------------------------------------
[app-echo]
exten = *4,1,Answer
exten = *4,n,Playback(demo-echotest)
exten = *4,n,Playback(beep)
exten = *4,n,Echo
exten = *4,n,Playback(demo-echodone)
exten = *4,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *5 - Milliwatt Tone
;-----------------------------------------------------------
[app-milliwatt]
exten = *5,1,Answer
exten = *5,n,Milliwatt
exten = *5,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *6 - Record Promt Test Format Gsm
;-----------------------------------------------------------
[app-rec-playback]
exten = *6,1,Answer
exten = *6,n,Wait(1)
exten = *6,n,Record(record:gsm)
exten = *6,n,Wait(1)
exten = *6,n,Playback(record)
exten = *6,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *7 - Music On Hold 
;-----------------------------------------------------------
[app-moh]
exten = *7,1,Answer
exten = *7,n,MusicOnHold(default)
exten = *7,n,Macro(hangupcall)
;
;------------------------------------
;*8  Says Time & plays Tone & Repeat's
;------------------------------------
[app-clock]; repeates time.
exten = *8,1,Answer
exten = *8,2,Set(FutureTime=$[${EPOCH} + 8])
exten = *8,3,Set(FutureTimeMod=$[${FutureTime} % 10])
exten = *8,4,Set(FutureTime=$[${FutureTime} - ${FutureTimeMod}])
exten = *8,5,Set(MaxConnectTime=$[${FutureTime} + 180])
exten = *8,6,Set(FutureTimeMod=$[${FutureTime} - ${EPOCH}])
exten = *8,7,GotoIf($["${FutureTimeMod}" < "0"]?10:8)
exten = *8,8,wait(1)
exten = *8,9,goto(6)
exten = *8,10,Answer
exten = *8,11,Set(FutureTime=$[${FutureTime} + 10])
exten = *8,12,Set(FutureTimeMod=$[${FutureTime} % 60])
exten = *8,13,wait(1)
exten = *8,14,playback(at-tone-time-exactly)
exten = *8,15,SayUnixTime(${FutureTime},,I)
exten = *8,16,SayUnixTime(${FutureTime},,M)
exten = *8,17,GotoIf($["${FutureTimeMod}" = "0"]?18:20)
exten = *8,18,SayUnixTime(${FutureTime},,p)
exten = *8,19,goto(23)
exten = *8,20,playback(and)
exten = *8,21,SayUnixTime(${FutureTime},,S)
exten = *8,22,playback(seconds)
exten = *8,23,Set(FutureTimeMod=$[${FutureTime} - ${EPOCH}])
exten = *8,24,GotoIf($["${FutureTimeMod}" < "1"]?27:25)
exten = *8,25,wait(1)
exten = *8,26,goto(23)
exten = *8,27,playback(beep)
exten = *8,28,Set(FutureTimeMod=$[${MaxConnectTime} - ${EPOCH}])
exten = *8,29,GotoIf($["${FutureTimeMod}" < "1"]?30:11)
exten = *8,30,Macro(hangupcall)
;
;-----------------------------------------------------------
; *9 - Wakeupcall
; Avaible for local mapping requires php to be installed
; agi code below wapeup.php and wakeconfirm.agi
;-----------------------------------------------------------
[app-wakeup]
exten = *9,1,Answer
exten = *9,n,Wait(1)
exten = *9,n,AGI(wakeup.php)
exten = *9,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *10 - Reginal & Local Weather  Requires flite/festival and
;and a sql database for zipcodes and php and the Nevr vitels 
;Weather by zipcode script 
;-----------------------------------------------------------
[app-weather]
exten = *10,1,Answer
exten = *10,n,Wait(1)
exten = *10,n,Set(TIMEOUT(digit)=7)
exten = *10,n,Set(TIMEOUT(response)=10)
exten = *10,n,Flite('At the beep enter the five digit zip code for the weather report you wish to retrieve.')
exten = *10,n,Read(ZIPCODE,beep,5,,,)
exten = *10,n,Flite('Please hold a moment while we contact the National Weather Service for your report.')
exten = *10,n,AGI(nv-weather-zip.php|${ZIPCODE})
exten = *10,n,Noop(Wave file: ${TMPWAVE})
exten = *10,n,Playback(${TMPWAVE})
exten = *10,n,Macro(hangupcall)
;
;----------------------------------------------------------
; *11 - avaible
;----------------------------------------------------------
;-----------------------------------------------------------
; *12 - Current Company Job Listings not yet working
;-----------------------------------------------------------
[app-jobs-postings]
exten = *12,1,Answer 
exten = *12,n,Playback(current-job-postings) 
exten = *12,n,System(/bin/curl -s )
exten = *12,n,Wait(1) 
exten = *12,n,MP3Player(/tmp/jobs.mp3) 
exten = *12,n,System(rm /tmp/jobs.mp3 -f) 
exten = *12,n,Playback(vm-goodbye)
exten = *12,n,Macro(hangupcall)
;
;------------------------------------------------------------
;Intercom
;------------------------------------------------------------
[app-ext-intercom]
exten = _*13.,1,Set(dialnumber=${EXTEN:3})
exten = _*13.,n,dbGet(user-intercom=SIP/${dialnumber}/intercom)
exten = _*13.,n,GotoIf($["${user-intercom}" = "disabled" ]?nointercom)
exten = _*13.,n,Set(__SIPADDHEADER=Call-Info: ;answer-after=0)
exten = _*13.,n,Set(__ALERT_INFO=Ring Answer)
exten = _*13.,n,Set(__SIP_URI_OPTIONS=intercom=true)
exten = _*13.,n,Dial(Local/${dialnumber}@from-internal/n)
exten = _*13.,n,Busy(20)
exten = _*13.,n,Macro(hangupcall)
exten = _*13.,n(nointercom),Noop(Intercom disallowed by ${dialnumber})
exten = _*13.,n,Playback(intercom&for&extension)
exten = _*13.,n,SayDigits(${dialnumber})
exten = _*13.,n,Playback(is&disabled)
exten = _*13.,n,Congestion(20)
exten = _*13.,n,Macro(hangupcall)
;
;------------------------------------------------------------
;Enable Intercom Per exten
;------------------------------------------------------------
[app-enable-intercom]
exten = *14,1,Answer
exten = *14,n,Wait(1)
exten = *14,n,Set(DB(SIP/${CALLERID(number)}/intercom)=enabled)
exten = *14,n,Playback(intercom&enabled)
exten = *14,n,Macro(hangupcall)
;
;------------------------------------------------------------
;Disable Intercom Per exten
;------------------------------------------------------------
[app-disable-intercom]
exten = *15,1,Answer
exten = *15,n,Wait(1)
exten = *15,n,Set(DB(SIP/${CALLERID(number)}/intercom)=disabled)
exten = *15,n,Playback(intercom&disabled)
exten = *15,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *16 ChanSpy  Used to monitor users calls. Uses the Macro 
; Provided below for checking username and passwords for access
;-----------------------------------------------------------
[app-chanspy]
exten = *16,1,Macro(chanspy,s,1)

[macro-chanspy]
exten = s,1,Set(LOOPCOUNT=0)
exten = s,n,Answer
exten = s,n,Wait(1)
exten = s,n(begin),Set(TIMEOUT(digit)=3)
exten = s,n,Set(TIMEOUT(response)=10)
exten = s,n,Playback(please-enter&your&extension)
exten = s,n,Read(ext_num,then-press-pound,,)
exten = s,n,Wait(1)
exten = s,n,Playback(pls-enter-chanspy-password)
exten = s,n,Read(ext_pwd,then-press-pound,,)
exten = s,n,Wait(1)
exten = s,n,AGI(chk_chanspy_pwd.agi|/usr/local/etc/asterisk/chanspy.conf|${ext_num}|${ext_pwd})
exten = s,n,GotoIf($["${result}" = "0"]?D:pwd-chanspy,i,1)
exten = s,n,Set(CALLERIDNUM=${ext_num})
exten = s,n(d),BackGround(please-enter-the&extension&you&with&to&monitor)
exten = s,n,Set(TIMEOUT(digit)=5)  ; Set Digit Timeout to 5 seconds
exten = s,n,Set(TIMEOUT(response)=10)  ; Set Response Timeout to 10 seconds
exten = _.,1,ChanSpy(SIP/${EXTEN}|q)
exten = i,1,PlayBack(invalid&extension)
exten = i,n,Goto(loop,1)
exten = t,1,Goto(loop,1)
exten = loop,1,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten = loop,n,GotoIf($[${LOOPCOUNT} > 2]?hang,1)
exten = loop,n,Goto(custom-chanspy,s,begin)
exten = hang,1,Playback(vm-goodbye)
exten = hang,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *17 - *19 - Free for assignment
;-----------------------------------------------------------
;-----------------------------------------------------------
; *20 - *29 - Free for assignment
;-----------------------------------------------------------
;-----------------------------------------------------------
; *20 - REPORT BACK ON EXTENSION STATUS
;-----------------------------------------------------------
;------------------------------------------------------------------------------------------
; REPORT BACK ON EXTENSION STATUS
;
; Settings Currently Supported:
;       CW:     Call Waiting
;       DND:    Do Not Disturb
;       CFB:    Call Forward On Busy
;       CFU:    Call Forward On Unavailable / No Answer
;       CF:     Call Forward Unconditional
;
; get status of a specific extentsion by dialing *109xxx where xxx is the extension
; status is desired for. (Can be any number of supported extension digits)
;-------------------------------------------------------------------------------------------
[app-application-status]
; get status from specific extension, prompted after dialing
exten => *20,1,Answer
exten => *20,n,Wait(1)
exten => *20,n,BackGround(please-enter-the)
exten => *20,n,Playback(extension)
exten => *20,n,Read(uext,then-press-pound)
exten => *20,n,Wait(1)
exten => *20,n,Goto(menu-check-status,s,1)
exten => _*20.,1,Set(uext=${EXTEN:4})
exten => _*20.,n,Noop(STATUS ON EXTENSION: ${EXTEN:4})
exten => _*20.,n,Answer
exten => _*20.,n,Wait(1)
exten => _*20.,n,Goto(macro-check-status,s,1)
; playback extension settings for current or prompted phone
exten => *21,1,Answer
exten => *21,n,Set(uext=${CALLERIDNUM})
exten => *21,n,Goto(macro-check-status,s,1)
; this function is passed an extension number and will read back the
; status on the target extension
;
; TARGET EXTENSION ${uext}
;
; Settings Currently Supported:
;       CW:     Call Waiting
;       DND:    Do Not Disturb
;       CFB:    Call Forward On Busy
;       CFU:    Call Forward On Unavailable / No Answer
;       CF:     Call Forward Unconditional
[macro-check-status]
; Announce Extension Being Reported on
exten => s,1,Noop(REPORTING STATUS ON EXT: ${uext})
exten => s,n,Playback(status&for&extension)
exten => s,n,SayDigits(${uext})
exten => s,n,Playback(is)
; CW:  Call Waiting Status
exten => s,n,Noop(CW RESULTS: ${DB_EXISTS(CW/${uext})} : ${DB_RESULT})
exten => s,n,Playback(custom/quarter-second-silence&call-waiting)
exten => s,n,GotoIf($[${DB_EXISTS(CW/${uext})}]?cwenabled:cwdisabled)
exten => s,n(cwenabled),Playback(activated)
exten => s,n,Goto(dndcheck)
exten => s,n(cwdisabled),Playback(de-activated)
; DND: Do Not Disturb Status
exten => s,n(dndcheck),Noop(DND RESULTS: ${DB_EXISTS(DND/${uext})} : ${DB_RESULT})
exten => s,n,Playback(custom/quarter-second-silence&do-not-disturb)
exten => s,n,GotoIf($[${DB_EXISTS(DND/${uext})}]?dndenabled:dnddisabled)
exten => s,n(dndenabled),Playback(activated)
exten => s,n,Goto(cfbcheck)
exten => s,n(dnddisabled),Playback(de-activated)
; CFB: Call Forward on Busy Status
exten => s,n(cfbcheck),Noop(CFB RESULTS: ${DB_EXISTS(CFB/${uext})} : ${DB_RESULT})
exten => s,n,Playback(custom/quarter-second-silence&call-fwd-on-busy)
exten => s,n,GotoIf($[${DB_EXISTS(CFB/${uext})}]?cfbenabled:cfbdisabled)
exten => s,n(cfbenabled),Playback(activated&and&is-set-to)
exten => s,n,SayDigits(${DB_RESULT})
exten => s,n,Goto(cfucheck)
exten => s,n(cfbdisabled),Playback(de-activated)
; CFU: Call Forward on Unavailable Status
exten => s,n(cfucheck),Noop(CFU RESULTS: ${DB_EXISTS(CFU/${uext})} : ${DB_RESULT})
exten => s,n,Playback(custom/quarter-second-silence&call-fwd-no-ans)
exten => s,n,GotoIf($[${DB_EXISTS(CFU/${uext})}]?cfuenabled:cfudisabled)
exten => s,n(cfuenabled),Playback(activated&and&is-set-to)
exten => s,n,SayDigits(${DB_RESULT})
exten => s,n,Goto(cfcheck)
exten => s,n(cfudisabled),Playback(de-activated)
; CF:  Call Forward Unconditional Status
exten => s,n(cfcheck),Noop(CF RESULTS: ${DB_EXISTS(CF/${uext})} : ${DB_RESULT})
exten => s,n,Playback(custom/quarter-second-silence&call-fwd-unconditional)
exten => s,n,GotoIf($[${DB_EXISTS(CF/${uext})}]?cfenabled:cfdisabled)
exten => s,n(cfenabled),Playback(activated&and&is-set-to)
exten => s,n,SayDigits(${DB_RESULT})
exten => s,n,Goto(endcheck)
exten => s,n(cfdisabled),Playback(de-activated)
; CALL STATUS END - GOODBYE!
exten => s,n,Playback(custom/quarter-second-silence&goodbye)
exten => s,n,Hangup
;
;-------------------------------------------------------------
;*31 - *33 BlackList
;------------------------------------------------------------
[blacklist]
exten = *31,1,Goto(app-blacklist-add,s,1)
exten = *32,1,Goto(app-blacklist-remove,s,1)
exten = *33,1,Goto(app-blacklist-last,s,1)
;
[app-blacklist-check]
exten = s,1,LookupBlacklist()
exten = s,n,GotoIf($["${LOOKUPBLSTATUS}"="FOUND"]?blacklisted)
exten = s,n,Return()
exten = s,n(blacklisted),Answer
exten = s,n,Wait(1)
exten = s,n,Zapateller()
exten = s,n,Zapateller()
exten = s,n,Playback(ss-noservice)
exten = s,n,Hangup
;
[app-blacklist-add]
exten = s,1,Answer
exten = s,n,Wait(1)
exten = s,n,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)
exten = s,n,Playback(digits/1)
exten = s,n(end),Noop(Waiting for input)
exten = 1,1,Set(DB(blacklist/${blacknr})=1)
exten = 1,n,Playback(num-was-successfully)
exten = 1,n,Playback(added)
exten = 1,n,Wait(1)
exten = 1,n,Hangup
;
[app-blacklist-last]
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)
exten = s,n,Playback(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)
exten = s,n,Playback(digits/1)
exten = s,n,Goto(end)
exten = s,n(noinfo),Playback(unidentified-no-callback)
exten = s,n,Hangup
exten = s,n(end),Noop(Waiting for input)
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
;
[app-blacklist-remove]
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)
exten = s,n,Playback(digits/1)
exten = s,n(end),Noop(Waiting for input)
exten = 1,1,dbDel(blacklist/${blacknr})
exten = 1,n,Playback(num-was-successfully)
exten = 1,n,Playback(removed)
exten = 1,n,Wait(1)
exten = 1,n,Hangup
;
;-------------------------------------------------------------
; Dictation Record
;-------------------------------------------------------------
[app-dictate-record]
exten = *34,1,Answer
exten = *34,n,Noop(CallerID is ${CALLERID(num)})
exten = *34,n,Dictate(/var/lib/asterisk/sounds/dictate/${CALLERID(num)})
exten = *34,n,Macro(hangupcall)
;
;---------------------------------------------------------------
;Dictation Send
;---------------------------------------------------------------
[app-dictate-send]
exten = *35,1,Answer
exten = *35,n,Noop(CallerID is ${CALLERID(num)})
exten = *35,n,Read(DICTFILE,enter-filename-short,,)
exten = *35,n,Set(DICTEMAIL=${DB(SIP/${CALLERID(num)}/dictate/email)})
exten = *35,n,Set(DICTFMT=${DB(SIP/${CALLERID(num)}/dictate/format)})
exten = *35,n,Set(NAME=${DB(SIP/${CALLERID(num)}/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/${CALLERID(num)}/${DICTFILE}.raw
exten = *35,n,Playback(dictation-sent)
exten = *35,n,Macro(hangupcall)
;
;-----------------------------------------------------------
; *36 - *39 - Free for assignment
;-----------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------------------
;Change Forward-To Number for Customer/Programmable Call Forwarding Busy Line (*40)
;Access Code followed by directory number is used to change the forwarded-to number for Call Forwarding Busy Line (CFBL). The state 
;of CFBL is not changed when this access code is used. This feature will utilize the activation code of *90 and deactivation code *91 
;with the following exceptions:activation will not require/allow the identification of a forwarded-to directory number and deactivation 
;will not clear the forwarded-to directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cpcfd]
exten = _*40.,1,Answer
exten = _*40.,n,Wait(1)
exten = _*40.,n,Set(DB(CPCFB/${CALLERID(number)})=${EXTEN:3})
exten = _*40.,n,Playback(call-fwd-no-ans&for&extension)
exten = _*40.,n,SayDigits(${CALLERID(number)})
exten = _*40.,n,Playback(is-set-to)
exten = _*40.,n,SayDigits(${EXTEN:3})
exten = _*40.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Six-Way Conference Calling Activation (*41)
;Allows the subscriber to originate a six-way conference call. Customers will enter this code prior to the first directory number 
;added into the conference. Each subsequent member of the conference is added with a flash hook. This code is used to eliminate 
;action conflicts with other flash hook originated features.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Change Forward-To Number for Customer Programmable Call Forwarding Don't Answer (*42)
;Access Code followed by directory number is used to change the forwarded-to number for Call Forwarding Don't Answer (CFDA). The 
;state of CFDA is not ;changed when this access code is used. This feature will utilize the activation code of *92 and deactivation 
;code *93 with the following exceptions:activation will not require/allow the identification of a forwarded-to directory number and 
;deactivation will not clear the forwarded-to directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cpcfda]
exten = _*42.,1,Answer
exten = _*42.,n,Wait(1)
exten = _*42.,n,Set(DB(CPCFDA/${CALLERID(number)})=${EXTEN:3})
exten = _*42.,n,Playback(call-fwd-no-ans&for&extension)
exten = _*42.,n,SayDigits(${CALLERID(number)})
exten = _*42.,n,Playback(is-set-to)
exten = _*42.,n,SayDigits(${EXTEN:3})
exten = _*42.,n,Macro(hangupcall,
;
;--------------------------------------------------------------------------------------------------------------------------------
;Drop last member of Six-Way Conference Call (*43)
;Provides the subscriber establishing a six-way conference to terminate the last party added to the call. This frees the port for 
;an additional party when the last party wasn't reachable.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Voice Activated Dialing (*44)
;Access to the Voice Activated Dialing (VAD) directory. Customers will dial this code to access their VAD directory in order to add, 
;delete or review the names and numbers
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Voice Dialing Extended Dial Tone (*45)
;Extend dial tone for Voice Activated Dialing (VAD). Customers will dial this code to extend the length of time in which dial 
;tone is heard after going off-hook so that various Customer Premise Equipment (CPE, i.e., fax and modems) will work properly.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;French Voice Activated Network Control (*46)
;Provides the subscriber access to Voice Activated Network Control (VANC) via the French language. Subscribers will dial this 
;code to access VANC so that they can say a name or command in French that will be activated, deactivated or provide access 
;to a service, e.g., Call Forwarding, Call Trace, etc.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Override Feature Authorization (*47)
;Allows a subscriber to override a Feature Authorization activated on a line which restricts 1+ calls from that line. Feature 
;Authorization may be overriden by dialing *47 and a Personal Identification Number ;(PIN) and then dialing a 1+ call after 
;receiving a second dial tone.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Override Do Not Disturb (*48)
;Allows a subscriber to override the Do Not Disturb feature which has been activated on a line. After receiving a message 
;indicating the station is in a Do Not Disturb condition, the subscriber may override the condition by dialing *48 and then 
;a Personal Identification Number (PIN) thus allowing the call to be completed in the normal manner.
;--------------------------------------------------------------------------------------------------------------------------------
[app-dnd-overide]
exten = _*48.,1,Dial(SIP/${ARG1}:3|20|r)  ; 20sec timeout
exten = _*48.,n,Voicemail(u${ARG1})
exten = _*48.,n,Hangup
;
;--------------------------------------------------------------------------------------------------------------------------------
;Long Distance Signal (*49)
;Extended period activation/deactivation (toggle) of basic 1FR/1MR long distance signal ringing/call waiting tones.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Voice Activated Network Control (*50)
;Access to Voice Activated Network Control (VANC). Customers will dial this code to access VANC so that they can say a name or
;command that will be activated, deactivated or to access a service.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Who Called Me? (*51)
;Provides the subscriber with the directory number (DN), date, and time of unanswered calls. 
;--------------------------------------------------------------------------------------------------------------------------------
[app-whocall]
exten = *51,2,Answer
exten = *51,3,Wait(1)
exten = *51,4,Background(info-about-last-call)
exten = *51,5,Background(telephone-number)
exten = *51,6,Set(lastcaller=${DB(CALLTRACE/${CALLERID(number)})})
exten = *51,7,GotoIf($[${lastcaller}]?8:10)
exten = *51,8,SayDigits(${lastcaller})
exten = *51,9,Macro(hangupcall)
exten = *51,10,Playback(from-unknown-caller)
exten = *51,11,Playback(unidentified-no-callback)
exten = *51,12,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Single Line Variety Package (SVP) - Call Hold (*52)
;Gives the subscriber the capability of placing a call on hold so that the call may be continued from another extension.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Single Line Variety Package (SVP) - Distinctive Ring B (*53)
;Allows a subscriber to select, by way of distinctive ringing, the particular person or extension that the subscriber wishes to alert.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Single Line Variety Package (SVP) - Distinctive Ring C (*54)
;Allows a subscriber to select, by way of distinctive ringing, the particular person or extension that the subscriber wishes to alert.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Single Line Variety Package (SVP) - Distinctive Ring D (*55)
;Allows a subscriber to select, by way of distinctive ringing, the particular person or extension that the subscriber wishes to alert.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Change Forward-To Number for ISDN Call Forwarding (*56)
;Access code followed by directory number (DN) is used to change the Forward-To number for Call Forwarding Variable feature button. 
;The state of Call ;Forwarding Variable feature button is not changed when this access code is utilized.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Customer Originated Trace (*57)
;Provides the recipient of an obscene, harassing, or threatening call the ability to request an auto-trace of the last call received.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;ISDN MBKS Manual Exclusion (*58 Activationn)
;Access code allows a Multibutton Key Set (MBKS) user or an analog set user whose telephone number is shared on another ISDN MBKS
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Rejection (*60 Activation)
;Allows the subscriber to have incoming calls from a limited number of calling parties rejected by the terminating switching system.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scra]
exten = _*60.,n,Set(DB(BLACKLIST/${CALLERID(number)})=${EXTEN:3})
exten = _*60.,n,Answer
exten = _*60.,n,Wait(1)
exten = _*60.,n,Playback(blacklist-add&for&extension)
exten = _*60.,n,SayDigits(${CALLERID(number)})
exten = _*60.,n,Playback(is-set-to)
exten = _*60.,n,SayDigits(${EXTEN:3})
exten = _*60.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Distinctive Ringing/Call Waiting (*61 Activation)
;Allows the subscriber to have incoming calls from a limited number of calling parties identified using distinctive alerting treatment.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Waiting (*62)
;Provides the subscriber the ability to provide a Call Waiting signal to a predetermined list of directory numbers specified by 
;the subscriber. Callers not on the predetermined list will receive busy tone.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scw]
exten = *62,1,Answer
exten = *62,n,Wait(1)
exten = *62,n,Set(DB(SCW/${CALLERID(number)})=ENABLED)
exten = *62,n,Playback(selective-call-waiting&activated)
exten = *62,n,Macro(hangupcall)
exten = _*62.,1,Macro(user-callerid)
exten = _*62.,n,Set(DB(SCW/${CALLERID(number)})=${EXTEN:3})
exten = _*62.,n,Answer
exten = _*62.,n,Wait(1)
exten = _*62.,n,Playback(selective-call-waiting-unconditional&for&extension)
exten = _*62.,n,SayDigits(${CALLERID(number)})
exten = _*62.,n,Playback(is-set-to)
exten = _*62.,n,SayDigits(${EXTEN:3})
exten = _*62.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Forwarding (*63 Activation)
;Allows the subscriber to have incoming calls from a limited number of calling parties forwarded to a prespecified remote station.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scfa]
exten = *63,1,Answer
exten = *63,n,Wait(1)
exten = *63,n,Set(DB(SCF/${CALLERID(number)})=ENABLED)
exten = *63,n,Playback(selective-call-waiting&activated)
exten = *63,n,Macro(hangupcall)
exten = _*63.,1,Set(DB(SCF/${CALLERIDNUM})=${EXTEN:3})})
exten = _*63.,n,Answer
exten = _*63,n,Wait(1)
exten = _*63.,n,Playback(selective-call-forwarding&for&extension)
exten = _*63.,n,SayDigits(${CALLERIDNUM})
exten = _*63.,n,Playback(is-set-to)
exten = _*63.,n,SayDigits(${EXTEN:3})
exten = _*63.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Acceptance (*64 Activation)
;Provides the subscriber the ability to block calls from all but a predetermined list of directory numbers specified by the 
;subscriber. Unaccepted callers may receive an announcement or be routed to a predetermined directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scaa]
exten = *64,1,Answer
exten = *64,n,Wait(1)
exten = *64,n,Set(DB(SCA/${CALLERID(number)})=ENABLED)
exten = *64,n,Playback(selective-call-accept&activated)
exten = *64,n,Macro(hangupcall)
exten = _*64.,1,Macro(user-callerid)
exten = _*64.,n,Set(DB(SCA/${CALLERID(number)})=${EXTEN:3})
exten = _*64.,n,Answer
exten = _*64.,n,Wait(1)
exten = _*64.,n,Playback(selective-call-accept&for&extension)
exten = _*64.,n,SayDigits(${CALLERID(number)})
exten = _*64.,n,Playback(is-set-to)
exten = _*64.,n,SayDigits(${EXTEN:3})
exten = _*64.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Calling Number Delivery (*65 Activation)
;Provides the subscriber with the directory number (DN) of the calling party during the ringing cycle.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cnda]
exten = *65,n,Set(DB(CIDB/${CALLERIDNUM}=YES)
exten = *65,n,Answer
exten = *65,n,Wait()
exten = *65,n,Playback(caller-id-blk&activated)
exten = *65,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Automatic Callback (*66 Activation)
;Allows a subscriber to automatically place a call to the last station called by the subscriber when that station becomes idle.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Calling Number Delivery Blocking (*67)
;Allows the subscriber to temporarily change the permanent public/private status indicator of his/her directory number (DN) and 
;thus control its availability to the called party.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cndd]
exten = *67,1,Answer
exten = *67,n,Wait(1)
exten = *67,n,Set(DB(CIDB/${CALLERIDNUM}=YES)
exten = *67,n,Answer
exten = *67,n,Wait(1)
exten = *67,n,Playback(caller-ib-blockin&activated)
exten = *67,n,Macro(hangupcall)
;
;---------------------------------------------------------------------------------------------------------------------------------
;Call Forwarding Busy Line/Don't Answer (*68 Activation)
;Allows a subscriber to forward calls intended for the subscriber's busy line, or idle line after a predetermined number of rings, 
;to another directory number entered by the subscriber at the time of activation.
;---------------------------------------------------------------------------------------------------------------------------------
[app-cfbdaa]
exten = *68,1,Answer
exten = *68,n,Wait(1)
exten = *68,n,Playback(call-fwd-on-busy&please-enter-your&extension)
exten = *68,n,Read(fromext,then-press-pound)
exten = *68,n,Set(fromext=$/{IF($["foo${fromext}"="foo"]?${CALLERID(number)}:${fromext})})
exten = *68,n,Wait(1)
exten = *68,n(startread),Playback(ent-target-attendant)
exten = *68,n,Read(toext,then-press-pound)
exten = *68,n,GotoIf($["foo${toext}"="foo"]?startread)
exten = *68,n,Wait(1)
exten = *68,n,Set(DB(CFBDA${fromext})=${toext})
exten = *68,n,Playback(call-fwd-on-busy&for&extension)
exten = *68,n,SayDigits(${fromext})
exten = *68,n,Playback(is-set-to)
exten = *68,n,SayDigits(${toext})
exten = *68,n,Macro(hangupcall)
exten = _*68.,1,Answer
exten = _*68.,n,Wait(1)
exten = _*68.,n,Set(DB(CFBDA/${CALLERID(number)})=${EXTEN:3})
exten = _*68.,n,Playback(call-fwd-on-busy&for&extension)
exten = _*68.,n,SayDigits(${CALLERID(number)})
exten = _*68.,n,Playback(is-set-to)
exten = _*68.,n,SayDigits(${EXTEN:3})
exten = _*68.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Automatic Recall (*69 Activation) aka lcr
;Allows a subscriber to automatically place a call to the last station that called the subscriber, when that station becomes idle.
;--------------------------------------------------------------------------------------------------------------------------------
[app-lcr]
;exten = *69,1,Macro(user-callerid)
exten = *69,1,Answer
exten = *69,n,Wait(1)
exten = *69,n,Playback(info-about-last-call&telephone-number)
exten = *69,n,Set(lastcaller=${DB(CALLTRACE/${CALLERID(number)})})
exten = *69,n,GotoIf($[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]?noinfo)
exten = *69,n,SayDigits(${lastcaller})
exten = *69,n,Set(TIMEOUT(digit)=3)
exten = *69,n,Set(TIMEOUT(response)=7)
exten = *69,n,Background(to-call-this-number&press-1)
exten = *69,n,Goto(fin)
exten = *69,n(noinfo),Playback(from-unknown-caller&unidentified-no-callback)
exten = *69,n,Macro(hangupcall)
exten = *69,n(fin),Noop(Waiting for input)
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)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Cancel Call Waiting (*70)
;Provides the subscriber the ability to enable the Call Waiting feature for the duration of a telephone call.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cwa]
exten = *70,1,Answer
exten = *70,n,Wait(1)
exten = *70,n,Set(DB(CW/${CALLERID(number)})=ENABLED)
exten = *70,n,Playback(call-waiting&activated)
exten = *70,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Cancel Call Waiting (*71)
;Provides the subscriber the ability to disable the Call Waiting feature for the duration of a telephone call.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cwd]
exten = *71,1,Answer
exten = *71,n,Wait(1)
exten = *71,n,dbDel(CW/${CALLERID(number)})
exten = *71,n,Playback(call-waiting&de-activated)
exten = *71,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Call Forwarding (*72 Activation)
;Allows a subscriber to redirect calls intended for his/her station (base station) to another station (remote station).
;--------------------------------------------------------------------------------------------------------------------------------
[app-cfa]
exten = *72,1,Answer
exten = *72,n,Wait(1)
exten = *72,n,Playback(call-fwd-unconditional)
exten = *72,n,Playback(please-enter-your&extension)
exten = *72,n,Read(fromext,then-press-pound)
exten = *72,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${CALLERID(number)}:${fromext})})
exten = *72,n,Wait(1)
exten = *72,n(startread),Playback(ent-target-attendant)
exten = *72,n,Read(toext,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,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,Set(DB(CF/${CALLERID(number)})=${EXTEN:3})
exten = _*72.,n,Playback(call-fwd-unconditional&for&extension)
exten = _*72.,n,SayDigits(${CALLERID(number)})
exten = _*72.,n,Playback(is-set-to)
exten = _*72.,n,SayDigits(${EXTEN:3})
exten = _*72.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Call Forwarding (*73 Deactivation)
;Allows a subscriber to redirect calls intended for his/her station (base station) to another station (remote station).
;--------------------------------------------------------------------------------------------------------------------------------
[app-cfd]
exten = *73,1,Answer
exten = *73,n,Wait(1)
exten = *73,n,dbDel(CF/${CALLERID(number)})
exten = *73,n,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,dbDel(CF/${fromext})
exten = _*73,n,Playback(call-fwd-unconditional&for&extension)
exten = _*73,n,SayDigits(${fromext})
exten = _*73,n,Playback(cancelled)
exten = _*73,n,Macro(hangupcall)
;
exten = #73,1,Answer
exten = #73,n,Wait(1)
exten = #73,n,Playback(please-enter-your&extension)
exten = #73,n,Read(fromext,then-press-pound)
exten = #73,n,Wait(1)
exten = #73,n,dbDel(CF/${fromext})
exten = #73,n,Playback(call-fwd-unconditional&for&extension)
exten = #73,n,SayDigits(${fromext})
exten = #73,n,Playback(cancelled)
exten = #73,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Speed Calling (*74 Speed Calling 8-Change List)
;Allows a subscriber to assign his/her own speed calling codes directly and immediately from his/her own telephone by dialing 
;a change speed calling list access code, an abbreviated code, and a new telephone number.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Speed Calling (*75 Speed Calling 30-Change List)
;Allows a subscriber to assign his/her own speed calling codes directly and immediately from his/her own telephone by dialing
;a change speed calling list access code, an abbreviated code, and a new telephone number.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Advanced Call Waiting Deluxe (*76)
;Allows a subscriber to specify, in advance of incoming calls, the termination treatment on incoming calls that arrive while
;the subscriber is engaged in another conversation.
;--------------------------------------------------------------------------------------------------------------------------------
[app-acwdd]
exten = *76,1,Answer
exten = *76,n,Wait(1)
exten = *76,n,DBdel(ACW/${CALLERID(number)})
exten = *76,n,Playback(selective-call-waiting)
exten = *76,n,Playback(de-activated)
exten = *76,n,Macro(hangupcall)
exten = #76,1,Answer
exten = #76,n,Wait(1)
exten = #76,n,Playback(please-enter-your&extension)
exten = #76,n,Read(fromext,then-press-pound)
exten = #76,n,Wait(1)
exten = #76,n,dbDel(ACW/${fromext})
exten = #76,n,Playback(selective-call-waiting&for&extension)
exten = #76,n,SayDigits(${fromext})
exten = #76,n,Playback(cancelled)
exten = #76,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Anonymous Call Rejection (*77 Activation)
;Allows Customers to reject calls from parties who have a privacy feature that prevents the delivery of their calling 
;number to the called party.
;--------------------------------------------------------------------------------------------------------------------------------
[app-acra]
exten = *77,1,Answer
exten = *77,n,Wait(1)
exten = *77,n,Set(DB(ACR/${CALLERIDNUM}=YES)
exten = *77,n,Playback(anon-call-rej&activated)
exten = *77,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Do Not Disturb (*78 Activation)
;Provides the subscriber the opportunity of having all calls intercepted by the CO switch whenever the line is programmed 
;for Do Not Disturb. The calling party will receive a message indicating the station is in Do Not Disturb condition.
;--------------------------------------------------------------------------------------------------------------------------------
[app-dnda]
exten = *78,1,Answer
exten = *78,n,Wait(1)
exten = *78,n,Set(DB(DND/${CALLERIDNUM})=YES)})
exten = *78,n,Playback(do-not-disturb&activated)
exten = *78.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Do Not Disturb (*79 Deactivation)
;Provides the subscriber the opportunity of having all calls intercepted by the CO switch whenever the line is programmed for 
;Do Not Disturb. The calling party will receive a message indicating the station is in Do Not Disturb condition.
;--------------------------------------------------------------------------------------------------------------------------------
[app-dndd]
exten = *79,1,Answer
exten = *79,n,Wait(1)
exten = *79,n,DBdel(DND/${CALLERIDNUM})
exten = *79,n,Playback(do-not-disturb&de-activated)
exten = *79,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Rejection (*80 Deactivation)
;Allows the subscriber to have incoming calls from a limited number of calling parties rejected by the terminating switching system.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scrd]
exten = _*80.,1,Answer
exten = _*80.,n,Wait(1)
exten = _*80.,n,DBdel(BLACKLIST/${CALLERID(number)})
exten = _*80.,n,Playback(blacklist-remove)
exten = _*80.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Distinctive Ringing/Call Waiting (*81 Deactivation)
;Allows the subscriber to have incoming calls from a limited number of calling parties identified using distinctive alerting treatment.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Line Blocking Deactivation (*82 Deactivation)
;Line Blocking Deactivation allows a caller to dial a delivery feature access code before dialing a complete telephone number to 
;temporarily override the presentation status of both the caller's directory number and the calling name. If the caller enters the 
;delivery code, then the calling identity presentation status will be shown as "public" for both caller directory number and 
;calling name.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Forwarding (*83 Deactivation)
;Allows the subscriber to have incoming calls from a limited number of calling parties forwarded to a prespecified remote station.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scfd]
exten = *83,1,Answer
exten = *83,n,Wait(1)
exten = *83,n,DBdel(SCF/${CALLERIDNUM})
exten = *83,n,Playback(selective-call-fwd)
exten = *83,n,Wait(1)
exten = *83,n,Playback(deactivated)
exten = *83.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Selective Call Acceptance (*84 Deactivation)
;Provides the subscriber the ability to block calls from all but a predetermined list of directory numbers specified by the 
;subscriber. Unaccepted callers may receive an announcement or be routed to a predetermined directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-scad]
exten = *84,1,Answer
exten = *84,n,Wait(1)
exten = *84,n,DBdel(SCA/${CALLERID(number)})
exten = *84,n,Playback(selective-call-accept)
exten = *84,n,Playback(de-activated)
exten = *84,n,Macro(hangupcall)
;
exten = *84*,1,Answer
exten = *84*,n,Wait(1)
exten = *84*,n,Playback(please-enter-your&extension)
exten = *84*,n,Read(fromext,then-press-pound)
exten = *84*,n,Wait(1)
exten = *84*,n,dbDel(SCA/${fromext})
exten = *84*,n,Playback(selective-call-accept&for&extension)
exten = *84*,n,SayDigits(${fromext})
exten = *84*,n,Playback(cancelled)
exten = *84*,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Calling Number Delivery (*85 Deactivation)
;Provides the subscriber with the directory number (DN) of the calling party during the ringing cycle.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cidbd]
exten = *85,1,Answer
exten = *85,n,Wait(1)
exten = *85,n,DBdel(CIDB/${CALLERIDNUM})
exten = *85,n,Answer
exten = *85,n,Wait(1)
exten = *85,n,Playback(caller-id-blocking&de-activated)
exten = *85,n,Hangup
;
;--------------------------------------------------------------------------------------------------------------------------------
;Automatic Callback (*86 Deactivation)
;Allows a subscriber to automatically place a call to the last station called by the subscriber when that station becomes idle.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Anonymous Call Rejection (*87 Deactivation)
;Allows Customers to reject calls from parties who have a privacy feature that prevents the delivery of their calling number 
;to the called party.
;--------------------------------------------------------------------------------------------------------------------------------
[app-acrd]
exten = *87,1,Answer
exten = *87,n,Wait(1)
exten = *87,n,DBdel(ACR/${CALLERIDNUM})
exten = *87,n,Playback(anon-call-rej)
exten = *87,n,Playback(deactivated)
exten = *87,n,Hangup
;
;--------------------------------------------------------------------------------------------------------------------------------
;Call Forwarding Busy Line/Don't Answer (*88 Deactivation)
;Allows a subscriber to forward calls intended for the subscriber's busy line, or idle line after a predetermined number of rings, 
;to another directory number entered by the subscriber at the time of activation.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cfbdad]
exten = *88,1,Answer
exten = *88,n,Wait(1)
exten = *88,n,dbDel(CFBDA/${CALLERID(number)})
exten = *88,n,Playback(call-fwd-on-busy&de-activated)
exten = *88,n,Macro(hangupcall)
;
exten = _*88.,1,Answer
exten = _*88.,n,Wait(1)
exten = _*88.,n,Set(fromext=${EXTEN:3})
exten = _*88.,n,dbDel(CFB/${fromext})
exten = _*88.,n,Playback(call-fwd-on-busy&for&extension)
exten = _*88.,n,SayDigits(${fromext})
exten = _*88.,n,Playback(cancelled)
exten = _*88.,n,Macro(hangupcall)
;
exten = #88,1,Answer
exten = #88,n,Wait(1)
exten = #88,n,Playback(please-enter-your&extension)
exten = #88,n,Read(fromext,then-press-pound)
exten = #88,n,Wait(1)
exten = #88,n,dbDel(CFBDA/${fromext})
exten = #88,n,Playback(call-fwd-on-busy&for&extension)
exten = #88,n,SayDigits(${fromext})
exten = #88,n,Playback(cancelled)
exten = #88,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Automatic Recall (*89 Deactivation)
;Allows a subscriber to automatically place a call to the last station that called the subscriber, when that station becomes idle.
;--------------------------------------------------------------------------------------------------------------------------------
;
;--------------------------------------------------------------------------------------------------------------------------------
;Customer Programmable Call Forwarding Busy Line (*90 Activation)
;Allows subscriber of the feature to forward calls intended for the subscriber's busy line to another directory number entered 
;by the subscriber at the time of activation. Deactivation will clear the forwarded-to directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cpcfba]
exten = *90,1,Answer
exten = *90,n,Wait(1)
exten = *90,n,Playback(call-fwd-on-busy)
exten = *90,n,Playback(please-enter-your&extension)
exten = *90,n,Read(fromext,then-press-pound)
exten = *90,n,Set(fromext=$/{IF($["foo${fromext}"="foo"]?${CALLERID(number)}:${fromext})})
exten = *90,n,Wait(1)
exten = *90,n,(startread),Playback(ent-target-attendant)
exten = *90,n,Read(toext,then-press-pound)
exten = *90,n,GotoIf($["foo${toext}"="foo"]?startread)
exten = *90,n,Wait(1)
exten = *90,n,Set(DB(CPCFB/${fromext})=${toext})
exten = *90,n,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,Set(DB(CPCFB/${CALLERID(number)})=${EXTEN:3})
exten = _*90.,n,Playback(call-fwd-on-busy&for&extension)
exten = _*90.,n,SayDigits(${CALLERID(number)})
exten = _*90.,n,Playback(is-set-to)
exten = _*90.,n,SayDigits(${EXTEN:3})
exten = _*90.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Customer Programmable Call Forwarding Busy Line (*91 Deactivation)
;Allows subscriber of the feature to forward calls intended for the subscriber's busy line to another directory number entered 
;by the subscriber at the time of activation. Deactivation will clear the forwarded-to directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cpcfbd]
exten = *91,1,Answer
exten = *91,n,Wait(1)
exten = *91,n,dbDel(CPCFB/${CALLERID(number)})
exten = *91,n,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,dbDel(CPCFB/${fromext})
exten = _*91.,n,Playback(cust-call-fwd-on-busy&for&extension)
exten = _*91.,n,SayDigits(${fromext})
exten = _*91.,n,Playback(cancelled)
exten = _*91.,n,Macro(hangupcall)
;
exten = #91,1,Answer
exten = #91,n,Wait(1)
exten = #91,n,Playback(please-enter-your&extension)
exten = #91,n,Read(fromext,then-press-pound)
exten = #91,n,Wait(1)
exten = #91,n,dbDel(CPCFB/${fromext})
exten = #91,n,Playback(cust-call-fwd-on-busy&for&extension)
exten = #91,n,SayDigits(${fromext})
exten = #91,n,Playback(cancelled)
exten = #91,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Customer Programmable Call Forwarding Don't Answer (*92 Activation)
;Allows subscriber of the feature to forward calls intended for the subscriber's idle line, after a predetermined number of rings,
;to another directory number entered by the subscriber at the time of activation. Deactivation will clear the forwarded-to directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cpcfdaa]
exten = *92,1,Answer
exten = *92,n,Wait(1)
exten = *92,n,Playback(cust-pro-call-fwd-no-ans)
exten = *92,n,Playback(please-enter-your&extension)
exten = *92,n,Read(fromext,then-press-pound)
exten = *92,n,Set(fromext=$/{IF($["foo${fromext}"="foo"]?${CALLERID(number)}:${fromext})})
exten = *92,n,Wait(1)
exten = *92,n(startread),Playback(ent-target-attendant)
exten = *92,n,Read(toext,then-press-pound)
exten = *92,n,GotoIf($["foo${toext}"="foo"]?startread)
exten = *92,n,Wait(1)
exten = *92,n,Set(DB(CPCFN/${fromext})=${toext})
exten = *92,n,Playback(call-fwd-no-ans&for&extension)
exten = *92,n,SayDigits(${fromext})
exten = *92,n,Playback(is-set-to)
exten = *92,n,SayDigits(${toext})
exten = *92,n,Macro(hangupcall)
;
exten = _*92.,1,Answer
exten = _*92.,n,Wait(1)
exten = _*92.,n,Set(DB(CPCFNA/${CALLERID(number)})=${EXTEN:3})
exten = _*92.,n,Playback(call-fwd-no-ans&for&extension)
exten = _*92.,n,SayDigits(${CALLERID(number)})
exten = _*92.,n,Playback(is-set-to)
exten = _*92.,n,SayDigits(${EXTEN:3})
exten = _*92.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------------------------------------------------------------
;Customer Programmable Call Forwarding Don't Answer (*93 Deactivation)
;Allows subscriber of the feature to forward calls intended for the subscriber's idle line, after a predetermined number of rings, 
;to another directory number entered by the subscriber at the time of activation. Deactivation will clear the forwarded-to directory number.
;--------------------------------------------------------------------------------------------------------------------------------
[app-cpcfdad]
exten = *93,1,Answer
exten = *93,n,Wait(1)
exten = *93,n,dbDel(CPCFNA/${CALLERID(number)})
exten = *93,n,Playback(call-fwd-no-ans&de-activated)
exten = *93,n,Macro(hangupcall)
;
exten = _*93.,1,Answer
exten = _*93.,n,Wait(1)
exten = _*93.,n,Set(fromext=${EXTEN:3})
exten = _*93.,n,dbDel(CPCFN/${fromext})
exten = _*93.,n,Playback(cust-pro-call-fwd-no-ans&for&extension)
exten = _*93.,n,SayDigits($/{fromext/})
exten = _*93.,n,Playback(cancelled)
exten = _*93.,n,Macro(hangupcall)
;
exten = #93,1,Answer
exten = #93,n,Wait(1)
exten = #93,n,Playback(please-enter-your&extension)
exten = #93,n,Read(fromext,then-press-pound)
exten = #93,n,Wait(1)
exten = #93,n,dbDel(CPCFNA/${fromext})
exten = #93,n,Playback(cust-pro-call-fwd-unconditional&for&extension)
exten = #93,n,SayDigits(${fromext})
exten = #93,n,Playback(cancelled)
exten = #93,n,Macro(hangupcall)
;
;-------------------------------------------------------------------------------
; *95 - Disable VoiceMail on a Line
;-------------------------------------------------------------------------------
[app-vm-disable]
exten = *95,1,Answer
exten = *95,n,DBdel(VM/${CALLERIDNUM})
exten = *95,n,Wait(1)
exten = *95,n,Playback(deactivated)
exten = *95,n,Macro(hangupcall)
;
;-------------------------------------------------------------------------------
; *96 -  Enable VoiceMail on a Line
;-------------------------------------------------------------------------------
[app-vm-enable]
exten = *96,1,Answer
exten = *96,n,Set(DB(VM/${CALLERIDNUM})=YES)
exten = *96,n,Wait(.5)
exten = *96,n,Playback(activated)
exten = *96,n,Macro(hangupcall)
;
;-------------------------------------------------------------------------------
; *97 - *98 Voicemail Checking / Retriving
;-------------------------------------------------------------------------------
[app-voicemail]
exten = *97,1,Answer
exten = *97,n,VoiceMailMain
exten = *97,n,Macro(hangupcall)
;
exten = _*97X.,1,Answer
exten = _*97X.,n,VoiceMailMain(${EXTEN:3})
exten = _*97X.,n,Macro(hangupcall)
;
exten = *98,1,Answer
exten = *98,4,VoicemailMain(${CALLERIDNUM})
exten = *98,5,Macro(hangupcall)
;
;---------------------------------------------------------
; */#100 - */#102 and 611 -Queue Agents Login
; Turn on=*xxx  Turn off=#xxx
;----------------------------------------------------------
[app-agentlogin]
exten = *100,1,AddQueueMember(100|SIP/${CALLERID(NUM)})
exten = *100,n,Playback(agent-loginok)
exten = *100,n,Hangup
exten = #100,1,RemoveQueueMember(100|SIP/${CALLERID(NUM)})
exten = #100,n,Playback(agent-loggedoffok)
exten = #100,n,Hangup
;
exten = *101,1,AddQueueMember(101|SIP/${CALLERID(NUM)})
exten = *101,n,Playback(agent-loginok)
exten = *101,n,Hangup
exten = #101,1,RemoveQueueMember(101|SIP/${CALLERID(NUM)})
exten = #101,n,Playback(agent-loggedoffok)
exten = #101,n,Hangup
;
exten = *102,1,AddQueueMember(102|SIP/${CALLERID(NUM)})
exten = *102,n,Playback(agent-loginok)
exten = *102,n,Hangup
exten = #102,1,RemoveQueueMember(102|SIP/${CALLERID(NUM)})
exten = #102,n,Playback(agent-loggedoffok)
exten = #102,n,Hangup
;
exten = *611,1,AddQueueMember(611|SIP/${CALLERID(NUM)})
exten = *611,n,Playback(agent-loginok)
exten = *611,n,Hangup
exten = #611,1,RemoveQueueMember(611|SIP/${CALLERID(NUM)})
exten = #611,n,Playback(agent-loggedoffok)
exten = #611,n,Hangup
;
;--------------------------------------------------------
;211 Community Information and Referral Services 
; Available for Reassignment
;--------------------------------------------------------
[app-211]
exten = 211,1,Playback(ss-noservice)
exten = 211,n,Congestion
exten = 211,n,Macro(hangupcall)
;
;-------------------------------------------
;311 - non-emerg not yet setup for Non Emerg
;-------------------------------------------
[app-311]
;exten = 311,1,Dial(LOCAL/local non emergancy nmbr here)
;exten = 311,n,Congestion
exten = 311,1,Playback(ss-noservice)
exten = 311,n,Congestion
exten = 311,n,Macro(hangupcall)
;
;---------------------------
; 411 - Information services
;---------------------------
[app-411]
;exten = 411,1,Dial(Local/SIP/ZAP/IAX2/411,30,r)
;exten = 411,n,Congestion
exten = 411,n,Playback(ss-noservice)
exten = 411,n,Congestion
exten = 411,n,Macro(hangupcall)
;
exten = *411,1,Answer
exten = *411,n,Wait(1)
exten = *411,n,Goto(pbdirectory,1)
exten = pbdirectory,1,AGI(pbdirectory)
exten = pbdirectory,n,GotoIf($["${dialnumber}"=""]?hangup,1)
exten = pbdirectory,n,Noop(Got number to dial: ${dialnumber})
exten = pbdirectory,n,Dial(Local/${dialnumber}@/n)
exten = hangup,1,Hangup
;
;exten = #,1,Answer
;exten = #,n,Wait(1)
;exten = #,n,AGI(directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS})
;exten = #,n,Playback(vm-goodbye)
;exten = #,n,Hangup
;exten = i,1,Playback(privacy-incorrect)
;
;---------------------------------------------------------------------------
; Create an extension, 500, for dialing the
; Digium Asterisk demo.
;---------------------------------------------------------------------------
[app-demo]
exten = 500,1,Playback(demo-abouttotry)  ; Let them know what's going on
exten = 500,n,Dial(IAX2/guest@misery.digium.com/s@default)  ; Call the Asterisk demo
exten = 500,n,Playback(demo-nogo)  ; Couldn't connect to the demo site
exten = 500,n,Goto(s,6)  ; Return to the start over message.
;
;------------------------------------
; 501 asterisk conf
;------------------------------------
[app-astconf]
exten = 501,1,Dial(SIP/sip:123@66.212.134.192,60,D(${MY_SHOW}#${MY_PIN}#))
exten = 501,n,Macro(hangupcall)
;
;---------------------------------------------------------------------------
;511 Traffic and Transportation Information (US); Available for Reassignment
;---------------------------------------------------------------------------
[app-511]
exten = 511,1,Answer
exten = 511,n,Playback(ss-noservice)
exten = 511,n,Macro(hangupcall)
;
;-------------------------------------
; 611 - [Repair Service / TechSupport]
; I used US holidays but you can edit it to use you countries holidays
;-------------------------------------
[app-611]
exten = 611,1,Goto(us-holiday-timerules,s,1)
exten = 611,n(CLOSED),Playback(office-closed&our-business-hours-are&office-hours)
exten = 611,n,Voicemail(u611)
exten = 611,n,Macro(hangupcall)
exten = 611,n(START),GotoIfTime(22:00-08:00|*|*|*?611|CLOSED)
exten = 611,n,Set(TIMEOUT(digit)=7)
exten = 611,n,Set(TIMEOUT(response)=10)
exten = 611,n,SayDigits(611)
exten = 611,n,Playback(repair&and&technical-support&for-quality-purposes&this-call-may-be&recorded)
exten = 611,n(ID),Playback(pls-enter-your-acct-nbr)
exten = 611,n,Read(acct,then-press-pound)
exten = 611,n,SayDigits(${acct})
exten = 611,n,Background(if-correct-press)
exten = 611,n,SayDigits(1)
exten = 611,n,Background(if-incorrect-press)
exten = 611,n,SayDigits(2)
exten = 611,n,Read(res,then-press-pound)
exten = 611,n,GotoIf($["${res}"="1"]?ACCT:ID)
exten = 611,n(ACCT),Set(CALLERID(name)=${CALLERIDNAME})
exten = 611,n,Set(CALLERID(number)=${acct})
exten = 611,n,Set(MONITOR_FILENAME=/var/spool/asterisk/monitor/q${EXTEN}-${TIMESTAMP}-${UNIQUEID})
exten = 611,n,SetMusicOnHold(default)
exten = 611,n,GotoIfTime(08:00-17:00|mon-fri|*|*?611|DAY)
exten = 611,n,GotoIfTime(17:00-22:00|mon-fri|*|*?611|NIGHT)
exten = 611,n,GotoIfTime(09:00-13:00|sat|*|*?611|NIGHT)
exten = 611,n,Goto(611,closed)
exten = 611,n(DAY),Queue(611|t|||300)
exten = 611,n(VM),Voicemail(u611)
exten = 611,n,Macro(hangupcall)
exten = 611,n(NIGHT),Queue(611|t|||300)
exten = 611,n,Goto(611,VM)
;
;----------------------------------------------------------------------------------------
;Call Parking
;----------------------------------------------------------------------------------------
[app-parking]
exten = 700,1,Answer
exten = 700,n,SetMusicOnHold(default)
exten = 700,n,ParkAndAnnounce(PARKED|60|SIP/${EXTEN}|70|4)
exten = _70X,1,ParkedCall(${EXTEN})
;
;----------------------------------------------------------------------------------------
;711 is the national number to access relay services from anywhere in the United States. 
;Dial 711 to be connected with a Relay Colorado operator.
;----------------------------------------------------------------------------------------
; 711 - [State Relay TTY/TDD/Voice Service]
;------------------------------------------
[app-tty-relay]
;exten = 711,1,Dial(SIP/711)
;exten = 711,n,Congestion
exten = 711,1,Playback(ss-noservice)
exten = 711,n,Congestion
exten = 711,n,Macro(hangupcall)
;
;-----------------------------------------------------------------------------
;Access to One Call Services to Protect Pipeline and Utilities from Excavation
;Damage (US); Available for Reassignment
;-----------------------------------------------------------------------------
[app-ocsppued]
;exten = 811,1,Dial(Zap or SIP or IAX2/user@${provider}/811,30,r)
;exten = 811,n,Congestion
exten = 811,1,Playback(ss-noservice)
exten = 811,n,Congestion
exten = 811,n,Macro(hangupcall)
exten = 811,n,Hangup
;
;---------------------------------------------
; 911 Emergancy 
;---------------------------------------------
[app-911]
;exten = 911,1,Dial(Zap/1/911)
;exten = 911,n,Congestion
exten = 911,1,Playback(no-911-1)
exten = 911,n,Congestion
exten = 911,n,Macro(hangupcall)
;
;--------------------------------------------------
;Basic Queue macro Sales / Billing / Technical Support
;--------------------------------------------------
[basic-queues]
exten = 100,1(sales),Playback(sales&for-quality-purposes&this-call-may-be-monitored-or-recorded)
exten = 100,n,Goto(macro-basic-queues,s,1)
exten = 101,n(billing),Playback(billing&for-quality-purposes&this-call-may-be-monitored-or-recorded)
exten = 101,n Goto(macro-basic-queues,s,1)
exten = 102,n(techsupport),Playback(technical-support&for-quality-purposes&this-call-may-be-monitored-or-recorded)
exten = 102,n Goto(macro-basic-queues,s,1)
;
[macro-basic-queues]
;Sales/billing/techsupport
exten = s,1,GotoIf($["${CONTEXT}"="from-internal"]?USERCID:SETCID)
exten = s,n(USERCID),Macro(user-callerid,)
exten = s,n(SETCID),Set(CALLERID(name)=${CALLERIDNAME})
exten = s,n(ID),Playback(pls-enter-account)
exten = s,n,Read(acct,then-press-pound)
exten = s,n,SayDigits(${acct})
exten = s,n,Background(if-this-is-correct-press)
exten = s,n,SayDigits(1)
exten = s,n,Background(if-this-is-incorrect-press)
exten = s,n,SayDigits(2)
exten = s,n,Read(res,then-press-pound,)
exten = s,n,GotoIf($["${res}"="1"]?ACCT:ID)
exten = s,n(ACCT),Set(CALLERID(number)=${acct})
exten = s,n,Set(MONITOR_FILENAME=/var/spool/asterisk/monitor/qs-${TIMESTAMP}-${UNIQUEID})
exten = s,n,Queue(${EXTEN}|t|||300)
exten = s,n,Voicemail(u${EXTEN})
;------------------------------------------------------------------------------
; Macros used by Vertical Service Codes & System
;------------------------------------------------------------------------------
[macro-user-unavail]; Used for exten without voicemail.
exten = s,1,Playback(the-party-you-are-calling)
exten = s,2,Playback(is-curntly-unavail)
exten = s,3,Playback(pls-try-call-later)
exten = s,4,Playback(goodbye)
exten = s,5,Hangup
;
[macro-caller-id];Checks the status of inbound CallerID and directs the call.
exten = s,1,System(test "${CALLERIDNAME}" = "O")
exten = s,2,GotoIf($[${CALLERIDNUM} = O]?3:102)
exten = s,3,SetCallerIDName("No Caller ID")
exten = s,4,Macro(no-callerid,s,1)  ;Sends Callers with no id to no-callerid macro below.
exten = s,102,Macro(std-exten,s,12)  ;landing point with caller id
;
[macro-no-callerid]
exten = s,1,Answer
exten = s,2,Playback(no-callerid)
exten = s,3,Playback(vm-goodbye)
exten = s,4,Congestion
exten = s,5,Hangup
;
; What to do on hangup.
[macro-hangupcall]
exten = s,1,ResetCDR(w)
exten = s,2,NoCDR()
exten = s,3,Wait(5)
exten = s,4,Hangup
;
; Outgoing channel(s) are busy ... inform the client
;
[macro-busy]
exten = s,1,Playback(all-circuits-busy-now)
exten = s,2,Playback(pls-try-call-later)
exten = s,3,Macro(hangupcall)
;
[macro-fixcid]
exten = s,1,SetCIDName(${CALLERIDNAME})

[macro-invalid]
exten = i,1,Answer
exten = i,2,Playback(the-number-u-dialed,noanswer)
exten = i,3,SayDigits(${ARG1})
exten = i,4,Playback(not-yet-assigned,noanswer)
exten = i,5,Congestion
exten = i,6,Hangup

[macro-unavail-novm]
exten = s,1,Playback(the-party-you-are-calling)
exten = s,2,Playback(is-curntly-unavail)
exten = s,3,Playback(pls-try-call-later)
exten = s,4,Playback(goodbye)
exten = s,5,Hangup

[macro-fastCongestion]; I use this to send people I dont want to deal with
exten = s,1,Answer
exten = s,2,Wait 1
exten = s,3,Playback(all-circuits-Congestion)
exten = s,4,Wait(30)
exten = s,5,Hangup

;sets the callerid of the device to that of the logged in user
[macro-user-callerid]
exten => s,1,Noop(user-callerid: ${CALLERID(name)} ${CALLERID(number)})
exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?report)
exten => s,n,GotoIf($["${REALCALLERIDNUM:1:2}" != ""]?start)
exten => s,n,Set(REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),NoOp(REALCALLERIDNUM is ${REALCALLERIDNUM})
exten => s,n,Set(USER=${DB(SIP/${REALCALLERIDNUM}/user)})
exten => s,n,Set(USERCIDNAME=${DB(USER/${USER}/cidname)})
exten => s,n,GotoIf($["x${USERCIDNAME:1:2}" = "x"]?report)
exten => s,n,Set(CALLERID(all)=${USERCIDNAME} <${USER}>)
exten => s,n,Set(REALCALLERIDNUM=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n(report),Noop(TTL: ${TTL} ARG1: ${ARG1})
exten => s,n,GotoIf($[ "${ARG1}" = "SKIPTTL" ]?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})  ; wait for a while, to give it a chance to be picked up by voicemail
exten => s,n,Answer()
exten => s,n,Wait(2)
exten => s,n,Playback(im-sorry&an-error-has-occured&with&call-forwarding)
exten => s,n,Macro(hangupcall)
exten => s,n,Congestion()
exten => s,n(continue),NoOp(Using CallerID ${CALLERID(all)})
exten => h,1,Macro(hangupcall)

;
[macro-add-caller-id]
exten = s,1,Answer
exten = s,2,Read(EXTENSION|enter-extension-num|4)
exten = s,3,Read(DIALCID|enter-new-outbound-cid|10)
exten = s,4,Set(${DB(CID/${EXTENSION}=${DIALCID})})
exten = s,5,Saydigits(${EXTENSION})
exten = s,6,Playback(has-been-set-to)
exten = s,7,Saydigits(${DIALCID})
exten = s,8,Playback(auth-thankyou)
exten = s,9,Set(AGAIN=0)
exten = s,10,Read(AGAIN|enter-another-value|1)  ; one for yes, any other num;
exten = s,11,GotoIf($[${AGAIN} = 1]?2:12)
exten = s,12,Playback(goodbye)
exten = s,13,Hangup()
;
[macro-fax]
exten = s,1,Macro(faxreceive)  ; requires fax addon and spandsp
exten = h,1,System(/var/lib/asterisk/scripts/fax.sh "${CALLERIDNUM}" "${CALLEDFAX}" "${EXTNAME}" "${EXTEMAIL}" "${FAXFILE}")
;
[macro-faxreceive]
exten = s,1,Set(FAXFILE=/var/spool/asterisk/fax/${CALLEDFAX}/${UNIQUEID})
exten = s,2,Set(${DB(EXTEMAIL=${MACRO_EXTEN}/xEmail)})  ;
exten = s,3,NoOP()
exten = s,4,Set(${DB(EXTNAME=${MACRO_EXTEN}/xName)})
exten = s,5,NoOP()
exten = s,6,Set($DB(EXTCOMPANY=${MACRO_EXTEN}/xCompany)})
exten = s,7,rxfax(${FAXFILE}.tif)
exten = s,103,Set(EXTMAIL=fax@company.com)
exten = s,104,Goto(7)
exten = s,105,Set(EXTNAME=Unknown)
exten = s,106,Goto(7)
exten = s,107,Set(EXTCOMPANY=Company)
exten = s,108,Goto(7)
;
[macro-festival]; Requiers festival to be installed and configured 
exten = s,1,Answer
exten = s,2,Festival('')
exten = s,3,Hangup
;
[macro-record-on]
exten = s,1,AGI(set-timestampagi)
exten = s,2,Set(CALLFILENAME=${timestamp}-${ARG2}-${ARG1})
exten = s,3,Monitor(gsm,${CALLFILENAME})
;
[macro-record-cleanup]
exten = s,1,GotoIf($[${CALLFILENAME} = ${NULL}]?6:2)
exten = s,2,Set(CFBASE=/var/spool/asterisk/monitor/${CALLFILENAME})
; wmix takes the two seperate wavs and mixes them into a single stream
; It is available in my wavetools rpm
exten = s,3,System(/usr/bin/wmix ${CFBASE}-inwav ${CFBASE}-outwav > ${CFBASE})
exten = s,4,System(/bin/rm ${CFBASE}-inwav ${CFBASE}-outwav)
; toast compresses the wav files into a gsm file
; It is available in my gsm rpm
exten = s,5,System(/usr/bin/toast -F ${CFBASE})
exten = s,6,NoOp
;
;---------------------------------------------------------------------
;Pulled From Freepbx.
; This macro is for dev purposes and just dumps channel/app variables.
; Useful when designing new contexts.
;---------------------------------------------------------------------
[macro-dumpvars]
exten = s,1,Noop(ACCOUNTCODE=${ACCOUNTCODE})
exten = s,2,Noop(ANSWEREDTIME=${ANSWEREDTIME})
exten = s,3,Noop(BLINDTRANSFER=${BLINDTRANSFER})
exten = s,4,Noop(CALLERID=${CALLERID})
exten = s,5,Noop(CALLERIDNAME=${CALLERIDNAME})
exten = s,6,Noop(CALLERIDNUM=${CALLERIDNUM})
exten = s,7,Noop(CALLINGPRES=${CALLINGPRES})
exten = s,8,Noop(CHANNEL=${CHANNEL})
exten = s,9,Noop(CONTEXT=${CONTEXT})
exten = s,10,Noop(DATETIME=${DATETIME})
exten = s,11,Noop(DIALEDPEERNAME=${DIALEDPEERNAME})
exten = s,12,Noop(DIALEDPEERNUMBER=${DIALEDPEERNUMBER})
exten = s,13,Noop(DIALEDTIME=${DIALEDTIME})
exten = s,14,Noop(DIALSTATUS=${DIALSTATUS})
exten = s,15,Noop(DNID=${DNID})
exten = s,16,Noop(EPOCH=${EPOCH})
exten = s,17,Noop(EXTEN=${EXTEN})
exten = s,18,Noop(HANGUPCAUSE=${HANGUPCAUSE})
exten = s,19,Noop(INVALID_EXTEN=${INVALID_EXTEN})
exten = s,20,Noop(LANGUAGE=${LANGUAGE})
exten = s,21,Noop(MEETMESECS=${MEETMESECS})
exten = s,22,Noop(PRIORITY=${PRIORITY})
exten = s,23,Noop(RDNIS=${RDNIS})
exten = s,24,Noop(SIPDOMAIN=${SIPDOMAIN})
exten = s,25,Noop(SIP_CODEC=${SIP_CODEC})
exten = s,26,Noop(SIPCALLID=${SIPCALLID})
exten = s,27,Noop(SIPUSERAGENT=${SIPUSERAGENT})
exten = s,28,Noop(TIMESTAMP=${TIMESTAMP})
exten = s,29,Noop(TXTCIDNAME=${TXTCIDNAME})
exten = s,30,Noop(UNIQUEID=${UNIQUEID})
exten = s,31,Noop(TOUCH_MONITOR=${TOUCH_MONITOR})
exten = s,32,Noop(MACRO_CONTEXT=${MACRO_CONTEXT})
exten = s,33,Noop(MACRO_EXTEN=${MACRO_EXTEN})
exten = s,34,Noop(MACRO_PRIORITY=${MACRO_PRIORITY})
;
;------------------------------------------------------------------------
; This is where all calls go that don't have any other destination provided
;------------------------------------------------------------------------
[invalid-number]
exten = _s.,1,Wait(1)
exten = _s.,n,Playback(silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer)
exten = _s.,n,Wait(1)
exten = _s.,n,Congestion(20)
exten = _s.,n,Hangup()
;
[invalid-feature]
exten = _s.,1,Wait(1)
exten = _s.,n,Playback(silence/1&feature-not-avail-line&silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer)
exten = _s.,n,Wait(1)
exten = _s.,n,Congestion(20)
exten = _s.,n,Macro(hangupcall)
;
;--------------------------------------------------------------------------
;Applications
;--------------------------------------------------------------------------
[app-blackhole]
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,Answer
exten = congestion,n,Playtones(congestion)
exten = congestion,n,Congestion(20)
exten = congestion,n,Hangup
exten = busy,1,Noop(Blackhole Dest: Busy)
exten = busy,n,Answer
exten = busy,n,Playtones(busy)
exten = busy,n,Busy(20)
exten = busy,n,Hangup
;
;------------------------------------------------------------
; Disa using voicemail passowords via agi
;------------------------------------------------------------
[app-disa]
;exten = s,1,Macro(user-callerid,)
exten = s,1,Set(LOOPCOUNT=0)
exten = s,n,Answer
exten = s,n,Wait(1)
exten = s,n(begin),Set(TIMEOUT(digit)=7)
exten = s,n,Set(TIMEOUT(response)=10)
exten = s,n,Playback(please-enter-the&extension)
exten = s,n,Read(ext_num,then-press-pound,,)
exten = s,n,Wait(1)
exten = s,n,Playback(pls-enter-vm-password)
exten = s,n,Read(ext_pwd,then-press-pound,,)
exten = s,n,Wait(1)
exten = s,n,AGI(chk_vm_pwd.agi|/etc/asterisk/voicemail.conf|${ext_num}|${ext_pwd})
exten = s,n,GotoIf($["${result}" = "0"]?custom-disa,s,D:custom-disa,i,1)
exten = s,n,Set(CALLERIDNUM=${ext_num})
exten = s,n(D),DISA(no-password|from-internal)
exten = h,1,Hangup
exten = i,1,Playback(invalid)
exten = i,n,Goto(loop,1)
exten = t,1,Goto(loop,1)
exten = loop,1,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten = loop,n,GotoIf($[${LOOPCOUNT} > 2]?hang,1)
exten = loop,n,Goto(custom-disa,s,begin)
exten = hang,1,Playback(vm-goodbye)
exten = hang,n,Hangup
;
;----------------------------------------------------------------
; Make a wish Hotline for Special Kids in Need...
;----------------------------------------------------------------
[make-a-wish]
;exten = NXXXXXX,1,Goto(app-wish-record,s,1)
;exten = NXXXXXX,1,Goto(app-wish-playback,s,1)
;
[app-wish-record]
exten = s,1,Ringing
exten = s,2,Wait(4)
exten = s,3,Answer
exten = s,4,Playback(wish-welcome)
exten = s,5,Set(${DB(MessageCount=wish/${CALLERIDNUM})})
exten = s,6,Set(${DB(MessageCount=$[${MessageCount} + 1])})
exten = s,7,Set(${DB(wish/${CALLERIDNUM}=${MessageCount})})
exten = s,8,Record(wish/${CALLERIDNUM}-${MessageCount}:ulaw|10|60)
exten = s,9,Playback(wish-done)
exten = s,10,Hangup
exten = s,106,Set(${DB(MessageCount=1)})
exten = s,107,Goto(s,7)
;
[app-wish-playback]
exten = s,1,Ringing
exten = s,2,Wait(4)
exten = s,3,Answer
exten = s,4,Set(${DB(MessageCount=wish/${CALLERIDNUM})})
exten = s,5,Set(${DB(CurrentMessage=1)})
exten = s,6,Playback(wish-recorded)
exten = s,7,Playback(wish/${CALLERIDNUM}-${CurrentMessage})
exten = s,8,Set(${DB(CurrentMessage=$[${CurrentMessage} + 1])})
exten = s,9,GotoIf(${DB([${CurrentMessage}  ${MessageCount}]?12:10)})
exten = s,10,Playback(beep)
exten = s,11,Goto(s,7)
exten = s,12,Playback(wish-goodbye)
exten = s,13,Hangup
exten = s,105,Playback(wish-notrecorded)
exten = s,106,Hangup
;
; Pront recording and and special prompt recording + enable disable
;-------------------------------------------------------------------------------
[prompts]
exten = *00*,1,Goto(prompt-management,s,1)
exten = *01*,1,Goto(special-message,s,1)
;-----------------------------------------------------
; Prompt management used for IVR prompt recording.
;-----------------------------------------------------
; Flexible prompt recording
;-----------------------------------------------------
[prompt-management]
;
exten = s,1,Answer
exten = s,n,Wait(1)
exten = s,n,DigitTimeout(5)
exten = s,n,Read(PROMPT_NUMBER|enter-prompt-number|3)
exten = s,n,SayDigits(${PROMPT_NUMBER})
exten = s,n,BackGround(T-to-hear-cur-ancmnt)
exten = s,n,BackGround(press-1)
exten = s,n,BackGround(T-to-rec-ancmnt)
exten = s,n,BackGround(press-2)
;
exten = t,1,Playback(goodbye)
exten = t,n,Hangup
;
exten = i,1,Playback(pbx-invalid)
exten = i,n,Goto(s,5)
;
exten = 1,1,Playback(beep)
exten = 1,n,Playback(bsky-prompt-${PROMPT_NUMBER})
exten = 1,n,Playback(beep)
exten = 1,n,Goto(s,6)
;
exten = 2,1,Goto(prompt-management-record,s,1)
exten = **,1,Playback(goodbye)
exten = **,n,Hangup
;
[prompt-management-record]
; New prompt recording
exten = s,1,Playback(vm-intro)
exten = s,n,Record(tmp-newprompt:wav)
exten = s,n,Playback(beep)
exten = s,n,BackGround(tmp-newprompt)
exten = s,n,BackGround(save-announce-press)
exten = s,n,BackGround(digits/1)
exten = s,n,BackGround(to-rerecord-announce)
exten = s,n,BackGround(digits/2)
;
exten = i,1,Playback(invalid)
exten = i,n,Goto(s,3)
;
exten = t,1,Goto(s,3)
;
exten = 1,1,System(cp -f /var/lib/asterisk/sounds/tmp-newprompt.wav /var/lib/asterisk/sounds/prompt-${PROMPT_NUMBER}.wav)
exten = 1,n,Playback(your-msg-has-been-saved)
exten = 1,n,Goto(app-prompt-management,s,4)
;
exten = 2,1,Goto(s,1)
;
exten = *,1,Goto(app-prompt-management,s,4)
;
;-------------------------------------------------------
; Special announcement admin (Easy IVR)
;-------------------------------------------------------
; Record/replay/turn on/off the special message
; played before ACD queue calls
;-------------------------------------------------------
[special-message]
;
exten = s,1,Answer
exten = s,n,Wait(1)
exten = s,n,DigitTimeout(5)
exten = s,n,BackGround(T-to-hear-cur-ancmnt)
exten = s,n,BackGround(press-1)
exten = s,n,BackGround(T-to-rec-ancmnt)
exten = s,n,BackGround(press-2)
exten = s,n,BackGround(T-to-enable-ancmnt)
exten = s,n,BackGround(press-3)
exten = s,n,BackGround(T-to-disable-ancmnt)
exten = s,n,BackGround(press-4)
;
exten = t,1,Playback(goodbye)
exten = t,2,Hangup
;
exten = i,1,Playback(pbx-invalid)
exten = i,2,Goto(s,4)
;
exten = 1,1,Playback(special-message)
exten = 1,2,Goto(s,4)
;
exten = 2,1,Goto(special-message-record,s,1)
;
exten = 3,1,Set($DB(SpecialMessage/1=1)})
exten = 3,n,Playback(enabled)
exten = 3,n,Goto(s,4)
;
exten = 4,1,DBdel(SpecialMessage/1)
exten = 4,n,Playback(disabled)
exten = 4,n,Goto(s,4)
;
exten = *,1,Playback(goodbye)
exten = *,2,Hangup
;
[special-message-record]
; Record the new special message
exten = s,1,Playback(vm-intro)
exten = s,n,Record(new-special-message:wav)
exten = s,n,Playback(beep)
exten = s,n,BackGround(new-special-message)
exten = s,n,BackGround(save-announce-press)
exten = s,n,BackGround(digits/1)
exten = s,n,BackGround(to-rerecord-announce)
exten = s,n,BackGround(digits/2)
exten = i,1,Playback(invalid)
exten = i,n,Goto(s,3)
;
exten = t,1,Goto(s,3)
;
exten = 1,1,System(cp -f /var/lib/asterisk/sounds/new-special-message.wav /var/lib/asterisk/sounds/special-message.wav)
exten = 1,n,Playback(your-msg-has-been-saved)
exten = 1,n,Goto(app-special-message,s,1)
;
exten = 2,1,Goto(s,1)
;
exten = *,1,Goto(special-message,s,1)
;
[macro-check-special-message]
; If the flag is set, play the special message, otherwise continue
exten = s,1,Set(${DB(SpecialMessage=SpecialMessage/1)})
exten = s,2,Playback(system-status-msg)
exten = s,3,Playback(special-message)
exten = s,4,Ringing
exten = s,5,Wait(4)
exten = s,102,Noop
;
;----------------------------------------------------------------------------------
; Start Dundi-e164 Setup
;----------------------------------------------------------------------------------
;[dundi-e164-customers]
;
; If you are an ITSP or Reseller, list your customers here
;
;exten = _12564286000,1,Dial(SIP/customer1)
;exten = _12564286001,1,Dial(IAX2/customer2)
;
;[dundi-e164-via-pstn]
;
; If you are freely delivering calls to the PSTN, list them here
;
;exten = _1256428XXXX,1,Dial(Zap/g2/${EXTEN:7}) ; Expose all of 256-428
;exten = _1256325XXXX,1,Dial(Zap/g2/${EXTEN:7}) ; Ditto for 256-325
;
;[dundi-e164-local]
;
; Context to put your dundi IAX2 or SIP user in for
; full access
;
;include = dundi-e164-canonical
;include = dundi-e164-customers
;include = dundi-e164-via-pstn
;
;[dundi-e164-switch]
;
; Just a wrapper for the switch
;
;switch = DUNDi/e164
;
;[dundi-e164-lookup]
;
; Locally to lookup, try looking for a local E164 solution
; then try DUNDi if we don't have one
;
;include = dundi-e164-local
;include = dundi-e164-switch
;
; DUNDi can also be implemented as a Macro instead of using
; the Local channel driver
;
;[macro-dundi-e164]
;
; ARG1 is the extension to Dial
;
;exten = s,1,Goto(${ARG1},1)
;include = dundi-e164-lookup
;
;---------------------------------------------------------
; enum lookup serveice
;----------------------------------------------------------
;[Enum164e]
; Home telephone from E164org lookup
;exten = 15552556690,1,Dial(${HOMEPHONES},20)
;exten = 15552556690,2,Voicemail2(u44)
;exten = 15552556690,3,HangUp
;
; Business Line from E164org lookup
;exten = 15552553925,1,Dial(${WORKPHONES},20)
;exten = 15552553925,2,Voicemail(u21)
;exten = 15552553925,3,HangUp
;
;[internal]
;exten = _XXXNXXXXXX,1,Macro(enum-call,localcall,1${EXTEN})
;exten = _1604NXXXXXX,1,Macro(enum-call,localcall,${EXTEN})
;exten = _011XXXXNXXXXXX,1,Macro(enum-call,localcall,${EXTEN:3})
;exten = _0111NXXNXXXXXX,1,Macro(enum-call,NA,${EXTEN:3})
;exten = _NXXNXXXXXX,1,Prefix(1)
;exten = _1NXXNXXXXXX,1,Macro(enum-call,NA,${EXTEN})
;exten = _011X,1,Macro(enum-call,international,${EXTEN:3})
;
;[macro-enum-call]
;exten = s,1,SetCallerID(1XXX5551212)
;exten = s,2,EnumLookup(${ARG2})
;exten = s,53,Goto(${ARG1},${ARG2},1)
;exten = s,103,Goto(${ARG1},${ARG2},1)
;exten = s,3,GotoIf($[$[${ENUM:0:3} = SIP] | $[${ENUM:0:3} = IAX]]?4:5)
;exten = s,4,Dial(${ENUM})
;exten = s,5,Goto(${ARG1},${ARG2},1)
;exten = s,105,Goto(${ARG1},${ARG2},1)
;
;--------------------------------------------
;Gui-Tools
;--------------------------------------------
[asterisk_guitools]
exten = executecommand,1,System(${command})
exten = executecommand,n,Hangup()
exten = record_vmenu,1,Answer
exten = record_vmenu,n,Playback(vm-intro)
exten = record_vmenu,n,Record(${var1})
exten = record_vmenu,n,Playback(vm-saved)
exten = record_vmenu,n,Playback(vm-goodbye)
exten = record_vmenu,n,Hangup
exten = play_file,1,Answer
exten = play_file,n,Playback(${var1})
exten = play_file,n,Hangup
hasbeensetup = Y
;
;---------------------------------------
[all-apps]
include = app-directory
include = app-pickup
include = app-echo
include = app-milliwatt
include = app-moh
include = app-clock  ; repeates time.
include = app-wakeup
include = app-weather
include = app-jobs-postings
include = app-ext-intercom
include = app-enable-intercom
include = app-disable-intercom
include = app-chanspy
include = app-application-status
include = blacklist
include = app-dictate-record
include = app-dictate-send
include = app-cpcfd
include = app-cpcfda
include = app-dnd-overide
include = app-whocall
include = app-scra
include = app-scw
include = app-scfa
include = app-scaa
include = app-cnda
include = app-cndd
include = app-cfbdaa
include = app-lcr
include = app-cwa
include = app-cwd
include = app-cfa
include = app-cfd
include = app-acwdd
include = app-acra
include = app-dnda
include = app-dndd
include = app-scrd
include = app-scfd
include = app-scad
include = app-cidbd
include = app-acrd
include = app-cfbdad
include = app-cpcfba
include = app-cpcfbd
include = app-cpcfdaa
include = app-cpcfdad
include = app-vm-disable
include = app-vm-enable
include = app-voicemail
include = app-agentlogin
include = app-211
include = app-311
include = app-411
include = app-demo
include = app-astconf
include = app-511
include = app-611
include = app-parking
include = app-tty-relay
include = app-ocsppued
include = app-911
include = app-blackhole
include = app-disa
include = app-wish-record
include = app-wish-playback
;-----------------------------------------------------
;add by gui
;-----------------------------------------------------
[default]
include = all-apps
;
[DID_fwddialup]
include = default
exten = _X.,1,Goto(default|1000|1)
exten = s,1,Goto(default|1000|1)
;
[DID_sipphone]
include = default
exten = _X.,1,Goto(default|1000|1)
exten = s,1,Goto(default|1000|1)
;
[numberplan-custom-1]
plancomment = DialPlan1
include = default
;
exten = _#6.,1,Macro(trunkdial,${fwddialup}/${EXTEN:2})
comment = _#6.,1,fwddialup-out,custom
;
exten = 1747NXXXXXX,1,Macro(trunkdial,${sipphone}/${EXTEN:0})
comment = 1747NXXXXXX,1,sipphone-out,custom
exten = 1800NXXXXXX,1,Macro(trunkdial,${sipphone}/${EXTEN:0})
comment = 1800NXXXXXX,1,sipphone-out,custom
exten = 1866NXXXXXX,1,Macro(trunkdial,${sipphone}/${EXTEN:0})
comment = 1866NXXXXXX,1,sipphone-out,custom
exten = 1877NXXXXXX,1,Macro(trunkdial,${sipphone}/${EXTEN:0})
comment = 1877NXXXXXX,1,sipphone-out,custom
exten = 1888NXXXXXX,1,Macro(trunkdial,${sipphone}/${EXTEN:0})
comment = 1888NXXXXXX,1,sipphone-out,custom