Farzan
Farzan

Reputation: 925

Asterisk - Reseting CDR to show correct billsec of a new call when channel is answered beforehand

What I want to do:
Answer an incoming call and Dial another number. When call is finished I need to have the correct conversation time of the call (which is supposed to be stored in ${CDR(billsec)}).
What I am getting:
Since the channel is answered, the C option in Dial application is only resetting the answer variable of CDR to current time therefore the resulting billsec is equal to duration variable of CDR and is equal to channel seize time not call conversation time.
My dial plan:

exten => 333333,1,NoOp(Here I answer the channel and make another call)
    same => n,Answer
    same => n,Dial(DAHDI/g0/123456789,,gC)
    same => n,NoOP(Billsec: ${CDR(billsec)}) // Here billsec is equal to CDR(duration)

Note: If I simply remove Answer CMD from dialplan then billsec variable is showing the correct call time and this makes sense because channel was not answered and CDR(answer) will be assigned as soon as called party answers the channel. But the problem is that in my complete dialplan I have to answer the channel before making the call because I need to interact with user beforehand and it needs the channel to be answered.

BTW, I am using Asterisk 13.0.0-beta1. Could any of you guys let me know how can I achieve what I want to do please?

Upvotes: 2

Views: 5076

Answers (3)

scharrua
scharrua

Reputation: 93

might be too late to answer your question, but I have the exact same scenario.

What I did is, just before the call is forwarded to the C leg (A leg is caller, B leg is IVR who answers the call, C leg is destination where to forward the call), use ForkCDR(arve).

Something like:

exten => _X.,1,NoOp(Incoming call from Provider X to User Y)
same => n,Macro(Execute_IVR)
same => n,ForkCDR(arve)
same => n,Dial(SIP/${EXTEN}@userY)

And it works fine: I get 2 CDR rows, one for A leg to IVR with its own bill sec (say, 25 seconds), and the other one with call forwardinng A leg to C leg, also with its own billsec (say 350 seconds). The sum of the 2 billsecs gives you the total duration of the call placed by A leg (caller). The billsec of the second CDR gives you the conversation duration of that part of the call.

Upvotes: 0

viktike
viktike

Reputation: 733

If basic CDR functionality is not enough for billing, check out CEL (Channel Event Logging). Supports all the DB backends, and has all the event's about a call (timestamped) that you possibly ever need.

Upvotes: 1

Fonewiz
Fonewiz

Reputation: 2087

ResetCDR() is your friend. I use this now so that I can track the original call duration and the portion of the call after it's transferred by the called party. This actually creates a second CDR record and should then contain the billsecs to match the conversation time.

Not 100% sure on all that but, give it a whirl, I think it's what you want.

http://www.voip-info.org/wiki/view/Asterisk+cmd+ResetCDR

Upvotes: 0

Related Questions