Skip to content

Instantly share code, notes, and snippets.

@jsimpsoncd
Created December 9, 2020 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsimpsoncd/1f4454614ad4b437e1a6a835b9ee9c19 to your computer and use it in GitHub Desktop.
Save jsimpsoncd/1f4454614ad4b437e1a6a835b9ee9c19 to your computer and use it in GitHub Desktop.
extensions.conf for "Why do I need a home phone" demos
[from-internal]
;The letter X or x represents a single digit from 0 to 9.
;The letter Z or z represents any digit from 1 to 9.
;The letter N or n represents a single digit from 2 to 9.
; These are our typical "call a phone number" rules
exten => _NXXNXXXXXX,1,Verbose(2, Dialing out ${EXTEN})
exten => _NXXNXXXXXX,n, Dial(SIP/${EXTEN}@voipms)
exten => _NXXNXXXXXX,n,Hangup()
exten => 1NXXNXXXXXX,1,Verbose(2, Dialing out ${EXTEN})
exten => 1NXXNXXXXXX,n, Dial(SIP/${EXTEN}@voipms)
exten => 1NXXNXXXXXX,n,Hangup()
; This is the what time is it demo
exten => 200,1,Verbose(2, Play the special audio)
exten => 200,n,Playback(tt-monkeys)
exten => 200,n,Set(FUTURETIME=$[${EPOCH} + 12])
exten => 200,n,SayUnixTime(${FUTURETIME},Zulu,HNS)
exten => 200,n,Hangup()
; This was the authenticate to call demo
exten => 300,1,Verbose(2, Check authentication for calling)
exten => 300,n,Read(password,vm-password,6,,2)
exten => 300,n,AGI(authenticate.php,${password})
exten => 300,n,Verbose(2, What is allowdial anyway? ${ALLOWDIAL})
exten => 300,n,GotoIf($["${ALLOWDIAL}" = "0" ]?reject,s,1)
; call a number now that we are authed.
exten => 300,n,Dial(SIP/8009346489@voipms)
exten => 300,n,Hangup()
; we used this one just to set the greeting for the auto attendant in the demo.
exten => 101,1,Playback(vm-intro)
exten => 101,n,Record(maingreeting.wav)
exten => 101,n,Wait(2)
exten => 101,n,Playback(maingreeting)
exten => 101,n,Hangup()
; didn't actually test this, but should work to dial an exten
exten => _XXX,1,Verbose(2, Dialing an extension)
exten => _XXX,n,Dial(SIP/${EXTEN}@${EXTEN})
exten => _XXX,n,Hangup()
[voipms-in]
exten => 4843742330,1,Verbose(2, Incoming call from PSTN)
;we swapped the next two lines to test the main number going right to an extension, vs going to the auto attendant.
;exten => 4843742330,n,Dial(SIP/100@100,10)
exten => 4843742330,n,GoSub(mainaa,s,1)
exten => 4843742330,n,Hangup()
[reject]
exten => s,1,Verbose(2, Reject the call)
exten => s,n,Playback(vm-invalidpassword)
[mainaa]
; The auto attendant. This is for call flow trees like "press one to talk to a real person". In this case 1 gets you to extension 100.
exten => s,1,Verbose(1, Caller ${CALLERID(all)} has entered the auto attendant)
exten => s,n,Answer()
; We'll wait 2 seconds on digit timeouts.
exten => s,n,Set(TIMEOUT(digit)=2)
exten => s,n,Wait(1)
; We'll play a greeting. Since it's background, you can dial while it's playing.
exten => s,n,Background(maingreeting)
; Wait 4 seconds for input.
exten => s,n,WaitExten(4)
; And if we don't get any, go to extension 1. Which dials 100.
exten => s,n,Goto(1,1)
exten => 1,1,Dial(SIP/100@100,10)
exten => 1,n,Hangup()
; User chose 2, send them to the from-internal context, ext 200, one of our demos
exten => 2,1,GoSub(from-internal,200,1)
; User chose 3, send them to the from-internal context, ext 300, one of our other demos
exten => 3,1,GoSUb(from-internal,300,1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment