Recording Accurate CDRs
If you’re serious about your call data records - because you’re billing customers, or because you want to automatically reconcile calls against your invoice - then they’d better be accurate.
An easy win here is to normalise the numbers you call. In South Australia, a number listed as “(08) 5550 1234” can be dialled as either 0855501234 or 55501234 - the “08” prefix is optional, since it merely clarifies the area code.
Since you don’t want to have to reconcile against both forms (that just makes things messy, let’s clean it up so it always appears with the leading ‘08’:
;; Handle 08XXXXXXXX calls by default, as this is our "native" area code here in SA.
exten => _XXXXXXXX,1,Goto(08${EXTEN},1)
Easily done.
Another common issue is to ‘answer’ an outbound call (either explictly with Answer()
or implicitly with something like Playback()
) before actually dialling. Answering the call too early means your billsec
- which you’re potentially basing your customer billing on - is higher than it should be!
If you want to play a message back to the caller before the call itself is made, use Progress()
to indicate that you’re doing it as the call progresses, and that the call isn’t actually connected yet.
A final example is much less common - when dialling one number actually calls another; you have several options available with different tradeoffs. For this example, pretend that the PSTN-looking number 0855501234 should actually be delivered to the VoIP-looking number 0870101234. (Maybe it’s a cheaper internal-use-only equivalent number, and people forget to use it?)
This example will have your CDR showing the original number (the PSTN number that was dialled, rather than the number that was actually called). It assumes your upstream SIP provider is named vsp1
exten => 0855501234,1,Dial(SIP/0870101234@vsp1)
This example will have your CDR showing the number that was really called, not the number dialled:
exten => 0855501234,1,Goto(0870101234,1)
The following will have a mix of the two - a CDR for 0870101234 for the ringing, and a CDR for 0855501234 covering the ringing and the billable call. This assumes regular_outbound
is your context for outbound calls.
exten => 0855501234,n,Dial(LOCAL/0870101234@regular_outbound)
So, that’s a few easy ways to make sure that your CDRs are actually worth the bits they’re saved with.