How can you get DID dialed into the CDR reports

Ok somebody asked this on the IRC channel yesterday, which was interesting then somebody at work this morning asked a question and now I need it… Funny how things work out.

The question asked was “What number(s) are people dialing to talk to us”. Now on a POTS setup it is easy, but with a T1/E1/PRI it is NOT.

We have several different main numbers that come in to our one IVR (xxx 325 xxxx, xxx 758 xxxx, xxx 426 xxxx) where you get greeted and can pick a person from the directory thereby end up at the extension of the person you want. But I need to know what number they dialed to get into our system and that is not possible from the cdr records because it does not record that information. It shows the CID of the caller and the extension that accepted the call, but assuming that they dialed the DID for that extension would be incorrect some times.

In the CDR you can’t see the inbound DID dialed, just the remote CID info on a inbound call. I could make a blanket assumption that they dialed each extensions DID (we have a one to one for everybody in the office), But then that would then miss all the ones calling our main number or who end up picking one of our three ring groups.

So is there a way to modify the CDR recording so that the DID dialed as it came in get’s recorded? And if so how as I know the person asking on IRC is a new at this and will probably ask anyway.

This also becomes important when a employee leaves as we forward that persons number to the new persons number so we don’t miss calls, but would like to really know when we are NOT getting calls on that line any more so we can reclaim it.

Yes I can extract all of this via the full logs but those roll and expire sometimes before we think about it so it’s not always possible to go back and check (besides the large quantity of work involved to do that).

I don’t know how to fix the DID in CDR thing (it would be nice, I agree) but on this particular issue: if you delete the old extension it should go to your any CID/DID route, you shouldn’t be losing calls to it.

Thats odd, that value is contained in ${EXTEN} on your inbound route section. For example we have a custom context for our pri called:

[from-mypri]
exten => _.,1,Noop(CALLERID: ${CALLERID(all)})
exten => _.,n,Wait(2)
exten => _.,n,Noop(CALLERID: ${CALLERID(all)})
exten => _.,n,Goto(from-pstn,${EXTEN},1)

And ${EXTEN} is what they dialed to get in. Even the asterisk cli will show you right when the call makes it in the system

   -- Accepting call from '8305551111' to '3662500' on channel 0/6, span 1

So in this case ${EXTEN} holds the value 3662500. What exactly does the CDR report show you when a call comes in?

true. but we don’t want to delete, but keep it forwarding to the new person until people STOP using the old number. So having them suddenly go to the any/any defeats the purpose…

The issue with having it roll to the any/any is I called Jenny’s number but now I get the x greeting, so let’s check the directory and Jenny does not exist so who do I talk to now? when instead the current system is you call Jennys number and it gets forwarded to Mary, She then explains Jenny is nolonger there and you should call me at my number instead.

in the reports Tab this is what we see:
5. 2008-01-01 07:39:09 Zap/1-1… 8009323822 “RAPID RESPONSE” <8009323822> 145 ANSWERED 01:01
6. 2008-01-01 07:38:13 Zap/1-1… 8009323822 “RAPID RESPONSE” <8009323822> 145 ANSWERED 00:33

the Master.CSV shows this.
"",“8009323822”,“145”,“from-did-direct”,""“RAPID RESPONSE”" <8009323822>",“Zap/1-1”,“SIP/145-09d87010”,“VoiceMail”,“145@default|u”,“2008-01-01 07:38:13”,“2008-01-01 07:38:34”,“2008-01-01 07:38:46”,33,12,“ANSWERED”,“DOCUMENTATION”

Now I know that they called xxx 758 7945 directly. But that info is NOT recorded anywhere.

fskrotski,
you’ve been off the IRC all day - was going to get on there and give you a suggestion and then you could write up the solution you came up with. I notice from your above Master,CSV file though that you may have other config issues so when you are back on we can discuss and then you can summarize here what solution you come up with.

Ok, but you could make an inbound route for that DID to go to the new person’s phone. I guess that’s pretty much the same thing as forwarding it and doesn’t really solve the “where did it come from” problem, though. :slight_smile:

Oh, a workaround would be to have the DID go to a ring group where you could tag the CID with the DID number, then deliver to the new person’s phone. Then the CDR will have the tagged CID that you could search on.

Yea regular work got into the way. several servers down with hardware problems. Spent all day with repair people swapping out parts to fixing things… I don’t have IRC access in our Data center. see you in the morning…

So philippel I did what you said to do in IRC and I had to change it up a bit to make it work. You said to use the hangup macro to set the field but I had to do it on the incoming call context (no big deal) it works fine and the Master.csv has the info now. The only problem is that the mysql cdr database does not share this info. Do you know why it would not be inserting this info?? I looked at the full log output and I see its just not getting the info to insert. Any suggestions how to get it in that mysql cdr db?

you should be able to do it in the hangup macro as well by overriding the macro but what ever way works for you is good. For the MySQL database, make sure you have “userfield=1” set in cdr_mysql.conf. And you’ll probably have to reload the module or just restart asterisk for it to take.

that fixed it. Do you happen to know what other options are supported in that conf file?

I just look in the source code when I need to see what else is needed - it’s usually the most authoritative answer:)

Can someone share more details on how to display DIDs in the CDR reports please? I would be interested in that also.

Thanks,
Kamel

If yes, can you please share what you had to do to display DIDs or at least pointers to what the solution looks like?

thanks,
kamel

please share how you did it?

Thanks

Okay,
After about 2 hours of trying to find some information on how to select a certain number of
characters of the SIP_HEADER, It looks like this and seems to be working perfectly…

[macro-hangupcall]
exten => s,1,Set(CDR(userfield)=${SIP_HEADER(To):16:10})
exten => s,n,ResetCDR(w)
exten => s,n,NoCDR()

The CID from most providers is only going to be 12 Characters as that is all that is allowed in the CNAM database. Plus a few more from the SIUP header to take away to get to the beginning of the DID that is called, and then you want to count 10 characters over…

I dont know how this is going to work on PRI Circuits, but it is just what the doctor oredered for a few clients…

I have also built a reporting add-in fo rthe reports section of freepbx that will allow you to include a bunchof DID’s you want to trak, and then will email you at different intervals so you can track them easily…

The SIP_HEADER field does not exist in non SIP circuits, like T1/E1/PRI. The standard use of Set(CDR(userfield)=${FROM_DID}) works. Thanks for posting the way to get SIP info out as many ask for it.

There might be a minor issue with using it if you have them call in and connect to a meetme setup, I’m checking into that as the records I have don’t show the correct info currently.

This doesn’t seem to work on inbound faxes.
Is there anyway to get that info?