; Static extension configuration file, used by
; the pbx_config module. This is where you configure all your
; inbound and outbound calls in Asterisk.
;

; This particular file (C) 2004-2005 Michael Loftis <mloftis@wgops.com>
;
; This is what (should) be a working example.  It's *VERY* close
; to what I'm using in production, I've edited and changed the 
; actual extension numbers though  and haven't tested it since I
; did that, but it should be right.
;
; You'll probably notice mentions of modwest in the VM prompts or something
; they are my employer.  Much of what you see here is being used every day
; by a small office of 10 people.
;
; verticals may be interesting, and they've not been converted to my 
; agent system.  The stdexten was also not yet converted, i initially
; got that code from somewhere else, but its soooo far from what that was
; it's not the same code.  I also have no clue at this moment where i got
; it.  if it's yours please tell me I'll credit ya!
;
; include the macro's for doing agents via dialplans...
#include agent-dialplan.conf

;
; The "General" category is for certain variables.
;
[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=yes

[globals]
CONSOLE=Zap/24
TRUNK=Zap/G1
TRUNKMSD=1

; Dialplan Agent stuff..
AGDB=Agent
AGAUTHSAY=agent-user


; this macro does setup for the outbound callerid, called by all
; of the outbound contexts

[macro-outboundCID]
; We load it from the agent information.
; Remember, AgentGetVar also finds a default for us too!
exten => s,1,Macro(AgentGetVar,OUTCID,${CALLERIDNUM})
exten => s,2,SetCIDNum(${AGENTVAR})

; Context definitions for outbound dialling...

; international trunk dialing.
[trunkint]
exten => _9011.,1,Macro(outboundCID)
exten => _9011.,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _9011.,3,Congestion

; LD trunk dialing.
[trunkld]
exten => _91NXXNXXXXXX,1,Macro(outboundCID)
exten => _91NXXNXXXXXX,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91NXXNXXXXXX,3,Congestion

; this is the specialty 'what is my LD carrier?' number
exten => 917005554141,1,Macro(outboundCID)
exten => 917005554141,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => 917005554141,3,Congestion

; Local trunk dialing.
[trunklocal]
exten => _9NXXXXXX,1,Macro(outboundCID)
exten => _9NXXXXXX,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _9NXXXXXX,3,Congestion

; Toll free lines routed via trunk.
[trunktollfree]
exten => _91800NXXXXXX,1,Macro(outboundCID)
exten => _91800NXXXXXX,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91800NXXXXXX,3,Congestion

exten => _91888NXXXXXX,1,Macro(outboundCID)
exten => _91888NXXXXXX,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91888NXXXXXX,3,Congestion

exten => _91877NXXXXXX,1,Macro(outboundCID)
exten => _91877NXXXXXX,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91877NXXXXXX,3,Congestion

exten => _91866NXXXXXX,1,Macro(outboundCID)
exten => _91866NXXXXXX,2,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91866NXXXXXX,3,Congestion

; build up of dialing, international being most privileged
; inside being least.

; international->longdistance->local->inside

; Master context for international long distance includes long distance...
[international]
ignorepat => 9
include => longdistance
include => trunkint

; Context for dialing long distance implicitly includes local..
[longdistance]
ignorepat => 9
include => local
include => trunkld

; Local context allows us to dial out locally
[local]
ignorepat => 9
include => inside
include => trunklocal
include => trunktollfree

[inside]
ignorepat => 9
include => extens
include => services
include => default


; extens exists so that we can include extensions in common places.
; see from-pri and from-sip!
; note that these are for *REMOTE* applications, IE these are DIDs.
; non-did services go in the services context here.
;
[extens]

; Example DISA application utilising the Agent system for 'common' 
; authentication.

exten => 6179,1,Ringing
exten => 6179,2,Wait(2)
exten => 6179,3,DigitTimeout(10)
exten => 6179,4,ResponseTimeout(10)
; The below makes sure we hang up our PRI with a normal code...
exten => 6179,5,SetVar(PRI_CAUSE=16)
exten => 6179,6,Answer
exten => 6179,7,Wait(1)
; Here we log the agent in, or hang up.
exten => 6179,8,Macro(AgentAuth)
exten => 6179,9,Macro(AgentGetSettings,${AGENTIDNUM},0)
exten => 6179,10,ResponseTimeout(${AGENTRTO})
exten => 6179,11,DISA(no-password,from-sip)

; How to log into voice mail.  In the voicemail.conf simply specify a blank 
; for the password and instruct your users NOT to change their VM pass
; via the menu option in there.

exten => 6175,1,Ringing
exten => 6175,2,Wait(2)
exten => 6175,3,Answer
exten => 6175,4,Macro(AgentAuth,,vm-login)
exten => 6175,5,VoiceMailMain(${AGENTIDNUM})
exten => 6175,6,Hangup

; This handles dialing any other 'standard' extensions....
exten => _61XX,1,NoOp("${EXTEN} Called from ${CALLERID}/${CALLERIDNUM}")
exten => _61XX,2,Macro(stdexten,${EXTEN},SIP/${EXTEN})

; I use this context to do IVR landings as well as internal dialing of services.
[services]
include => verticals
include => parkedcalls

; direct to voicemail.... IE dial 76115 gives someone the VM for x6115.
; the 790X line is for the 'support' 'sales' etc boxes.
exten => _761XX,1,Voicemail(b${EXTEN:1})
exten => _7790X,1,Voicemail(b${EXTEN:1})

; 7900 to do agent login
; No comforts here, just launch.
; we do it in a seperate context because it needs dialouts
; and we do not want that here.
; The dialouts may be legacy from my chan_agent experiments honestly.
; but this DOES work.
exten => 7900,1,Goto(agentlogin,s,1)


; 7901 is the support queue transfer target
; We mutz CID here so we can tell our agents its a support queue call.
; We do quick/quiet dump, no comforts and we allow the agent to transfer.
; Need logic here for all busy, after hours for VM....
; The goqueue macro has some detritus that isn't used, specifically the last
; argument specifying the agent.
exten => 7901,1,NoOp
exten => 7901,2,SetMusicOnHold(default)
exten => 7901,3,DigitTimeout(5)
exten => 7901,4,ResponseTimeout(5)
exten => 7901,5,SetCIDName([SQ]${CALLERIDNAME})
exten => 7901,6,SetVar(QUEUEDCALL=1)
exten => 7901,7,Macro(goqueue,7901,supportq,Agent/@1)

; 7902 is Billing
exten => 7902,1,NoOp
exten => 7902,2,SetMusicOnHold(default)
exten => 7902,3,DigitTimeout(5)
exten => 7902,4,ResponseTimeout(5)
exten => 7902,5,SetCIDName([BQ]${CALLERIDNAME})
exten => 7902,6,SetVar(QUEUEDCALL=1)
exten => 7902,7,Macro(goqueue,7902,billingq,Agent/@2)

; 7995 is to internally/using CID check VM
; perhaps play vm-goodbye before hangup if they break out?
; what about dial-0-for-operator/etc?
exten => 7995,1,Ringing
exten => 7995,2,Wait(2)
exten => 7995,3,Answer
exten => 7995,4,Macro(AgentAuth,${CALLERIDNUM},vm-login)
exten => 7995,5,VoiceMailMain(${CALLERIDNUM})
exten => 7995,6,Hangup

;
; goqueue handles getting into a queue.  It also handles after-hours VM
; when noone is around. or when the global do not disturb is set.
;
; Global DND needs rewriting since it was put into the logic *before* any
; of the agent-dialplan logic was even conceived.
;
; $ARG1 is VM Mailbox
; $ARG2 is queue name to enter
; $ARG3 is the agent group/chan to check for availibility.
[macro-goqueue]
; this macro handles getting someone into the given queue, or into VM
exten => s,1,Goto(300)

; global DND/Do Not Queue flag?
; jump to s,401 when not found
; There's a pait of extenstions for this in our services context
; that I've omitted from this LGPL copy.  Pretty easy to figure it out.

exten => s,300,DBget(DNDALL=DND/all)
exten => s,301,GotoIf($[ ${DNDALL} = 1 ]?600:400)

; s,300 jumps here (401) when not found
exten => s,400,NoOp
exten => s,401,NoOp
exten => s,402,Queue(${ARG2}|t)
; fall through for when the agents are all logged out from the dynamic queue
; might actually want that to be to 700, log in a fake agent somehow, then
; let it go back to trying to ring people (IE handle during business hours)
exten => s,403,Goto(600)

; after hours, or master DND, or simply unavailable, VM!
exten => s,600,NoOp
exten => s,601,Wait(1)
exten => s,602,VoiceMail(sb${ARG1})



; if they press 0 while in the suppor queue, send them here so they 
; can leave a VM!
[supportqoutcon]
exten => 0,1,Voicemail(sb8901)
;exten => i,1,Playback(invalid)


; if they press 1, send them here so they can leave a VM!
[salesqoutcon]
exten => 0,1,Voicemail(sb8903)
;exten => i,1,Playback(invalid)



; AFTERHOURS=1 for holidays/after hours
; AFTERHOURS=0 for normal business hours
[macro-setafterhours]
; what to default to?  I think defaulting to being after hours is safest...
; why?  otherwise they can get stuck in a queue indefinetly.
exten => s,1,SetVar(AFTERHOURS=1)
exten => s,2,GotoIfTime(8:00-17:00|mon-fri|*|*?200)

exten => s,200,SetVar(AFTERHOURS=0)

; Some experimetnal stuff i was trying is in here, the part you really want is the s,1... bits.
; agent logins are here so we can allow for remotes local and extensions....
[agentlogin]
exten => _X.,1,NoOp(Experimental agent login XXXXXXXX)
exten => _X.,2,SetVar(QUEUEDCALL=1)
exten => _X.,3,Macro(AgentCall,${EXTEN})
exten => _X.,104,Goto(500)
exten => _X.,500,NoOp(GAH Serious error XXXXXXXX)
exten => _X.,501,Congestion

exten => s,1,Wait(1)
exten => s,2,Answer
exten => s,3,Macro(AgentLogin,${CALLERIDNUM})
exten => s,4,Hangup

[agentloginex]
exten => _X.,1,NoOp(Experimental agent login XXXXXXXX)
exten => _X.,2,SetVar(QUEUEDCALL=1)
exten => _X.,3,Macro(AgentCall,${EXTEN})
exten => _X.,104,Goto(500)
exten => _X.,500,NoOp(GAH Serious error XXXXXXXX)
exten => _X.,501,Congestion

exten => s,1,Wait(1)
exten => s,2,Answer
exten => s,3,Macro(AgentLogin,${CALLERIDNUM})
exten => s,4,Hangup


;
; vertical service codes.... *XX/#XX
; I don't think they're standard and I don't have the list in front of me.
; though they might eb the standard verticals...
[verticals]

; *21 unconditional CFWD...
; Unconditional Call Forward
exten => _*21*.,1,GotoIf($["foo${EXTEN:4}" = "foo*"]?50:100)
exten => _*21*.,50,DBget(temp=CFIM/${CALLERIDNUM})
exten => _*21*.,51,SayDigits(${temp})
exten => _*21*.,52,Goto(102)

exten => _*21*.,100,DBput(CFIM/${CALLERIDNUM}=${EXTEN:4})
exten => _*21*.,101,SayDigits(${EXTEN:4})
exten => _*21*.,102,Playback(vm-goodbye)
exten => _*21*.,103,Hangup

exten => _*21*.,151,Macro(noextenrecv)
exten => _*21*.,152,Goto(102)

exten => #21#,1,DBdel(CFIM/${CALLERIDNUM})
exten => #21#,2,Playback(auth-thankyou)
exten => #21#,3,Playback(vm-goodbye)
exten => #21#,4,Hangup

; *61 CFWD on busy/unavail
; Call Forward on Busy or Unavailable
exten => _*61*.,1,GotoIf($["foo${EXTEN:4}" = "foo*"]?50:100)
exten => _*61*.,50,DBget(temp=CFIM/${CALLERIDNUM})
exten => _*61*.,51,SayDigits(${temp})
exten => _*61*.,52,Goto(102)

exten => _*61*.,100,DBput(CFIM/${CALLERIDNUM}=${EXTEN:4})
exten => _*61*.,101,SayDigits(${EXTEN:4})
exten => _*61*.,102,Playback(vm-goodbye)
exten => _*61*.,103,Hangup

exten => _*61*.,151,Macro(noextenrecv)
exten => _*61*.,152,Goto(102)

exten => #61#,1,DBdel(CFBS/${CALLERIDNUM})
exten => #61#,2,Playback(auth-thankyou)
exten => #61#,3,Playback(vm-goodbye)
exten => #61#,4,Hangup 

; I can't even remember if *90 and *91 work.  They probably don't.

exten => *90,1,AgentCallBackLogin(${CALLERIDNUM}|${CALLERIDNUM}@agentlogin)
exten => *90,2,Playback(auth-thankyou)
exten => *90,3,Playback(vm-goodbye)
exten => *90,4,Hangup

exten => *91,1,AgentCallBackLogin(${CALLERIDNUM}|'#')
exten => *91,2,Playback(auth-thankyou)
exten => *91,3,Playback(vm-goodbye)
exten => *91,4,Hangup


[macro-noextenrecv]
; doesn't exist...
exten => s,1,Playback(vm-no)
exten => s,2,Playback(vm-extension)
exten => s,3,Playback(vm-received)

[from-sip]
include => international
include => default

; PRI feeds us 4 digit DIDs/DNID
[from-pri]

; 71xx DIDs
exten => _71XX,1,Goto(extens,${EXTEN},1)

; 7678 Main Number, goes to default to start IVR
exten => 7678,1,Goto(default,s,1)

; 4679 Fax line, goes directly to ringing the Fax. FAXDID in globals
exten => 7679,1,Dial(${FAX})
exten => 7679,2,Congestion
exten => 7679,3,Wait(30)
exten => 7679,4,Hangup

exten => 7679,102,Busy
exten => 7679,103,Wait(30)
exten => 7679,104,Hangup

; why set that?  because then they get the invalid number message
; from THEIR network.  we never get billed and neither do they.
exten => i,1,Set(PRI_CAUSE=1)
exten => i,2,Hangup

[default]

include => extens

; Run IVR Menu here...
exten => s,1,Ringing
exten => s,2,Wait(2)
exten => s,3,Answer
exten => s,4,DigitTimeout(5)
exten => s,5,ResponseTimeout(30)
exten => s,6,Goto(600)
; welcome to modwest... 
; 1 for sales
; 2 for support
; 3 for billing
; 0 for anything else (rings janiel/operator)
; * to repeat
exten => s,600,Background(modwest/main_menu)

exten => 1,1,Dial(Local/8903@services)

exten => 2,1,Dial(Local/8901@services)

exten => 3,1,Dial(Local/8902@services)

; exten => 8,1,Dial(Local/1@mgmnt)

exten => *,1,Goto(s,600)

exten => 0,1,Dial(Local/8904@services)

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

; Just give up on them after 30 seconds......
exten => t,1,Goto(#,1)

; fat fingers?  "That's not valid, try again"
exten => i,1,Playback(invalid)
exten => i,2,Goto(s,1)

; what to do with fax tones, should NEVER return...
exten => fax,1,Dial(Local/${FAXDID}@from-pri)
exten => fax,2,Congestion
exten => fax,3,Wait(30)
exten => fax,4,Hangup






; Here is our 'standard' extension macro used for
; internal transfer, external DID, agent/queue forwards.
; for handling the queues we need to look at the caller id stuff so we don't
; dump the agent system endlessly into voicemail!
; 
; Also needs to check for nonexistent extens somehow....
;
[macro-stdexten]
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;
exten => s,1,NoOp("macro-stdexten Called for ${ARG1} ringing ${ARG2} cid ${CALLERIDNAME}")
; branch to 100 if true, 500 if not... checks to see if
; caller came in via a queue, in which case we NEVER run to the target voicemail
; here.  that has to be done via direct, or the [SQ]/etc must be stripped (preferred)
exten => s,2,GotoIf($[ $[ "foo${CALLERIDNAME:0:4}" = "foo[SA]" ] | $[ "foo${CALLERIDNAME:0:4}" = "foo[OP]" ] | $[ "foo${CALLERIDNAME:0:4}" = "foo[SQ]" ] | $[ "foo${CALLERIDNAME:0:4}" = "foo[OP]" ] ]?100:500)

exten => s,100,NoOp(stdexten went to cfwd without VM)
exten => s,101,SetVar(CFWDNOVM=1)
exten => s,102,Macro(cfwd,${ARG1},${ARG2})

exten => s,500,NoOp(stdexten went to cfwd with VM)
exten => s,501,SetVar(CFWDNOVM=0)
exten => s,502,Macro(cfwd,${ARG1},${ARG2})


[macro-cfwd]
;
; Standard extension macro with call forwarding handling:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
; Dial goes to n+101 on a busy if it exists, but if not goes to next step
; so s,3 goes to s,4 because s,104 doesn't exist.

; behaviour is if CFIM then attempt, if that is busy or errors then
; try locally falling to or not to VM
; no CFIM then just dial locally
; after dialling locally check CFBS (since n+101=104 doesn't exist), if no cfbs goto busy.
; CFWDNOVM overrides VM on queued calles/etc...Also makes us not timeout
; on any of our dial statements...
exten=s,1,DBget(temp=CFIM/${ARG1}) ; Get CFIM key, if not existing, goto 102
exten=s,2,Dial(Local/${temp}@local/n)   ; Unconditional forward
;exten=s,3,Dial(${ARG2},20) ; 20sec timeout, then go on to try busy or no answer.
exten=s,3,Goto(3000)
exten=s,4,DBget(temp=CFBS/${ARG1})  ; Get CFBS key, if not existing, goto 105
exten=s,5,Dial(Local/${temp}@local/n) ; Forward on busy or unavailable
; make sure they do not get dead air by pushing up to 105 if the above fails
exten=s,6,Goto(s,105)

; decide if we timeout or not, this is so that queued calls/AgentCall can work right.
exten=s,3000,GotoIf($[ "foo${CFWDNOVM}" = "foo1" ]?3500:4000)

exten=s,3500,Dial(${ARG2})
exten=s,3501,Goto(4)
exten=s,3601,Goto(4)

exten=s,4000,Dial(${ARG2},20)
exten=s,4001,Goto(4)
exten=s,4101,Goto(4)

; No CFIM key, wrap back and try to dial given channel...
exten=s,102,Goto(s,3)

; No CFBS key - voicemail ?
; Select based on CFWDNOVM
; 200 if we get VM, 800 if not.
exten=s,105,GotoIf($[ $[ "${CFWDNOVM}" = "" ] | $[${CFWDNOVM} = 0] ]?200:800)
; 106 is target for the Forward on busy, so if that fails we loop up to above.
exten=s,106,Goto(s,105)

; check for a VM before using...
; if VM then branches to s,301 (n+101 exit on MailboxExists)
; if not we hop to 800 to figure out how to efficiently handle
; a hangup...
exten=s,200,MailboxExists(${ARG1})
exten=s,201,Goto(s,800)

; branch here if VM 
exten=s,300,NoOp
exten=s,301,Voicemail(b${ARG1})
exten=s,302,Playback(vm-goodbye)
exten=s,303,Hangup

; figure out if they came in on PRI, set code and hang up if so.
; default to cause 1 which is unallocated number
; if the number exists (IE dbget succeeds) we set it as 17 'user busy'
exten=s,800,NoOp
exten=s,801,NoOp ; SetVar(PRI_CAUSE=1) done in 9xx branch for not found
exten=s,802,DBget(tempcause=ACTIVEXTEN/${ARG1})
exten=s,803,SetVar(PRI_CAUS=${tempcause})
exten=s,804,Goto(s,1200)

exten=s,900,NoOp
exten=s,901,NoOp
exten=s,902,NoOp
exten=s,903,SetVar(PRI_CAUSE=28)
exten=s,904,Goto(s,1200)

; Determine channel type...
exten=s,1200,NoOp(channel is ${CHANNEL})
exten=s,1201,GotoIf($[ "foo${CHANNEL:0:3}" = "fooZap" ]?1500:1800)

; Zap channel, assume for now it's PRI and just hangup, the PRI_CAUSE
; variable will be set correctly here and the network will give indication.
exten=s,1500,NoOp
exten=s,1501,SetVar(ZAPCHANNUM=${CHANNEL:4})
exten=s,1502,Hangup

; Non-Zap, give indication locally.
exten=s,1800,Busy

; Old standard no cfwd stdexten
;exten => s,1,NoOp("macro-stdexten Called for ${ARG1} ringing ${ARG2}")
;exten => s,2,Dial(${ARG2},20,t)                                   ; Ring the interface, 20 seconds maximum
;exten => s,3,Voicemail(u${ARG1})                                ; If unavailable, send to voicemail w/ unavail announce
;exten => s,4,Goto(default,s,1)                                  ; If they press #, return to start
;exten => s,103,Voicemail(b${ARG1})                              ; If busy, send to voicemail w/ busy announce
;exten => s,104,Goto(default,s,1)                                ; If they press #, return to start

; we jump here if it looks like they came in via a queue....
;exten => s,1001,NoOp("came in via queue...")
;exten => s,1002,Dial(${ARG2},20,t)

[mgmnt]
include => extens
exten => s,1,NoOp
exten => s,2,Background(modwest/mgmnt_main)

;exten => 1,1,Macro(goqueue,testq)
exten => 1,1,NoOp
exten => 1,2,SetMusicOnHold(default)
exten => 1,3,DigitTimeout(5)
exten => 1,4,ResponseTimeout(5)
exten => 1,5,SetCIDName([OP]${CALLERIDNAME})
exten => 1,6,SetVar(QUEUEDCALL=1)
exten => 1,7,Macro(goqueue,8901,testq,Agent/@1)
exten => 1,8,Goto(s,1)

exten => 91,1,Read(AGNUM,agent-user)
exten => 91,2,Macro(AgentLogout,${AGNUM})
exten => 91,3,Goto(s,1)

exten => 96,1,Macro(AgentLogout,${CALLERIDNUM})
exten => 96,2,Goto(s,1)

exten => 97,1,Macro(AgentLogin,${CALLERIDNUM})
exten => 97,2,Goto(s,1)

exten => 98,1,Record(modwest/system_maintenance:gsm)
exten => 98,2,Wait(1)
exten => 98,3,Background(modwest/system_maintenance)
exten => 98,4,Wait(1)
exten => 98,5,Goto(s,1)

exten => 99,1,Record(modwest/mgmnt_main:gsm)
exten => 99,2,Wait(1)
exten => 99,3,Goto(s,1)



exten => i,1,Background(invalid)
exten => i,2,Goto(s,1)

exten => t,1,Goto(s,1)

; default demo extension
[demo]
;
; We start with what to do when a call first comes in.
;
exten => s,1,Wait,1                     ; Wait a second, just for fun
exten => s,2,Answer                     ; Answer the line
exten => s,3,DigitTimeout,5             ; Set Digit Timeout to 5 seconds
exten => s,4,ResponseTimeout,10         ; Set Response Timeout to 10 seconds
exten => s,5,BackGround(demo-congrats)  ; Play a congratulatory message
exten => s,6,BackGround(demo-instruct)  ; Play some instructions

exten => 2,1,BackGround(demo-moreinfo)  ; Give some more information.
exten => 2,2,Goto(s,6)

exten => 3,1,SetLanguage(fr)            ; Set language to french
exten => 3,2,Goto(s,5)                  ; Start with the congratulations

exten => 1000,1,Goto(default,s,1)
;
; We also create an example user, 1234, who is on the console and has
; voicemail, etc.
;
exten => 1234,1,Playback(transfer,skip)         ; "Please hold while..."
                                        ; (but skip if channel is not up)
exten => 1234,2,Macro(stdexten,1234,${CONSOLE})

exten => 1235,1,Voicemail(u1234)                ; Right to voicemail

exten => 1236,1,Dial(Console/dsp)               ; Ring forever
exten => 1236,2,Voicemail(u1234)                ; Unless busy

;
; # for when they're done with the demo
;
exten => #,1,Playback(demo-thanks)              ; "Thanks for trying the demo"
exten => #,2,Hangup                     ; Hang them up.

;
; A timeout and "invalid extension rule"
;
exten => t,1,Goto(#,1)                  ; If they take too long, give up
exten => i,1,Playback(invalid)          ; "That's not valid, try again"

;
; Create an extension, 500, for dialing the
; Asterisk demo.
;
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
exten => 500,2,Dial(IAX2/guest@misery.digium.com/s@default)     ; Call the Asterisk demo
exten => 500,3,Playback(demo-nogo)      ; Couldn't connect to the demo site
exten => 500,4,Goto(s,6)                ; Return to the start over message.

;
; Create an extension, 600, for evaulating echo latency.
;
exten => 600,1,Playback(demo-echotest)  ; Let them know what's going on
exten => 600,2,Echo                     ; Do the echo test
exten => 600,3,Playback(demo-echodone)  ; Let them know it's over
exten => 600,4,Goto(s,6)                ; Start over

;
; Give voicemail at extension 8500
;
exten => 8500,1,VoicemailMain
exten => 8500,2,Goto(s,6)
;
; Here's what a phone entry would look like (IXJ for example)
;
;exten => 1265,1,Dial(Phone/phone0,15)
;exten => 1265,2,Goto(s,5)

;[mainmenu]
;
; Example "main menu" context with submenu
;
;exten => s,1,Answer
;exten => s,2,Background(thanks)                ; "Thanks for calling press 1 for sales, 2 for support, ..."
;exten => 1,1,Goto(submenu,s,1)
;exten => 2,1,Hangup
;include => default
;
;[submenu]
;exten => s,1,Ringing                                   ; Make them comfortable with 2 seconds of ringback
;exten => s,2,Wait,2
;exten => s,3,Background(submenuopts)   ; "Thanks for calling the sales department.  Press 1 for steve, 2 for..."
;exten => 1,1,Goto(default,steve,1)
;exten => 2,1,Goto(default,mark,2)


