Accountcode based on trunk

Howdy all.

I am looking to setup A2 billing and playing with what i can do with CDRs. Basically we have a setup like

CLIENTPBX <> SIPSWITCH <> Provider

We manage the sipswitch in the middle and sometimes the client pbx, sometimes clients will byo pbx. There will be no extensions on the sipswitch, only trunks and routing to the clients, A2 will be on the sipswitch.

I have been reading some other forums where guys have added the X-AccountCode to the sip header frrom the remote PBX but since i wont always have the access or ability ( or might not be Asterisk ).

In each case the client will have a trunk named Client_ERT, Client_TSV etc what i would like to be able to do is any calls that originate via each trunk use that code as the accountcode thats written to the CDRS, ERT, TSV etc

any help on if this is possible would be great!!

tia

You want to probably do custom dialplan in dialout-trunk-predial-hook You can then add whatever info you need. with something like Set(CDR(accountcode)=value)

1 Like

ok did some looking and found this

[macro-dialout-trunk-predial-hook]

exten => s,1,GotoIf($["${custom}" = “SIP/ssi2”]?A2)
exten => s,n,MacroExit()
exten => s,n(A2),Noop(A2 Account Code Added)
exten => s,n,SIPAddHeader(X-Accountcode:${CDR(accountcode)})
exten => s,n,MacroExit()

this is what another guy was doing but this was on the remote end calling

so from here

https://www.voip-info.org/wiki/view/Asterisk+Detailed+Variable+List

i see things like

${CHANNEL}

that might do what i need?

thats really helped mate

got it working cheers

for anyone else trying to do a similar thing

[macro-dialout-trunk-predial-hook]
exten => s,1,Set(foo=${CUT(CHANNEL,_,2)})
exten => s,n,Set(foo=${CUT(foo,-,1)})
exten => s,n,Set(CDR(accountcode)=${foo})
exten => s,n,MacroExit()

ended up with this, using the CUT function was able to trim down the CHANNEL to only display the client code

1 Like