Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shahriarhasib/a2b795ff8e782bf3233c8c63a4cd0151 to your computer and use it in GitHub Desktop.
Save shahriarhasib/a2b795ff8e782bf3233c8c63a4cd0151 to your computer and use it in GitHub Desktop.
[general]
; General configuration section for Asterisk settings (usually empty in custom dial plans).
[globals]
;audiolocation=/home/shahriar/lab
;audiolocation=/var/lib/asterisk/sounds/en/lab
;DHAKA_TZ=Asia/Dhaka
; Global variables can be defined here, but they are currently commented out.
[ISD]
include => DOMESTIC
; Include the DOMESTIC context for access to its extensions.
exten => _00Z.,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
; Log the call details (caller ID, dialed number, context) for debugging or monitoring.
same => n,GoSub(CALLRECORD,s,1)
; Jump to the CALLRECORD context to handle call recording logic.
same => n,ExecIf($[${Recording}=1]?Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}))
; If recording is enabled, generate a filename using the current date, time, caller ID, and extension.
same => n,ExecIf($[${Recording}=1]?MixMonitor(${CALLFILENAME}.wav,b))
; If recording is enabled, start recording the call into the specified file.
same => n,SET(CALLERID(All)=Demo For Class<09609012009>)
; Set a custom Caller ID for the outbound call.
same => n,DIAL(SIP/IPTS-PROVIDER/${EXTEN})
; Dial the specified number using the SIP provider.
same => n,NoOP(Dial status: ${DIALSTATUS})
; Log the dial status (e.g., ANSWERED, BUSY, FAILED) for debugging.
same => n,Hangup()
; Terminate the call.
[INTERCOM]
exten => _5XX,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
; Log details of intercom calls for monitoring.
same => n,DIAL(SIP/${EXTEN})
; Dial a SIP extension directly for intercom calls.
same => n,NoOP(Dial status: ${DIALSTATUS})
; Log the dial status for debugging.
same => n,ExecIf($[${DIALSTATUS}=CHANUNAVAIL]?AGI(looking-for-mobile-no.php))
; If the channel is unavailable, run an AGI script to find a mobile number.
same => n,Hangup()
; Terminate the call.
exten => _888,1,Queue(CLASS-Members-Q)
; Add the caller to a queue named CLASS-Members-Q.
exten => _999,1,ConfBridge(CLASS-CONF)
; Place the caller into a conference bridge named CLASS-CONF.
exten => _4XX,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
; Log the details of calls to 4XX extensions.
same => n,DIAL(SIP/HUDAS-SERVER/${EXTEN})
; Dial a SIP extension via HUDAS-SERVER.
same => n,NoOP(Dial status: ${DIALSTATUS})
; Log the dial status.
same => n,ExecIf($[${DIALSTATUS}=CONGESTION]?AGI(looking-for-mobile-no.php))
; If the channel is congested, run an AGI script to find a mobile number.
same => n,Hangup()
; Terminate the call.
[DOMESTIC]
include => INTERCOM
; Include the INTERCOM context for access to its extensions.
exten => _0Z.,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
; Log domestic call details for monitoring.
same => n,GoSub(CALLRECORD,s,1)
; Jump to the CALLRECORD context for recording setup.
same => n,ExecIf($[${Recording}=1]?Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}))
; Generate a recording filename if recording is enabled.
same => n,ExecIf($[${Recording}=1]?MixMonitor(${CALLFILENAME}.wav,b))
; Start recording the call if enabled.
same => n,SET(CALLERID(All)=Demo For Class<09609012009>)
; Set a custom Caller ID for domestic calls.
same => n,DIAL(SIP/IPTS-PROVIDER/${EXTEN})
; Dial the number using the SIP provider.
same => n,NoOP(Dial status: ${DIALSTATUS})
; Log the dial status.
same => n,Hangup()
; Terminate the call.
[CALLRECORD]
exten => s,1,Background(lab/ask-for-record)
; Play a prompt asking whether to record the call.
same => n,WaitExten(5)
; Wait 5 seconds for user input.
exten => 1,1
[CLASS-CONF]
type=bridge
[general]
[globals]
;audiolocation=/home/shahriar/lab
;audiolocation=/var/lib/asterisk/sounds/en/lab
;DHAKA_TZ=Asia/Dhaka
[ISD]
include => DOMESTIC
exten => _00Z.,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
same => n,GoSub(CALLRECORD,s,1)
same => n,ExecIf($[${Recording}=1]?Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}))
same => n,ExecIf($[${Recording}=1]?MixMonitor(${CALLFILENAME}.wav,b))
same => n,SET(CALLERID(All)=Demo For Class<09609012009>)
same => n,DIAL(SIP/IPTS-PROVIDER/${EXTEN})
same => n,NoOP(Dial status: ${DIALSTATUS})
same => n,Hangup()
[INTERCOM]
exten => _5XX,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
same => n,DIAL(SIP/${EXTEN})
same => n,NoOP(Dial status: ${DIALSTATUS})
same => n,ExecIf($[${DIALSTATUS}=CHANUNAVAIL]?AGI(looking-for-mobile-no.php))
same => n,Hangup()
exten => _888,1,Queue(CLASS-Members-Q)
exten => _999,1,ConfBridge(CLASS-CONF)
exten => _4XX,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
same => n,DIAL(SIP/HUDAS-SERVER/${EXTEN})
same => n,NoOP(Dial status: ${DIALSTATUS})
same => n,ExecIf($[${DIALSTATUS}=CONGESTION]?AGI(looking-for-mobile-no.php))
same => n,Hangup()
[DOMESTIC]
include => INTERCOM
exten => _0Z.,1,NoOP(${CALLERID(All)} is dialing ${EXTEN} using dialplan ${CONTEXT})
same => n,GoSub(CALLRECORD,s,1)
same => n,ExecIf($[${Recording}=1]?Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}))
same => n,ExecIf($[${Recording}=1]?MixMonitor(${CALLFILENAME}.wav,b))
same => n,SET(CALLERID(All)=Demo For Class<09609012009>)
same => n,DIAL(SIP/IPTS-PROVIDER/${EXTEN})
;same => n,DIAL(SIP/${EXTEN}@IPTS-PROVIDER)
same => n,NoOP(Dial status: ${DIALSTATUS})
same => n,Hangup()
[CALLRECORD]
exten => s,1,Background(lab/ask-for-record)
same => n,WaitExten(5)
exten => 1,1,Set(Recording=1)
same => n,Return()
exten => i,1,Set(Recording=0)
same => n,Return()
exten => t,1,Set(Recording=0)
same => n,Return()
[FROM-IPTSP]
exten => _096.,1,NoOP(CALLER:${CALLERID(All)}, Dialed No. ${EXTEN}, Dialplan:${CONTEXT})
same => n,NoOP(Channel:${CHANNEL}, peer:${BRIDGEPEER}, Dest Domain:${SIPDOMAIN})
same => n,NoOP(URI:${SIPURI}, Codec:${SIP_CODEC})
same => n,GoSub(CALLRECORD,s,1)
same => n,ExecIf($[${Recording}=1]?Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN}))
same => n,ExecIf($[${Recording}=1]?MixMonitor(${CALLFILENAME}.wav,b))
same => n,GotoIfTime(09:00-20:59|sun-thu|*|*?ONHOUR,s,1:OFFHOUR,s,1)
same => n,Hangup()
[OFFHOUR]
exten => s,1,Background(lab/offhour-announcement)
same => n,Set(CDR(userfield)=${CALLERID(num)}-CallBackRequested)
same => n,Playback(lab/callback-requested)
same => n,Hangup()
[ONHOUR]
exten => s,1,Background(lab/on-hour-greetings-menu)
same => n,Background(lab/option 4)
same => n,WaitExten(5)
;exten => 1,1,SayUnixTime(${EPOCH},IMp,BST)
exten => 1,1,SayUnixTime(${EPOCH},BdY 'at' I 'and' Mp,GMT6)
exten => 2,1,Goto(FEEDBACK,s,1)
exten => 3,1,Goto(DIRECTDIAL,s,1)
exten => 4,1,ConfBridge(CLASS-CONF)
exten => 0,1,Goto(s,1)
exten => t,1,Playback(lab/timeout)
same => n,Goto(ONHOUR,s,1)
exten => h,1,NoOP(Hanging Up)
same => n,Goto(s,1)
exten => i,1,Playback(lab/wrong-number)
same => n,Goto(s,1)
[DIRECTDIAL]
exten => s,1,BackGround(lab:x/direct-dial/direct-dial)
same => n,WaitExten(5)
exten => _XXX,1,Goto(INTERCOM,${EXTEN},1)
exten => _XXXX,1,Goto(INTERCOM,${EXTEN},1)
exten => t,1,Playback(lab/timeout)
same => n,Goto(ONHOUR,s,1)
exten => h,1,NoOP(Hanging Up)
same => n,Goto(s,1)
exten => i,1,Playback(lab/wrong-number)
same => n,Goto(s,1)
[FEEDBACK]
exten => s,1,Read(callerfeedback,lab/training-feedback,1,,2,3)
same => n,ExecIf($[${callerfeedback}=1])?Set(FeedText=Understanding):Set(FeedText=NotUnderstanding))
same => n,NoOP(Caller's feedback is )
same => n,Set(CDR(userfield)=${CALLERID(num)}-${FeedText})
same => n,Goto(ONHOUR,s,1)
[global]
disallow=all
allow=ulaw,alaw
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
direct_media=no
context=INTERCOM
;[registration-iptsp]
;type=registration
;outbound_auth=iptsp-auth
;server_uri=sip:iptsp.bol-online.com
;client_uri=sip:[email protected]
;Transport Configuration
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
[transport-tcp]
type=transport
protocol=tcp
bind=0.0.0.0
;Extensions (Local Users)
[501]
type=endpoint
aors=501
auth=501-auth
context=DOMESTIC
callerid=User 1<501>
[502]
type=endpoint
aors=502
auth=502-auth
context=INTERCOM
callerid=User 2<502>
;Authentication for Local Users
[501-auth]
type=auth
auth_type=userpass
password=kndohj98dj
username=501
[502-auth]
type=auth
auth_type=userpass
password=kndohj98dj
username=502
;AOR (Address of Record) for Local Users
[501]
type=aor
max_contacts=1
[502]
type=aor
max_contacts=1
;SIP Provider (External Trunk)
[IPTS-PROVIDER]
type=endpoint
aors=IPTS-PROVIDER
context=FROM-IPTSP
;Authentication & AOR for SIP Provider
[IPTS-PROVIDER]
type=aor
contact=sip:iptsp.bol-online.com
;[iptsp-auth]
;type=auth
;auth_type=userpass
;username=username
;password=secret
;Remote SIP Peers
[HUDAS-SERVER]
type=endpoint
aors=HUDAS-SERVER
auth=HUDAS-SERVER-auth
context=DOMESTIC
transport=tcp,udp
[KOLLOL-SERVER]
type=endpoint
aors=KOLLOL-SERVER
auth=KOLLOL-SERVER-auth
context=DOMESTIC
transport=tcp,udp
[TANZIZ-SERVER]
type=endpoint
aors=TANZIZ-SERVER
auth=TANZIZ-SERVER-auth
;Authentication for Remote Peers
[HUDAS-SERVER-auth]
type=auth
auth_type=userpass
username=HUDAS-SERVER
password=qZ9a4M2zrwhakvcdVNLS
[KOLLOL-SERVER-auth]
type=auth
auth_type=userpass
username=KOLLOL-SERVER
password=qZ9a4M2zrwhakvcdVNLS
[CLASS-Members-Q]
member => SIP/501
member => SIP/HUDAS-SERVER/4101
[general]
disallow=all
allow=ulaw,alaw
qualify=yes
nat=force_rport,comedia
directmedia=no
canreinvite=no
insecure=invite,port
call-limit=2
context=INTERCOM
[501]
type=friend
host=dynamic
secret=kndohj98dj
context=DOMESTIC
callerid=User 1<501>
[502]
type=friend
host=dynamic
secret=kndohj98dj
context=INTERCOM
callerid=User 2<502>
[IPTS-PROVIDER]
type=peer
host=iptsp.bol-online.com
context=FROM-IPTSP
[HUDAS-SERVER]
type=friend
host=dynamic
secret=qZ9a4M2zrwhakvcdVNLS
context=DOMESTIC
tcpenable=yes
transport=tcp,udp
[KOLLOL-SERVER]
type=friend
host=dynamic
secret=qZ9a4M2zrwhakvcdVNLS
context=DOMESTIC
tcpenable=yes
transport=tcp,udp
[TANZIZ-SERVER]
type=friend
host=dynamic
secret=pKuLoKkHh3uSTbFn7mBu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment