context app-router { 371 => { progress(); Set(xheader=${PJSIP_HEADER(read,X-Asterisk-Announce)}); Playback(kamailio/${xheader},noanswer); Busy(); Hangup(); } _X.=> { begin: LOOP=0; Set(__CNT=0); Set(__DID=${EXTEN}); CHANNELNAME=CUT(CHANNEL,"/",2); Set(__KAMAILIO=${CUT(CHANNELNAME,"-",1)}); Set(__ORIG_CALLID=${PJSIP_HEADER(read,X-ORIG-CALLID)}); Set(__ORIG_ICE=${PJSIP_HEADER(read,X-ORIG-ICE)}); Set(__ORIG_CLIOPR=${PJSIP_HEADER(read,X-ORIG-CLIOPR)}); Set(__ORIG_SRVCOUNT=${PJSIP_HEADER(read,X-ORIG-SRVCOUNT)}); Set(__ORIG_SRCPORT=${PJSIP_HEADER(read,X-ORIG-SRCPORT)}); Set(__MAIN_MENU_ID=${PJSIP_HEADER(read,X-MAIN-MENU-ID)}); Set(__MAIN_MENU_FILE=${PJSIP_HEADER(read,X-MAIN-MENU-FILE)}); Set(__GREETING_FILE=${PJSIP_HEADER(read,X-MAIN-GREET-FILE)}); Set(__SUB_FOLDER=${PJSIP_HEADER(read,X-SUB-FOLDER)}); Set(__LANGUAGE=${PJSIP_HEADER(read,X-LANGUAGE)}); Set(__NO_ANSWER_TIMER=${PJSIP_HEADER(read,X-NO-ANSWER-TIMER)}); Set(__MOH=${PJSIP_HEADER(read,X-MOH)}); Set(__DIALATTEMPT=${PJSIP_HEADER(read,X-DIALATTEMPT)}); Set(__P_ASSERTED_IDENTITY=${PJSIP_HEADER(read,P-Asserted-Identity)}); Set(__PRIVACY=${PJSIP_HEADER(read,Privacy)}); Set(__CALLBACK_FLAG=${PJSIP_HEADER(read,X-CALLBACK_FLAG)}); Set(__MENU_ID=${MAIN_MENU_ID}); Set(__MENU_FILE=${MAIN_MENU_FILE}); if ("${MAIN_MENU_FILE}" != "0") { Set(anncheck=${SHELL(test -f /var/lib/asterisk/sounds/${LANGUAGE}/${SUB_FOLDER}/${MENU_FILE}.wav && echo -n 1 || echo -n 0)}); if ("${anncheck}" == "0"){ hangup(79); } } if ("${MAIN_MENU_FILE}" == "0") { Set(grtcheck=${SHELL(test -f /var/lib/asterisk/sounds/${LANGUAGE}/${SUB_FOLDER}/${GREETING_FILE}.wav && echo -n 1 || echo -n 0)}); if ("${grtcheck}" == "0"){ hangup(79); } } Answer(); if ("${MAIN_MENU_FILE}" == "0") { Playback("IVR/${LANGUAGE}/${SUB_FOLDER}/${GREETING_FILE}"); if ("${MAIN_MENU_ID}" == "ANN") { hangup(); } if("${CALLBACK_FLAG}" == "1") { Set(__CALLBACK_ON=0); } __result="ROUTING"; __CNT=$[${CNT}+1]; goto DIAL-X|setdial; } Read(__result,"IVR/${LANGUAGE}/0/100"&"IVR/${LANGUAGE}/${SUB_FOLDER}/${GREETING_FILE}",5,,1,1); if ("${result}" != "") { __CNT=$[${CNT}+1]; goto DIAL-X|setdial; }; __CNT=$[${CNT}+1]; goto DIAL-X|begin; }; _VM.=> { begin: LOOP=0; __MENU_ID=${CUT(EXTEN,,2)}; __SUB_FOLDER=${CUT(EXTEN,,3)}; __MENU_FILE=${CUT(EXTEN,,4)}; __ERR_FILE=${CUT(EXTEN,,5)}; __LANGUAGE=${CUT(EXTEN,,6)}; __KAM_SRV=${CUT(EXTEN,,7)}; __CALLBACK_FLAG=${CUT(EXTEN,,8)}; if ("${ERR_FILE}" != "0") { Playback("IVR/${LANGUAGE}/0/${ERR_FILE}"); if ("${ERR_FILE}" == "260") { Playback("IVR/${LANGUAGE}/0/120"&"IVR/${LANGUAGE}/0/110"); __result="ENDCALL"; __CNT=$[${CNT}+1]; goto DIAL-X|setdial; } } if ("${MENU_ID}" == "SYSANN") { Playback("kamailio/${MENU_FILE}"); hangup(); } Set(anncheck=${SHELL(test -f /var/lib/asterisk/sounds/${LANGUAGE}/${SUB_FOLDER}/${MENU_FILE}.wav && echo -n 1 || echo -n 0)}); if ("${anncheck}" == "0") { Playback("IVR/${LANGUAGE}/0/129"&"IVR/${LANGUAGE}/0/120"&"IVR/${LANGUAGE}/0/110"); __result="ANNFAIL"; __CNT=$[${CNT}+1]; goto DIAL-X|setdial; } if ("${MENU_ID}" == "ANN") { Playback("IVR/${LANGUAGE}/${SUB_FOLDER}/${MENU_FILE}"); hangup(); } if ("${KAM_SRV}" == "NIGHT_SRV") { Playback("IVR/${LANGUAGE}/${SUB_FOLDER}/${MENU_FILE}"); if ("${MAIN_MENU_ID}" == "ANN") { hangup(); } if("${CALLBACK_FLAG}" == "1") { Set(MASTER_CHANNEL(CALLBACK_FLAG)=1); Set(MASTER_CHANNEL(CALLBACK_ON)=0); Set(__CALLBACK_ON=0); } __result="ROUTING"; __CNT=$[${CNT}+1]; goto DIAL-X|setdial; } __CNT=$[${CNT}+1]; goto DIAL-X|begin; }; fax=> { begin: Set(__CNT=1); Set(__MOH=0); __result="FAX"; goto DIAL-X|setdial; }; _DIAL.=> { begin: if (${LOOP}>2) { goto end_call; } Read(__result,"IVR/${LANGUAGE}/${SUB_FOLDER}/${MENU_FILE}",5,,1,2); if ("${result}" == "" && "${READSTATUS}" == "TIMEOUT") { Read(__result,"IVR/${LANGUAGE}/0/silence",5,,1,6); } if ("${result}" == "") { if(${LOOP}<2) { Playback("IVR/${LANGUAGE}/0/230"); LOOP=${LOOP}+1; goto begin; } else { goto end_call; } } setdial: Set(__DYNAMIC_FEATURES=callback); Set(REDIRECTING(from-num-valid)=0); set(DIAL_STRING=${DID}-${CNT}); if (${DID:0:4} == 800) { set(SESSION_TIMEOUT=3600000); } else { set(SESSION_TIMEOUT=172800000); } dodial: if (${MOH}>0){ Set(CHANNEL(musicclass)=${MOH}); Dial(PJSIP/${DIAL_STRING}@${KAMAILIO}_out,130,mL(${SESSION_TIMEOUT})b(settings,add_headers,1)); } else{ Dial(PJSIP/${DIAL_STRING}@${KAMAILIO}_out,130,RL(${SESSION_TIMEOUT})b(settings,add_headers,1)); } callback_check: //if("${DIALSTATUS}" == "ANSWER" && "${SHARED(callback,${Org_Chan})}"!="1") { // hangup(); //} if ("${CALLBACK_ON}"="1") { //here comes code for callback menu NoOp(********** CALBACK STUFF ************); hangup(); } set_cont_vm: LOOP=0; cont_vm: if (${LOOP}>2) { goto end_call; } if (!(("${result}" == "ROUTING"||"${result}" == "FAX")) && ("${HANGUPCAUSE}"!="1") && ("${HANGUPCAUSE}"!="2") && ("${HANGUPCAUSE}"!="3")) { if (${LOOP}==0) { if("${HANGUPCAUSE}"=="18"){ PROMPT=131; } else { PROMPT=129; } Playback("IVR/${LANGUAGE}/0/${PROMPT}"); } contpress=""; Read(contpress,"IVR/${LANGUAGE}/0/132"&"IVR/${LANGUAGE}/0/135",1,,1,8); if("${contpress}"=="*"){ __result="*"; __CNT=$[${CNT}+1]; __DIALATTEMPT=$[${DIALATTEMPT}+1]; goto setdial; } if ("${contpress}" == "1") { __CNT=$[${CNT}+1]; __DIALATTEMPT=$[${DIALATTEMPT}+1]; goto setdial; } if ("${contpress}" == "" && ${LOOP}<2){ Playback("IVR/${LANGUAGE}/0/230"); LOOP=${LOOP}+1; goto cont_vm; } if (${LOOP}<2){ Playback("IVR/${LANGUAGE}/0/235"); LOOP=${LOOP}+1; goto cont_vm; } } else { hangup(); } end_call: Playback("IVR/${LANGUAGE}/0/120"&"IVR/${LANGUAGE}/0/110"); hangup(); }; }; context settings { add_headers=> { begin: if (${LEN(${P_ASSERTED_IDENTITY})} > 1) { SET(PJSIP_HEADER(add,P-Asserted-Identity)=${P_ASSERTED_IDENTITY}); if (${LEN(${PRIVACY})} > 1) { SET(PJSIP_HEADER(add,Privacy)=${PRIVACY}); } } SET(PJSIP_HEADER(add,X-MENU-RESULT)=MENUID=${MENU_ID};DIGRESULT=${result}); SET(PJSIP_HEADER(add,X-ORIG-CALLID)=${ORIG_CALLID}); SET(PJSIP_HEADER(add,X-ORIG-ICE)=${ORIG_ICE}); SET(PJSIP_HEADER(add,X-ORIG-CLIOPR)=${ORIG_CLIOPR}); SET(PJSIP_HEADER(add,X-ORIG-SRVCOUNT)=${ORIG_SRVCOUNT}); SET(PJSIP_HEADER(add,X-ORIG-SRCPORT)=${ORIG_SRCPORT}); SET(PJSIP_HEADER(add,X-MAIN-MENU-ID)=${MAIN_MENU_ID}); SET(PJSIP_HEADER(add,X-SUB-FOLDER)=${SUB_FOLDER}); SET(PJSIP_HEADER(add,X-NO-ANSWER-TIMER)=${NO_ANSWER_TIMER}); SET(PJSIP_HEADER(add,X-LANGUAGE)=${LANGUAGE}); SET(PJSIP_HEADER(add,X-DIALATTEMPT)=${DIALATTEMPT}); }; }; context callback { s=> { begin: if ("${CALLBACK_FLAG}" == "1") { Set(MASTER_CHANNEL(CALLBACK_ON)=1); if("${CALLBACK_ON}" == "0") { hangup(); } } }; };