aboutsummaryrefslogtreecommitdiff
path: root/asterisk-conf/extensions.conf
diff options
context:
space:
mode:
Diffstat (limited to 'asterisk-conf/extensions.conf')
-rw-r--r--asterisk-conf/extensions.conf233
1 files changed, 233 insertions, 0 deletions
diff --git a/asterisk-conf/extensions.conf b/asterisk-conf/extensions.conf
new file mode 100644
index 0000000..47dfc20
--- /dev/null
+++ b/asterisk-conf/extensions.conf
@@ -0,0 +1,233 @@
+[globals]
+tandmxkey=l2408fy4dlia3SqONVFSLD0LVkNmuerd209181Rl8228829DYIB
+tandmxhostid=110
+
+arf20=PJSIP/1051
+all=PJSIP/1001&PJSIP/1002&PJSIP/1051&SCCP/1101
+
+
+[from-internal]
+
+exten => _1XXX,1,Goto(internal-users,${EXTEN},1) ; 1xxx users
+exten => _2XXX,1,Goto(internal-services,${EXTEN},1) ; 2xxx services
+exten => _8XXXXXXX,1,Goto(tandmx,${EXTEN:1},1) ; tandmx prefixed by 8
+exten => _733XXXX,1,Set(number=${EXTEN:3}) ; SDF numbers prefixed by 733
+ same => n,Goto(sdf,${EXTEN:3},1)
+
+; PSTN
+exten => _0ZX,1,Goto(pstn,${EXTEN},1) ; emergency numbers (3 numbers starting with 0 followed by non-zero)
+exten => _112,1,Goto(pstn,${EXTEN},1) ; emergency service (fixed)
+exten => _XXXXXX,1,Goto(pstn,968${EXTEN},1) ; regional numbers (6 digits)
+exten => _[6789]XXXXXXXX,1,Goto(pstn,${EXTEN},1) ; national numbers (9 digits)
+exten => _0ZXXX,1,Goto(pstn,${EXTEN:1},1) ; short numbers prefixed by 0
+exten => _00ZX!,1,Goto(pstn,${EXTEN},1) ; international numbers prefixed by 00
+
+; catch invalid extension
+exten => _X!,1,Goto(bogons,s,1)
+
+; catch timeouts
+exten => t,1,Playback(press-button-again)
+ same => n,Hangup()
+
+
+[internal-users]
+
+; arf20 alias
+exten => 1000,1,Progress()
+ same => n,Dial(${arf20}, 20)
+ same => n,Goto(fail-to-internal,${EXTEN},1)
+
+; internal calls between extensions (10xx SIP)
+exten => _10XX,1,Progress()
+ same => n,Dial(PJSIP/${EXTEN}, 20)
+ same => n,Goto(fail-to-internal,${EXTEN},1)
+
+; internal calls between extensions (11xx SCCP)
+exten => _11XX,1,Progress()
+ same => n,Dial(SCCP/${EXTEN}, 20)
+ same => n,Goto(fail-to-internal,${EXTEN},1})
+
+
+[internal-services]
+
+; test
+exten = 2222,1,Answer()
+ same = n,Wait(1)
+ same = n,Playback(hello-world)
+ same = n,Hangup()
+; test2
+exten = 2223,1,Answer()
+ same = n,Wait(1)
+ same = n,Playback(digits/10)
+ same = n,Hangup()
+; Echo test
+exten => 2101,1,NoOp(Echo test)
+same => n,Playback(demo-echotest)
+same => n,Echo()
+same => n,Playback(demo-echodone)
+same => n,Hangup()
+
+
+; IVR
+exten => 2000,1,Goto(ivr,s,1)
+; conference
+exten => 2001,1,Answer()
+ same => n,ConfBridge(1)
+; asterisk time
+exten => 2002,1,Answer()
+ same => n,DateTime()
+ same => n,Hangup()
+; voicemail
+exten => 2003,1,VoiceMailMain()
+
+
+[ivr]
+; prompt
+exten => s,1,Answer(500)
+ same => n(loop),Background(arfnet/ivr_hello)
+ same => n,WaitExten()
+; on 1
+exten => 1,1,Read(entered_ext,arfnet/please-enter-ext,4)
+ same => n,Goto(from-internal,${entered_ext},1)
+; on 2
+exten => 2,1,Goto(internal-users,1000,1)
+; on 3
+exten => 3,1,Goto(internal-services,2001,1)
+; on 4
+exten => 4,1,VoiceMail(1000@default)
+
+exten = i,1,Playback(option-is-invalid)
+ same = n,Goto(ivr,s,1)
+
+exten = t,1,Playback(are-you-still-there)
+ same = n,Goto(ivr,s,1)
+
+
+[from-external]
+
+exten => _1XXX,1,Goto(internal-users,${EXTEN},1)
+exten => _2XXX,1,Goto(internal-services,${EXTEN},1)
+
+exten => _X!,1,Goto(bogons,s,1)
+
+
+[from-anonymous]
+
+exten => _X!,1,Verbose(*** Anonymous direct IP inbound call from: ${CALLERID(all)})
+ same => n,Goto(from-external,${EXTEN},1)
+
+
+[sdf]
+
+; to SDF
+exten => _XXXX,1,Verbose(*** Dialing outbound via SDF ${EXTEN})
+ same => n,Set(CALLERID(num)=2063)
+ same => n,Dial(PJSIP/${EXTEN}@sdf)
+ same => n,Goto(fail-to-external,${EXTEN},1)
+
+
+; external trunk calls from sdf
+[from-sdf]
+
+exten => 2063,1,Answer()
+ same => n,Verbose(*** Inbound call via SDF from: ${CALLERID(all)})
+ same => n,Dial(${arf20})
+ same => n,Hangup()
+
+
+[tandmx]
+
+; to Tandmx
+exten => _XXXXXXX,1,Verbose(*** Dialing outbound via Tandmx to: ${EXTEN})
+ same => n,Set(number=${EXTEN})
+ same => n,Set(CALLERID(num)=2736${CALLERID(num):1})
+ same => n,Set(lookup=${SHELL(curl "http://api.tandmx.net/api/v1/?auth=${tandmxkey}&number=${number}&ani=${CALLERID(num)}&host=${tandmxhostid}")})
+ same => n,Dial(${lookup})
+ same => n,Goto(fail-to-external,${EXTEN},1)
+
+
+[from-tandmx]
+
+exten => _2736XXX,1,Answer()
+ same => n,Verbose(*** Inbound call via Tandmx from: ${CALLERID(all)})
+ same => n,Goto(internal-users,1${EXTEN:4},1)
+
+exten => _2737XXX,1,Answer()
+ same => n,Verbose(*** Inbound call via Tandmx from: ${CALLERID(all)})
+ same => n,Goto(internal-services,2${EXTEN:4},1)
+
+
+[pstn]
+
+; to PSTN
+exten => _X!,1,Verbose(*** Dialing outbound via PSTN to: ${EXTEN})
+ same => n,Set(CALLERID(all)=868925554)
+ same => n,Dial(PJSIP/${EXTEN}@pstn)
+ same => n,Goto(fail-to-external,${EXTEN},1)
+
+[from-pstn]
+
+exten => 868925554,1,Answer()
+ same => n,Verbose(*** Inbound call via PSTN from: ${CALLERID(all)})
+ same => n,Progress()
+ same => n,Wait(1)
+ same => n,Ringing()
+ same => n,Dial(${all},45,d)
+ same => n,VoiceMail(1000@default,u)
+ same => n,Hangup()
+
+exten => 1,1,Goto(ivr,s,1)
+
+
+[bogons]
+
+exten => s,1,Answer()
+ same => n,Playback(pbx-invalid)
+ same => n,Hangup()
+
+
+[fail-to-external]
+
+exten => _X!,1,Goto(s-${DIALSTATUS},1) ; (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
+
+exten => s-NOANSWER,1,Playback(vm-nobodyavail)
+ same => n,Hangup()
+
+exten => s-BUSY,1,Playback(all-circuits-busy-now)
+ same => 1,Busy(5)
+ same => n,Hangup()
+
+exten => s-CHANUNAVAIL,1,Playback(ss-noservice)
+ same => n,Hangup()
+
+exten => s-CONGESTION,1,Congestion(5)
+ same => n,Hangup()
+
+exten => _s-.,1,Goto(s-NOANSWER,1)
+
+
+[fail-to-internal]
+
+exten => _X!,1,Set(MAILBOX=${EXTEN})
+ same => n,Goto(s-${DIALSTATUS},1) ; (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
+
+exten => s-NOANSWER,1,VoiceMail(1000@default,u) ; If unavailable, send to voicemail w/ unavail announce
+ same => n,Hangup() ; If they press #, return to start
+
+exten => s-BUSY,1,VoiceMail(1000@default,b) ; If busy, send to voicemail w/ busy announce
+ same => n,Hangup() ; If they press #, return to start
+
+exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer
+
+exten => a,1,VoicemailMain(${MAILBOX}) ; If they press *, send the user into VoicemailMain
+
+
+[send-text]
+exten => s,1,Verbose(*** Sending text to: ${ARG1})
+ same => n,Set(PEER=${CUT(CUT(CUT(MESSAGE(from),@,1),<,2),:,2)})
+ same => n,Set(FROM=${SHELL(asterisk -rx ‘pjsip show endpoint ${PEER}’ | grep ‘callerid ‘ | cut -d’:’ -f2- | sed ‘s/^ *//’ | tr -d ‘‘)})
+ same => n,Set(CALLERID_NUM=${CUT(CUT(FROM,>,1),<,2)})
+ same => n,Set(FROM_SIP=${STRREPLACE(MESSAGE(from),
+ same => n,MessageSend(pjsip:${ARG1},${FROM_SIP})
+ same => n,Hangup()
+