Recording Custom Extension

I am using FreePBX Stable-5.211.65-14 x64

I am trying to figure out how to start recording in the dialplan. I am writing custom dialplans to integrate with my software. I could pass the call to a FreePBX created extension to start the recording and pass it to my custom extension, but I trying to avoid doing that.

Thanks,

I have tried adding these lines to the to dialplan but none of them have worked.

exten => s,nGosub(sub-record-check,s,1(exten,${dialnumber}))

exten => s,nGosubIf($["${REC_POLICY_MODE}"=“always”]?record,1(${EXTEN},${REC_POLICY_MODE},${FROMEXTEN}))

exten => s,nGosub(record,1(${EXTEN},“always”,${FROMEXTEN}))

won’t work, the synatax is wrong, it needs to be

exten => s,n,Gosub …
notice the extra comma

Thanks that was a just a typo in the forum it was correct in the dialplan.

Here is all the code for the extension.

[from-trunk]
include => TRANS

[TRANS]
exten => s,1,ExecIf($["${FROM_DID}" = ""]?Set(__FROM_DID=${EXTEN}))
exten => s,n,Gosub(app-blacklist-check,s,1())
exten => s,n,Set(CDR(did)=${FROM_DID})
exten => s,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s,n,Set(CHANNEL(musicclass)=default)
exten => s,n,Set(__MOHCLASS=default)
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Set(_TORECORD=${CURL(http://10.0.0.24/calltrackerv2/record.php?DID=${FROM_DID})})
exten => s,n,Set(_TRANSNUM=${CURL(http://10.0.0.24/calltrackerv2/transfer.php?DID=${FROM_DID})})
exten => s,n,Set(__FROMEXTEN=${CALLERID(num)})
exten => s,n,Gosub(sub-record-check,s,1(exten,${FROM_DID}))
exten => s,n,Dial(LOCAL/${TRANSNUM})
exten => s,n,Hangup()

Then you need to post a log of the call that arrives at the s (start) extension in the [from-trunk] context, if it goes to another extension than s then you can debug from there . . . :smile:

Here is the full log of a call. Thank you for your help.

Call Log Pastebin

    -- Executing [12023331111@from-sip-external:1] NoOp("SIP/10.0.0.34-00000046", "Received incoming SIP connection from unknown peer to 12023331111") in new stack
    -- Executing [12023331111@from-sip-external:2] Set("SIP/10.0.0.34-00000046", "DID=12023331111") in new stack
    -- Executing [12023331111@from-sip-external:3] Goto("SIP/10.0.0.34-00000046", "s,1") in new stack
    -- Goto (from-sip-external,s,1)
    -- Executing [s@from-sip-external:1] GotoIf("SIP/10.0.0.34-00000046", "1?checklang:noanonymous") in new stack
    -- Goto (from-sip-external,s,2)
    -- Executing [s@from-sip-external:2] GotoIf("SIP/10.0.0.34-00000046", "0?setlanguage:from-trunk,12023331111,1") in new stack
    -- Goto (from-trunk,12023331111,1)
    -- Executing [12023331111@from-trunk:1] Set("SIP/10.0.0.34-00000046", "__FROM_DID=12023331111") in new stack
    -- Executing [12023331111@from-trunk:2] NoOp("SIP/10.0.0.34-00000046", "Received an unknown call with DID set to 12023331111") in new stack
    -- Executing [12023331111@from-trunk:3] Goto("SIP/10.0.0.34-00000046", "s,a2") in new stack
    -- Goto (from-trunk,s,2)
    -- Executing [s@from-trunk:2] Gosub("SIP/10.0.0.34-00000046", "app-blacklist-check,s,1()") in new stack
    -- Executing [s@app-blacklist-check:1] GotoIf("SIP/10.0.0.34-00000046", "0?blacklisted") in new stack
    -- Executing [s@app-blacklist-check:2] Set("SIP/10.0.0.34-00000046", "CALLED_BLACKLIST=1") in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/10.0.0.34-00000046", "") in new stack
    -- Executing [s@from-trunk:3] Set("SIP/10.0.0.34-00000046", "CDR(did)=12023331111") in new stack
    -- Executing [s@from-trunk:4] ExecIf("SIP/10.0.0.34-00000046", "0 ?Set(CALLERID(name)=19094442222)") in new stack
    -- Executing [s@from-trunk:5] Set("SIP/10.0.0.34-00000046", "CHANNEL(musicclass)=default") in new stack
    -- Executing [s@from-trunk:6] Set("SIP/10.0.0.34-00000046", "__MOHCLASS=default") in new stack
    -- Executing [s@from-trunk:7] Set("SIP/10.0.0.34-00000046", "__CALLINGPRES_SV=allowed_not_screened") in new stack
    -- Executing [s@from-trunk:8] Set("SIP/10.0.0.34-00000046", "CALLERPRES()=allowed_not_screened") in new stack
    -- Executing [s@from-trunk:9] Set("SIP/10.0.0.34-00000046", "_TORECORD=true") in new stack
    -- Executing [s@from-trunk:10] Set("SIP/10.0.0.34-00000046", "_TRANSNUM=18004444444@outbound-allroutes") in new stack
    -- Executing [s@from-trunk:11] Set("SIP/10.0.0.34-00000046", "__FROMEXTEN=19094442222") in new stack
    -- Executing [s@from-trunk:12] Gosub("SIP/10.0.0.34-00000046", "sub-record-check,s,1(exten,12023331111)") in new stack
    -- Executing [s@sub-record-check:1] Set("SIP/10.0.0.34-00000046", "REC_POLICY_MODE_SAVE=") in new stack
    -- Executing [s@sub-record-check:2] GotoIf("SIP/10.0.0.34-00000046", "1?check") in new stack
    -- Goto (sub-record-check,s,7)
    -- Executing [s@sub-record-check:7] Set("SIP/10.0.0.34-00000046", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:8] GotoIf("SIP/10.0.0.34-00000046", "1?next") in new stack
    -- Goto (sub-record-check,s,11)
    -- Executing [s@sub-record-check:11] ExecIf("SIP/10.0.0.34-00000046", "0?Return()") in new stack
    -- Executing [s@sub-record-check:12] ExecIf("SIP/10.0.0.34-00000046", "0?Set(__REC_POLICY_MODE=)") in new stack
    -- Executing [s@sub-record-check:13] GotoIf("SIP/10.0.0.34-00000046", "0?exten,1") in new stack
    -- Executing [s@sub-record-check:14] Set("SIP/10.0.0.34-00000046", "__REC_STATUS=INITIALIZED") in new stack
    -- Executing [s@sub-record-check:15] Set("SIP/10.0.0.34-00000046", "NOW=1406075720") in new stack
    -- Executing [s@sub-record-check:16] Set("SIP/10.0.0.34-00000046", "__DAY=22") in new stack
    -- Executing [s@sub-record-check:17] Set("SIP/10.0.0.34-00000046", "__MONTH=07") in new stack
    -- Executing [s@sub-record-check:18] Set("SIP/10.0.0.34-00000046", "__YEAR=2014") in new stack
    -- Executing [s@sub-record-check:19] Set("SIP/10.0.0.34-00000046", "__TIMESTR=20140722-203520") in new stack
    -- Executing [s@sub-record-check:20] Set("SIP/10.0.0.34-00000046", "__FROMEXTEN=unknown") in new stack
    -- Executing [s@sub-record-check:21] Set("SIP/10.0.0.34-00000046", "__CALLFILENAME=exten-12023331111-unknown-20140722-203520-1406075720.188") in new stack
    -- Executing [s@sub-record-check:22] Goto("SIP/10.0.0.34-00000046", "exten,1") in new stack
    -- Goto (sub-record-check,exten,1)
    -- Executing [exten@sub-record-check:1] GotoIf("SIP/10.0.0.34-00000046", "0?callee") in new stack
    -- Executing [exten@sub-record-check:2] Set("SIP/10.0.0.34-00000046", "__REC_POLICY_MODE=") in new stack
    -- Executing [exten@sub-record-check:3] GotoIf("SIP/10.0.0.34-00000046", "0?caller") in new stack
    -- Executing [exten@sub-record-check:4] GotoIf("SIP/10.0.0.34-00000046", "1?callee") in new stack
    -- Goto (sub-record-check,exten,8)
    -- Executing [exten@sub-record-check:8] GosubIf("SIP/10.0.0.34-00000046", "0?record,1(exten,12023331111,unknown)") in new stack
    -- Executing [exten@sub-record-check:9] Return("SIP/10.0.0.34-00000046", "") in new stack
    -- Executing [s@from-trunk:13] Dial("SIP/10.0.0.34-00000046", "LOCAL/18004444444@outbound-allroutes") in new stack
    -- Called LOCAL/18004444444@outbound-allroutes
    -- Executing [18004444444@outbound-allroutes:1] Macro("Local/18004444444@outbound-allroutes-0000003b;2", "user-callerid,LIMIT,EXTERNAL,") in new stack
    -- Executing [s@macro-user-callerid:1] Set("Local/18004444444@outbound-allroutes-0000003b;2", "TOUCH_MONITOR=1406075720.190") in new stack
    -- Executing [s@macro-user-callerid:2] Set("Local/18004444444@outbound-allroutes-0000003b;2", "AMPUSER=19094442222") in new stack
    -- Executing [s@macro-user-callerid:3] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?report") in new stack
    -- Executing [s@macro-user-callerid:4] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?Set(REALCALLERIDNUM=19094442222)") in new stack
    -- Executing [s@macro-user-callerid:5] Set("Local/18004444444@outbound-allroutes-0000003b;2", "AMPUSER=") in new stack
    -- Executing [s@macro-user-callerid:6] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:7] Set("Local/18004444444@outbound-allroutes-0000003b;2", "AMPUSERCIDNAME=") in new stack
    -- Executing [s@macro-user-callerid:8] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?report") in new stack
    -- Goto (macro-user-callerid,s,15)
    -- Executing [s@macro-user-callerid:15] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?continue") in new stack
    -- Goto (macro-user-callerid,s,28)
    -- Executing [s@macro-user-callerid:28] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CALLERID(number)=19094442222") in new stack
    -- Executing [s@macro-user-callerid:29] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CALLERID(name)=unknown") in new stack
    -- Executing [s@macro-user-callerid:30] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CDR(cnum)=19094442222") in new stack
    -- Executing [s@macro-user-callerid:31] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CDR(cnam)=unknown") in new stack
    -- Executing [s@macro-user-callerid:32] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CHANNEL(language)=en") in new stack
    -- Executing [18004444444@outbound-allroutes:2] Set("Local/18004444444@outbound-allroutes-0000003b;2", "MOHCLASS=default") in new stack
    -- Executing [18004444444@outbound-allroutes:3] Set("Local/18004444444@outbound-allroutes-0000003b;2", "_NODEST=") in new stack
    -- Executing [18004444444@outbound-allroutes:4] Gosub("Local/18004444444@outbound-allroutes-0000003b;2", "sub-record-check,s,1(out,18004444444,)") in new stack
    -- Executing [s@sub-record-check:1] Set("Local/18004444444@outbound-allroutes-0000003b;2", "REC_POLICY_MODE_SAVE=") in new stack
    -- Executing [s@sub-record-check:2] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?check") in new stack
    -- Goto (sub-record-check,s,7)
    -- Executing [s@sub-record-check:7] Set("Local/18004444444@outbound-allroutes-0000003b;2", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:8] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?next") in new stack
    -- Goto (sub-record-check,s,11)
    -- Executing [s@sub-record-check:11] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Return()") in new stack
    -- Executing [s@sub-record-check:12] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(__REC_POLICY_MODE=)") in new stack
    -- Executing [s@sub-record-check:13] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?out,1") in new stack
    -- Goto (sub-record-check,out,1)
    -- Executing [out@sub-record-check:1] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?Set(__REC_POLICY_MODE=)") in new stack
    -- Executing [out@sub-record-check:2] GosubIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?record,1(exten,18004444444,unknown)") in new stack
    -- Executing [out@sub-record-check:3] Return("Local/18004444444@outbound-allroutes-0000003b;2", "") in new stack
    -- Executing [18004444444@outbound-allroutes:5] Macro("Local/18004444444@outbound-allroutes-0000003b;2", "dialout-trunk,2,18004444444,,off") in new stack
    -- Executing [s@macro-dialout-trunk:1] Set("Local/18004444444@outbound-allroutes-0000003b;2", "DIAL_TRUNK=2") in new stack
    -- Executing [s@macro-dialout-trunk:2] GosubIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?sub-pincheck,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:3] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?disabletrunk,1") in new stack
    -- Executing [s@macro-dialout-trunk:4] Set("Local/18004444444@outbound-allroutes-0000003b;2", "DIAL_NUMBER=18004444444") in new stack
    -- Executing [s@macro-dialout-trunk:5] Set("Local/18004444444@outbound-allroutes-0000003b;2", "DIAL_TRUNK_OPTIONS=Ttr") in new stack
    -- Executing [s@macro-dialout-trunk:6] Set("Local/18004444444@outbound-allroutes-0000003b;2", "OUTBOUND_GROUP=OUT_2") in new stack
    -- Executing [s@macro-dialout-trunk:7] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?nomax") in new stack
    -- Goto (macro-dialout-trunk,s,9)
    -- Executing [s@macro-dialout-trunk:9] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?skipoutcid") in new stack
    -- Executing [s@macro-dialout-trunk:10] Set("Local/18004444444@outbound-allroutes-0000003b;2", "DIAL_TRUNK_OPTIONS=Tt") in new stack
    -- Executing [s@macro-dialout-trunk:11] Macro("Local/18004444444@outbound-allroutes-0000003b;2", "outbound-callerid,2") in new stack
    -- Executing [s@macro-outbound-callerid:1] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?Set(CALLERPRES()=allowed_not_screened)") in new stack
    -- Executing [s@macro-outbound-callerid:2] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(REALCALLERIDNUM=19094442222)") in new stack
    -- Executing [s@macro-outbound-callerid:3] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?normcid") in new stack
    -- Goto (macro-outbound-callerid,s,6)
    -- Executing [s@macro-outbound-callerid:6] Set("Local/18004444444@outbound-allroutes-0000003b;2", "USEROUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:7] Set("Local/18004444444@outbound-allroutes-0000003b;2", "EMERGENCYCID=") in new stack
    -- Executing [s@macro-outbound-callerid:8] Set("Local/18004444444@outbound-allroutes-0000003b;2", "TRUNKOUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:9] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?trunkcid") in new stack
    -- Goto (macro-outbound-callerid,s,14)
    -- Executing [s@macro-outbound-callerid:14] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:15] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:16] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:17] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CALLERPRES()=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:18] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CDR(outbound_cnum)=19094442222") in new stack
    -- Executing [s@macro-outbound-callerid:19] Set("Local/18004444444@outbound-allroutes-0000003b;2", "CDR(outbound_cnam)=unknown") in new stack
    -- Executing [s@macro-dialout-trunk:12] GosubIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?sub-flp-2,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:13] Set("Local/18004444444@outbound-allroutes-0000003b;2", "OUTNUM=18004444444") in new stack
    -- Executing [s@macro-dialout-trunk:14] Set("Local/18004444444@outbound-allroutes-0000003b;2", "custom=SIP/StarCom50") in new stack
    -- Executing [s@macro-dialout-trunk:15] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default)Tt)") in new stack
    -- Executing [s@macro-dialout-trunk:16] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(DIAL_TRUNK_OPTIONS=TtM(confirm))") in new stack
    -- Executing [s@macro-dialout-trunk:17] Macro("Local/18004444444@outbound-allroutes-0000003b;2", "dialout-trunk-predial-hook,") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("Local/18004444444@outbound-allroutes-0000003b;2", "") in new stack
    -- Executing [s@macro-dialout-trunk:18] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?bypass,1") in new stack
    -- Executing [s@macro-dialout-trunk:19] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CONNECTEDLINE(num,i)=18004444444)") in new stack
    -- Executing [s@macro-dialout-trunk:20] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CONNECTEDLINE(name,i)=CID:19094442222)") in new stack
    -- Executing [s@macro-dialout-trunk:21] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?customtrunk") in new stack
    -- Executing [s@macro-dialout-trunk:22] Dial("Local/18004444444@outbound-allroutes-0000003b;2", "SIP/StarCom50/18004444444,300,Tt") in new stack
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Called SIP/StarCom50/18004444444
    -- SIP/StarCom50-00000047 is making progress passing it to Local/18004444444@outbound-allroutes-0000003b;2
    -- Local/18004444444@outbound-allroutes-0000003b;1 is making progress passing it to SIP/10.0.0.34-00000046
    -- SIP/StarCom50-00000047 answered Local/18004444444@outbound-allroutes-0000003b;2
    -- Local/18004444444@outbound-allroutes-0000003b;1 answered SIP/10.0.0.34-00000046
       > 0x7f24e8021500 -- Probation passed - setting RTP source address to 10.0.0.34:17110
       > 0x7f251001d6f0 -- Probation passed - setting RTP source address to 162.212.218.148:43952
    -- Executing [h@macro-dialout-trunk:1] Macro("Local/18004444444@outbound-allroutes-0000003b;2", "hangupcall,") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("Local/18004444444@outbound-allroutes-0000003b;2", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("Local/18004444444@outbound-allroutes-0000003b;2", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] Hangup("Local/18004444444@outbound-allroutes-0000003b;2", "") in new stack
  == Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'Local/18004444444@outbound-allroutes-0000003b;2' in macro 'hangupcall'
  == Spawn extension (macro-dialout-trunk, h, 1) exited non-zero on 'Local/18004444444@outbound-allroutes-0000003b;2'
  == Spawn extension (macro-dialout-trunk, s, 22) exited non-zero on 'Local/18004444444@outbound-allroutes-0000003b;2' in macro 'dialout-trunk'
  == Spawn extension (outbound-allroutes, 18004444444, 5) exited non-zero on 'Local/18004444444@outbound-allroutes-0000003b;2'
    -- Executing [h@from-trunk:1] Hangup("SIP/10.0.0.34-00000046", "") in new stack
  == Spawn extension (from-trunk, h, 1) exited non-zero on 'SIP/10.0.0.34-00000046'
  == Spawn extension (from-trunk, s, 13) exited non-zero on 'SIP/10.0.0.34-00000046'

I don’t really know what you are trying to do, but maybe you should make a custom context called [trans] (upper case TRANS is kinda non-conventional) and send your inbound calls to that context, then call from-trunk when you’ve done your stuff.

The calls are completing fine. the only thing that isn’t working is the recording the calls.

I added exten => s,n,Gosub(sub-record-check,s,1(exten,${FROM_DID})) it looks like the call is being recorded but the recording field in the CDRs is empty and the monitor folder is empty.

No, sorry, I still don’t understand what you are trying to do but apparently your “curl” call is never being called.

Maybe someone else . . .

The curl works perfectly.

Thanks for your help.