I'm writing CDR to mssql table with cdr_adaptive_odbc. This works fine in the sense that the record is written after the call.
But I'd like to write a cdr_record when the call comes in, before it is answered/aborted.
Reason: I'd like to add a function in our CRM-system: click this button and see the phonenumber of the incoming call, where the CDR-record is "ringing" or something. Then match the phonenumber with customer records, and show caller info on screen.
(I don't want to push the number to the CRM, it has to be a pull)
I have tried this:
exten => 13,1,noop()
same => n,forkcdr()
same => n,Wait(2)
same => n,dial(SIP/L13)
same => n,hangup()
but that does not create a new record in the database.
Instead of using CDR, I log CEL to a table. Then I can see the call which are started (eventtype 1, CHANNEL_START), and see if the linkedid has corresponding events with eventtype 4 ANSWER and events with eventtype 2 CHANNEL_END
I then find the lastest customer-id with that phone number (a customer might register multiple time with the same number), and show the corresponding name.
I finally (just for kicks) show the talk-time and disposition from the CDR-record.
You can use forkCDR app to drop enother cdr at start