1

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.

  • I don't want to push the number to the CRM, it has to be a pull what about pushing the number to a temporary table where it'll be pulled by the CRM later on ? – André Borie Aug 27 '15 at 1:20
0

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.

SELECT TOP 10 a.cid_num, 
          a.eventtime 'begin', 
          b.eventtime 'answer', 
          c.eventtime 'end', 
          mk.maxid, 
          navn, 
          cdr.duration, 
          cdr.billsec, 
          cdr.disposition 
FROM   asteriskcel a 
   LEFT JOIN asteriskcel b 
          ON b.eventtype = 4 -- ANSWER
             AND b.linkedid = b.uniqueid 
             AND b.linkedid = a.linkedid 
   LEFT JOIN asteriskcel c 
          ON c.eventtype = 2 -- CHANNEL_END
             AND c.linkedid = c.uniqueid 
             AND c.linkedid = a.linkedid 
   LEFT JOIN (SELECT RIGHT(telefon, 8) tlf, 
                     Max(id)           maxid 
              FROM   t_kunder 
              GROUP  BY RIGHT(telefon, 8)) mk 
          ON RIGHT(a.cid_num, 8) = mk.tlf 
   LEFT JOIN t_kunder k 
          ON mk.maxid = k.id 
   LEFT JOIN bit_cdr cdr 
          ON cdr.linkedid = a.linkedid 
WHERE  a.eventtype = 1 -- CHANNEL_START
   AND a.linkedid = a.uniqueid 
   AND a.context = 'default' 
ORDER  BY a.eventtime DESC  
-2

You can use forkCDR app to drop enother cdr at start

  • As stated in the original question, this did not work. It should have, that's why I tried in the first place. – Lenne Sep 7 '15 at 5:20
  • It work if you use ResetCDR(vw) – arheops Sep 7 '15 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.