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