20 CDR and Call Recordings

the PortSIP PBX has an inbuilt CDR service that provides complete real-time data for all calls. When a call is completed, the call detail record can be pushed to another application instantly via WebHook or WebSocket.
The record contains various call details such as time, date, duration, source and destination addresses, numbers, as well as cost. PortSIP goes a step further adding much more information such as call types, call information, From and To names, and final display names crucial when call transfers occur.

Call Recording

The tenant administrator can select the menu Call Statistics > Call Recordings to view all recording files. Double-click the recording record, the recording file can be downloaded or played.
Click the Action button will pop-ups the menu, allowing you to navigate to the CDR of this call.
PortSIP PBX allows you to control the call recording in two levels.

User Level

To enable/disable call recording for a user, follow these steps: Click the “Call Manager” menu, then click “Users”. Double-click the user you want to modify, and in the “Extension” tab, you can turn on/off the “Record Audio Calls” or “Record Video Calls” options.
If “Record Audio Calls” is enabled, the call of this user will be recorded as a WAV file, even if the call is a video call. If “Record Video Calls” is enabled, the call of this user will be recorded as an MP4 file if the call is a video call.

Tenant Level

The tenant administrator has the ability to enable/disable the call recording for all users of this tenant.
Click the left menu "Company", on the "General" page, under the "Options" section, you can turn on/off the "Enable extension audio recording" or "Enable extension video recording" options.
If “Enable extension audio recording” is enabled, the call of a user will be recorded as a WAV file, even if the call is a video call. If “Enable extension video recording” is enabled, the call of a user will be recorded as an MP4 file if the call is a video call.

Automatically stop recording if the call between two external numbers

In some countries, due to privacy and security concerns, the law stipulates that when a call is made between two external numbers, it is not recorded. Consider the following scenario: The client calls the contact center from the trunk, and the agent answered, the call is recorded, and after a while of conversation, the agent transfers the client’s call to another mobile phone number. At this point, the call recording should stop.
PortSIP PBX provides corresponding features to support this regulation. The system administrator can click the menu Advanced > Settings, on General Page, and turn off the “Record the call between external numbers” option so that when the call is transferred to be made between two external numbers, the call recording will automatically stop.

Pause/Resume Recording

PortSIP PBX allows Pause/Resume of the call recording during the call.
  • Dials FAC *48 will pause the call recording during the call
  • Dials FAC *49 will resume the call recording during the call
The client APP or IP Phone can also pause/resume the call recording by sending the out-of-dialog SIP message to the PBX, the message should be as below:
MESSAGE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.16:5568;branch=z9hG4bK-524287-1---a67ad51a25df052f;rport
Max-Forwards: 70
From: <sip:[email protected]>;tag=fa2d6f1d
Call-ID: SFNH1yZ5c4LrG70_Tlyxgg..
CSeq: 3 MESSAGE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, REGISTER, SUBSCRIBE, INFO, PUBLISH
Content-Type: plain/x-media-control
Proxy-Authorization: Digest username="101",realm="test.io",nonce="13323933303:c8b6b255488669affb8a3e657188569a",uri="sip:[email protected]",response="da014b313dde19ff29c82043404af10f",algorithm=MD5
User-Agent: abcd
Allow-Events: hold, talk, conference, dialog
Content-Length: 21
{ "operation" : "pause-audio-recording", "session_id" : "5984923794364"}
In the above out-of-dialog message, the message body should be in JSON format. The operation indicates whether to pause or resume recording and the session_id specifies the call session ID. You can obtain this ID from the X-Session-Id header in the INVITE or 200 OK SIP message.
You can also use an in-dialog message to pause or resume recording. The message would look like this
MESSAGE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.16:5568;branch=z9hG4bK-524287-1---a67ad51a25df052f;rport
Max-Forwards: 70
From: <sip:[email protected]>;tag=fa2d6f1d
Call-ID: SFNH1yZ5c4LrG70_Tlyxgg..
CSeq: 3 MESSAGE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, REGISTER, SUBSCRIBE, INFO, PUBLISH
Content-Type: plain/x-media-control
Proxy-Authorization: Digest username="101",realm="test.io",nonce="13323933303:c8b6b255488669affb8a3e657188569a",uri="sip:[email protected]",response="da014b313dde19ff29c82043404af10f",algorithm=MD5
User-Agent: abcd
Allow-Events: hold, talk, conference, dialog
Content-Length: 21
pause-audio-recording
For the in-dialog message, the message body is plain text.
The PBX supports the following message commands:
  • pause-audio-recording: pause the audio recording for the call
  • pause-video-recording: pause the video recording for the call
  • resume-audio-recording: resume the audio recording for the call
  • resume-video-recording: resume the video recording for the call

CDR

After signing in as a tenant administrator, select the menu Call Statistics > CDR, and the CDR is listed. You can play or download the recording file if the call recording is enabled.
When you double-click a CDR, more call details are displayed. For example, if A calls B, then transfers B to a virtual receptionist, presses DTMF, and connects to a queue, and one of the queue agents answers, we can have the following CDR.

Push CDR to Webhook

You can collect the CDR by making an HTTP request to an external service or application every time a call is completed.
A webhook is a mechanism that allows you to call out to an external program based on events in PortSIP PBX.
Only the tenant administrator has the ability to enable/disable this feature.
Select "Company" from the left menu. On the "Event URL" page, turn on CDR Events. Choose an Authentication Method and enter your Webhook URL. The PBX will then push CDR events to your 3rd party Webhook.
Below is an example of a CDR. The call flow is caller > trunk > PBX IVR > Queue > Agent.
{
"answered_time":"1679476851",
"call_id":"b6PEEYEcn5speSovMAybCw..",
"callee":"5000",
"callee_domain":"test.io",
"caller":"1888722",
"caller_display_name":"",
"caller_domain":"192.168.0.16",
"did_cid":"18800606",
"direction":"in",
"ended_reason":"callee_disconnect",
"ended_time":"1679476870",
"event_type":"call_cdr",
"outbound_caller_id":"",
"ring_time":"1679476851",
"session_id":"690852418417594368",
"start_time":"1679476851",
"status_code":"0",
"tenant_id":"690833127458734080",
"tenant_name":"PortSIP Inc.",
"trunk_name":"AudioCodes"
"user_data":"",
"call_targets":[
{
"answered_time":"1679476851",
"call_type":"normal_call",
"callee":"5000",
"caller":"1888722",
"destination":"sip:[email protected]:8922",
"end_reason":"referred",
"ended_time":"1679476857",
"id":"690833127458734080",
"outbound_caller_id":"",
"ring_time":"1679476851",
"start_time":"1679476851",
"status_code":0,
"trunk_name":"AudioCodes"
},
{
"answered_time":"1679476857",
"call_type":"normal_call",
"callee":"8000",
"caller":"1888722",
"destination":"sip:[email protected]:8916",
"end_reason":"referred",
"ended_time":"1679476862",
"id":"690833127458734080",
"outbound_caller_id":"",
"ring_time":"1679476857",
"start_time":"1679476857",
"status_code":0,
"trunk_name":"AudioCodes"
},
{
"answered_time":"0",
"call_type":"normal_call",
"callee":"102",
"caller":"1888722",
"destination":"sip:[email protected]:9070",
"end_reason":"None",
"ended_time":"1679476862",
"id":"690833127458734080",
"outbound_caller_id":"",
"ring_time":"1679476858",
"start_time":"1679476858",
"status_code":0,
"trunk_name":"AudioCodes"
},
{
"answered_time":"1679476862",
"call_type":"normal_call",
"callee":"103",
"caller":"1888722",
"destination":"sip:[email protected]:9530",
"end_reason":"None",
"ended_time":"1679476870",
"id":"690833127458734080",
"outbound_caller_id":"",
"ring_time":"1679476858",
"start_time":"1679476858",
"status_code":0,
"trunk_name":"AudioCodes"
}
]
}
The CDR information is in JSON format and includes the following fields:
  • answered_time: The timestamp of when the call was answered in Unix timestamp format. In this example, this time represents when the PBX IVR answered. If the value is 0, it means the call was not answered.
  • call_id: The call ID of the call. In this example, it is the Call-Id of the INVITE that comes from the trunk to PortSIP PBX.
  • callee: The first callee number when the call arrived at PBX. In this example, it is PortSIP PBX IVR number 5000.
  • callee_domain: The SIP domain (tenant’s SIP domain) of the callee.
  • caller: The caller of the call from the trunk.
  • caller_display_name: The display name of the FROM header in the INVITE sent from the trunk.
  • caller_domain: The host part of the FROM header in the INVITE is sent from the trunk.
  • did_cid: The DID number was dialed from the trunk. It is also known as user part of TO header in INVITE sent from trunk.
  • direction: Indicates whether a call is inbound or outbound. “in” means inbound from trunk while “out” means outbound to trunk. If a call comes from and then forwards to trunk then direction will be “in2out”.
  • end_reason: Indicates why a call ended. Possible reasons include: caller_disconnect, callee_disconnect, replaced, referred, redirected, blind_transfer_complete, attended_transfer_complete and cancelled.
  • ended_time: Time when a call ended in Unix timestamp format
  • event_type: Indicates that this information pertains to CDR.
  • outbound_caller_id : Outbound Caller ID for outbound calls made to trunk with an outbound caller ID set up.
  • ring_time: Ring time of the call; for instance ring time for PortSIP PBX IVR 5000 ringing.
  • session_id: Session ID for calls also present in X-session-ID header of INVITE/200 OK message; can be used to query recording files.
  • start_time: Call start time represented as Unix timestamp for call arrived at PortSIP PBX.
  • status_code: If the call failed, this field indicates the status code as a SIP status code (e.g., 404 or 408). A value of 0 means there was no error.
  • tenant_id: When a call arrives at PBX, it is matched with all tenant inbound rules by DID. Once a rule is matched, the call is routed to that tenant and this field indicates the ID of that tenant who handles the call.
  • tenant_name: The name of the tenant who handles the call.
  • trunk_name: The name of the trunk through which the call was made.
  • user_data: If a call is launched via REST API, this field contains any user data passed in string format.
A call may have multiple targets. For example, if extension 101 is registered to PBX from both an IP Phone and an App simultaneously and someone calls 101, there will be two targets: one for the IP Phone and one for the App. Another example is when someone calls 101 and it rings but goes unanswered. After a while, the call is forwarded to 102 which rings and is answered. In this case, there are two targets: one for 101 and another for 102.
In our example, when a call comes in from the trunk, the first target is IVR 5000. The caller then presses DTMF 1 and the call is forwarded to Queue 8000 which becomes the second target. While waiting in the queue, agents 102 and 103 ring as third and fourth targets.
The target of the IVR 5000:
{
"answered_time":"1679476851",
"call_type":"normal_call",
"callee":"5000",
"caller":"1888722",
"destination":"sip:[email protected]:8922",
"end_reason":"referred",
"ended_time":"1679476857",
"id":"690833127458734080",
"outbound_caller_id":"",
"ring_time":"1679476851",
"start_time":"1679476851",
"status_code":0,
"trunk_name":"AudioCodes"
}
  • answered_time: The answer time of that call target in Unix timestamp format. A value of 0 means the call was not answered.
  • call_type: The type of call. Possible values include normal_call, queue_call, ring_group_call, callback and queue_callback.
  • callee: The callee of this target.
  • caller: The caller of this call.
  • destination: The IP address and port of this target.
  • end_reason: The reason why this target ended. In this case, since the caller pressed DTMF and the call was referred to the queue and this target (IVR) hung up, the end reason is "referred".
  • end_time: The time when this target ended in Unix timestamp format.
  • id: The ID of this target CDR in the database.
  • outbound_caller_id: If the target is a trunk and an outbound caller ID is set up for the call, this field will contain that outbound caller ID.
  • ring_time: The ring time for this target.
  • start_time: The time when a call to this target started is represented as Unix timestamp.
  • status_code: If a call to this target failed then status code will be SIP status code (e.g., 404 or 408). A value of 0 means there was no error.
  • trunk_name: Name of trunk through which a call to this target was made.

Push CDR to WebSocket Subscriber

You can collect the CDR by subscribing to the cdr event from an external service or application every time a call is completed.
A WebSocket subscription is a mechanism that allows you to receive the events in an external program from the PortSIP PBX.
Only the tenant administrator has the ability to subscribe to this event.
For more details please refer to this topic.