callfile: TESTT05100514541601721
# An application id from the callgenerator is passed concatinated with the destination nr in Channel:
# to have it available in the test-dial context for storing the dial result for later usage.
# The callgenerator application id might be longer than 20 chars so it is split up over 3 SetVar SMID1, SMID2, SMID3.
#
Channel: Local/TESTT05100514541601721:041234567890@test-dial
Context: test
Extension: s
Priority: 1
CallerId: 01722270201
MaxRetries: 0
WaitTime: 35
RetryTime: 10
Account: TEST
SetVar: SMID1=TESTT05100514541601
SetVar: SMID2=721
SetVar: SMID3=
SetVar: SMINFO=TESTINFO
SetVar: SMOADC=+491722270201
SetVar: SMADC=+491234567890
SetVar: SMRETRYCNT=3
extensions.conf:
[general]
TRUNKTEST=Zap/r1
WAV_PATH=/wav
CALLGEN_PATH=/callgen
; An application id from the call generator is passed concatinated with the destination nr in Channel:
; to have it available in the test-dial context for storing the dial result for later usage.
[test-dial]
; using the test-dial context allows us to use SetCallerPres not directly usable/available in CallFile
;exten => _TEST.,1,SetCallerPres(prohib)
exten => _TEST.,1,SetCallerPres(allowed)
exten => _TEST.,2,Cut(SMID=EXTEN,:,1)
exten => _TEST.,3,Cut(REALEXTEN=EXTEN,:,2)
exten => _TEST.,4,Dial(${TRUNKTEST}/${REALEXTEN},30,ng)
exten => _TEST.,5,DBPut(DIALTEST/${SMID}/HANGUPCAUSE=${HANGUPCAUSE})
exten => _TEST.,6,DBPut(DIALTESTVOICE/${SMID}/DIALSTATUS=${DIALSTATUS})
exten => _TEST.,105,goto(5)
exten => _TEST.,205,goto(5)
[test]
exten => s,1,SetCDRUserField(ID=${SMID1}${SMID2}${SMID3}\;)
exten => s,2,AppendCDRUserField(ADC=${SMADC}\;)
exten => s,3,AppendCDRUserField(OADC=${SMOADC}\;)
exten => s,4,AppendCDRUserField(INFO=${SMINFO}\;)
exten => s,5,Playback(${WAV_PATH}/intro)
exten => s,6,Playback(${WAV_PATH}/pending/${SMID1}${SMID2}${SMID3}-filea)
exten => s,7,Playback(${WAV_PATH}/gap1)
exten => s,8,Playback(${WAV_PATH}/pending/${SMID1}${SMID2}${SMID3}-fileb)
exten => s,9,Playback(${WAV_PATH}/gap2)
exten => s,10,Playback(${WAV_PATH}/${SMID1}${SMID2}${SMID3}-filec)
exten => s,11,Hangup
; Hangup during play
exten => h,1,GotoIf($["${CHANNEL}" = "OutgoingSpoolFailed"]?4)
; notify callgenerator about successful accepted call
exten => h,2,TrySystem(rm -f ${WAV_PATH}/pending/${SMID1}${SMID2}${SMID3}*)
exten => h,3,TrySystem(/bin/echo > ${CALLGEN_PATH}/done/${SMID1}${SMID2}${SMID3}.SMT)
; do nothing
exten => h,4,NoOp(CHANNEL=${CHANNEL})
; dial attempt failed, have attempt logged as CDR with callgenerator provided SMID, SMADC, SMOADC
exten => failed,1,SetCDRUserField(ID=${SMID1}${SMID2}${SMID3}\;)
exten => failed,2,AppendCDRUserField(ADC=${SMADC}\;)
exten => failed,3,AppendCDRUserField(OADC=${SMOADC}\;)
exten => failed,4,AppendCDRUserField(INFO=${SMINFO}\;)
exten => failed,5,AppendCDRUserField(RETRYCNT=${SMRETRYCNT}\;)
exten => failed,6,AppendCDRUserField(DIALSTATUS=${DIALSTATUS}\;)
; retrieve HANGUPCAUSE,DIALSTATUS stored by -dial context
exten => failed,7,DBGet(THANGUPCAUSE=DIALTEST/${SMID1}${SMID2}${SMID3}/HANGUPCAUSE)
exten => failed,8,AppendCDRUserField(HANGUPCAUSE=${THANGUPCAUSE}\;)
exten => failed,108,Goto(9)
exten => failed,9,DBGet(TDIALSTATUS=DIALTEST/${SMID1}${SMID2}${SMID3}/DIALSTATUS)
exten => failed,10,AppendCDRUserField(DIALSTATUS=${TDIALSTATUS}\;)
exten => failed,110,Goto(11)
exten => failed,11,DBDeltree(DIALTEST/${SMID1}${SMID2}${SMID3})
; notify callgenerator about failed call by writing file into callgenerator spool path
exten => failed,12,SetVar(UPDASTCALL=/bin/echo \"\\")
exten => failed,13,SetVar(UPDASTCALL=${UPDASTCALL}${TDIALSTATUS})
exten => failed,14,SetVar(UPDASTCALL=${UPDASTCALL}\"\\\")
exten => failed,15,SetVar(UPDASTCALL=${UPDASTCALL}${THANGUPCAUSE})
exten => failed,16,SetVar(UPDASTCALL=${UPDASTCALL}\"\\")
exten => failed,17,TrySystem(${UPDASTCALL} > ${CALLGEN_PATH}/fail/${SMID1}${SMID2}${SMID3}.SMT.tmp && /bin/mv ${CALLGEN_PATH}/fail/${SMID1}${SMID2}${SMID3}.SMT.tmp ${CALLGEN_PATH}/fail/${SMID1}${SMID2}${SMID3}.SMT)
;