;Version("3.1.2.1")
;InformationalVersion("3.1.2.0")

[nixxis-consult]

 exten => s,1,Verbose(1,  Nixxis consult ${CUT(NixxisFileVersion,\",2)})
 same => n,Set(CallExtension=${EXTEN})
 same => n,ExecIf($["${PeerName}" = ""]?Set(PeerName=${CHANNEL(peername)}))
 same => n,Set(ACTIVITY=${SIP_HEADER(x-cr-act)})
 same => n,Set(CONTACT=${SIP_HEADER(x-cr-con)})
 same => n,Set(CallRecordingId=${SIP_HEADER(x-cr-rec)})
 same => n,Set(PeerAccount=${SIP_HEADER(x-cr-acc)})
 same => n,Set(CallerId=${SIP_HEADER(x-cr-ani)})

 same => n,SIPAddHeader(x-cr-con-act: ${ACTIVITY})
 same => n,SIPAddHeader(x-cr-con-con: ${CONTACT})
 same => n,SIPAddHeader(x-cr-mon: ${CHANNEL})
 same => n,Set(CALLERID(num)=${CallerId})

 same => n,GotoIf($["${CallRecordingId}" == ""]?NoRecording)
 same => n,Verbose(1,    with recording ${CallRecordingId})
 same => n,SIPAddHeader(x-cr-rec: ${CallRecordingId})
 same => n,Set(RecordingPath=${NixxisRecordingPath})
 same => n,ExecIf($["${RecordingPath}" == "" ]?Set(RecordingPath=${NixxisRecordingPath}))
 same => n,ExecIf($["${NixxisRecordingProcessing}" = "" ]?MixMonitor(${RecordingPath}/${PeerAccount}/${CallRecordingId}.wav):MixMonitor(${RecordingPath}/${PeerAccount}/${CallRecordingId}.wav,,${NixxisRecordingProcessing} "^{MIXMONITOR_FILENAME}"))

 same => n(NoRecording),Dial(SIP/${ACTIVITY}@${PeerName})
 same => n,HangUp()
 
