[globals] pgrIP=172.24.0.7 pgrCDRs=/var/log/asterisk/pager_cdrs.csv pgrOpr=DAHDI/G0/3430 [internal] ; Pager IVR exten => _X.,1,Goto(pager-ivr,s,1) [pager-ivr] ; 4PAG (4724) - Pager IVR exten => s,1,Answer() ; Record start time and calling number same => n,Set(callTS=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)}) same => n,Set(cpn=${CALLERID(num)}) same => n,Set(fromPgrIVR=1) ; Play greeting while collecting destination pager number same => n(start),Read(destPgr,pager_ivr/greeting&pager_ivr/enter_pager_no,4,,0,5) ; Validate destination pager number same => n,GotoIf(${ISNULL(${destPgr})}?operAssist) same => n,GotoIf($[${LEN(${destPgr})} != 4]?badNo) ; Extracting pager type same => n,Set(pgrType=${destPgr:0:1}) ; Validating pager type is 1 (numeric) or 2 (alphanumeric) same => n,GotoIf($[${pgrType} = 1]?destValid) same => n,GotoIf($[${pgrType} = 2]?destValid) same => n,Goto(badNo) ; Extracting raw pager number same => n(destValid),Set(pgrNo=${destPgr:1}) same => n,Set(oprAssist=0) ; Collecting whether or not the user sends calling number or custom digits same => n(selectSend),Read(custMsg,pager_ivr/send_calling_or_custom_no,1,,3,10) same => n,GotoIf($[${custMsg} = 1]?sendANI) same => n,GotoIf($[${custMsg} = 2]?sendCust) same => n,Goto(badOpt) ; Sending calling number same => n(sendANI),Set(msgBody=${CALLERID(num)}) same => n,Goto(sendPage) ; Sending custom number same => n(sendCust),Read(msgBody,pager_ivr/enter_custom_no,320,,3,10) ; SEND IT same => n(sendPage),Set(msgBodyLen=${LEN(${msgBody})}) same => n,Set(httpResp=${CURL(http://${pgrIP}/send_page.php?pager=${pgrNo}&type=${pgrType}&msg=${msgBody}&baud=1&beep=1)}) same => n,NoOp(SENT: http://${pgrIP}/send_page.php?pager=${pgrNo}&type=${pgrType}&msg=${msgBody}&baud=1&beep=1) same => n,NoOp(RESPONSE: ${httpResp}) same => n,GotoIf($["${httpResp}" = "!sc1"]?success) same => n,Goto(failed) ; IT SENT! same => n(success),Set(sendSuccess=1) same => n,Playback(pager_ivr/page_sent) same => n,Goto(done) ; Error handling for invalid destination same => n(badNo),Playback(pager_ivr/bad_no) same => n,Goto(start) ; Error handling for sending message option, we just send them back to try again same => n(badOpt),Goto(selectSend) ; Error handling for failed pages same => n(failed),Set(sendSuccess=0) same => n,Playback(pager_ivr/trouble) same => n,SayAlpha(${httpResp}) same => n,Goto(done) ; Flow wrap-up same => n(done),Playback(pager_ivr/thankyou) same => n,Hangup() ; Operator assistance same => n(operAssist),Set(oprAssist=1) same => n,Set(CALLERID(name)=PAGE ASSISTANCE) same => n,Dial(${pgrOpr}) same => n,Hangup() ; Write out CDR record when caller hangs up exten => h,1,System(echo "${callTS},${cpn},${oprAssist},${pgrNo},${pgrType},${msgBodyLen},${sendSuccess}" >> ${pgrCDRs}) same => n,Hangup()