Call recording with custom dialplan

Hello everyone,

I have created a custom pre-dialout trunk dialplan that will use a different area code depending on what area code is dialed.

It looks like this:

    [from-internal-custom]
exten => _9NXXXXXXXXX,1,Verbose(Number dialed ${EXTEN})
        same => n,Set(Dialed=${EXTEN:1}) ;Remove leading 9
        same => n,Verbose(Evaluating ${Dialed} for NPA)
        same => n,Set(NPA=${Dialed:0:3}) ;Sets 3 digit NPA
        same => n,Verbose(Sorting for NPA of ${NPA})
        same => n,GotoIf($[$["${NPA}" = "205"] | $["${NPA}" = "251"] | $["${NPA}" = "256"] | $[ "${NPA}" = "334"] | $["${NPA}" = "938"]]?Alabama)

REPEAT for all states

same => n,Goto(InvalidNPA);This must remain the last line for NPA sorting error catching
        same => n(Alabama),Verbose(Dialing ${Dialed} based on NPA of ${NPA} in the state of Alabama)
        same => n,Set(CALLERID(num)=+1XXXXXXXXXX)

REPEAT for all states

same => n(InvalidNPA),Verbose(Bad NPA of ${NPA} for ${Dialed}, no match. Please contact your admin to add this new NPA of ${NPA} and state)
        same => n,Set(CALLERID(num)=+1XXXXXXXXX)
        same => n,Verbose(No valid NPA of ${NPA} for ${Dialed} can be found, applying default CallerID of ${CALLERID(num)}. Please contact your admin to add this new NPA of ${NPA} and state)
        same => n,Dial(SIP/TRUNK/5464*1${Dialed},300,Tt)
        same => n,HangUp()

My question is, is there an easy way to “hook” into what Freepbx uses for call recording so these outbound calls can get recorded like a normal outbound call or perhaps a better way to do this in general that would allow call recording?

Thanks for the help, it is greatly appreciated!

I suggest all that stuff belongs in your

[macro-dialout-trunk-predial-hook]

context. You could massage your CALLERID(num) there.

Furthermore , IF lateral thinking is enabled and:-

database show NPA

returned:-

/NPA/205/CID : 2055551213
/NPA/205/agent : Bubba
/NPA/205/state : AL
/NPA/213/CID : 6265551211
/NPA/213/state : CA
/NPA/251/CID : 2055551213
/NPA/251/state : AL
/NPA/256/CID : 2055551213
/NPA/256/agent : Bubba
/NPA/256/state : AL
/NPA/334/CID : 2055551213
/NPA/334/state : AL
/NPA/555/CID : 2055551214
/NPA/555/state : NONE
/NPA/714/CID : 3235551395
/NPA/714/state : CA
/NPA/938/CID : 2055551213
/NPA/938/agent : Bubba
/NPA/938/state : AL

Then the code might be quite short, Additionally in NANP land technically the CID should be NXXNXXNNNN, the carrier might add a prepended + or +1, but that is wrong :slight_smile:

Possible resources,

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/asterisk-CHP-6-SECT-6.html
rasterisk -x "help database"
rasterisk -x "database put NPA/555 state NONE"
rasterisk -x "database get NPA/555 CID"
rasterisk -x "database put NPA/555 CID +15552051234"
rasterisk -x "database get NPA/555 CID"
rasterisk -x "database get NPA/555 CID"
rasterisk -x "database show NPA"
rasterisk -x "database show NPA/213"
rasterisk -x "database showkey state"
rasterisk -x "database showkey agent"
and the lovely

wget http://www.nanpa.com/nanp1/allutlzd.zip

1 Like