Search code examples
asteriskcustom-fieldscdrelastix

How to save Remote Party ID to CDR in Asterisk?


I'm new to Asterisk so any help will be greatly appreciated.

I'm trying to save remote party ID (CONNECTEDLINE) in CDR logs table in transferred calls. In blind transfers there's no problem because I'm getting Remote Party ID as Caller ID in src field.

In attended transfers I'm loosing the original caller ID.

This is how transfer goes:

  1. A calls B (A talking with B)
  2. B holds A, and calls C (B talking with C)
  3. B transfers A to C (A talking with C)

Now, in CDRs table I'm getting two records. One for the first call (A<->B), and another for the two second calls (B<->C and A<->C). The point is in second CDR I have lost any reference to A.

I want to save Remote Party ID (A) in second CDR. I've already added a custom field to CDR table (connectedID).

I'm reading about editing some configuration files, adding this kind of sentences:

"exten => s,1,set(CDR(connectedID)=${CONNECTEDLINE})"

However, I'm quite lost. I don't know which file I need to edit, even in what part of file I should put these lines of code.

Could somebody point me in the right direction?


Solution

  • Reading call events via AMI (thanks to @arheops) I manage how to save Remote Party ID in CDR.

    In hangup event we can see Remote Party ID in ConnectedLineNum field.

    For a transferred call like this one:

    • 401 calls 208
    • 208 calls 308 (401 on hold)
    • 208 transfers original call to 308 (401 talking with 308)

    this is a hangup event sample for the final segment of the call.

    Event Hangup Privilege: call,all Channel: SIP/308-00000665 Uniqueid: 1421757614.1658 CallerIDNum: 208 CallerIDName: Juan Ruiz ConnectedLineNum: 401 ConnectedLineName: Test1 Cause: 16 Cause-txt: Normal Clearing

    Original caller is stored in ConnectedLineNum variable.

    So I add this line to the hangup section:

    exten => s,1,Set(CDR(connectedid)=${CONNECTEDLINE(number)})

    I'm using Elastix 2.4.0, so I've added this line at the beggining of the [macro-hangupcall] macro in extensions_override_elastix.conf file.

    In other Asterisk based distros it should be in another file.