Call Direction
Call direction is a CDR field that indicates where the call initiated. In a traditional phone network, PSTN -> phone is considered "inbound" and phone -> PSTN is "outbound".
However, in a hosted PBX system:
- Inbound - indicates that the PSTN (phone/carrier) is calling the hosted PBX (inbound to hosted PBX).
- Outbound - indicates that the hosted PBX is calling the PSTN (phone/carrier) (outbound from hosted PBX).
When calls involve two phones there are multiple call legs:
PHONE A -> hosted PBX -> PHONE B
- PHONE A -> hosted PBX - is the inbound call
- hosted PBX -> PHONE B - is the outbound leg
Therefore, the call_direction
field of a CDR might not indicate the direction of the call as we typically understand it.
Interpreting direction of recorded calls
When call recording is configured, the "leg" being recorded includes the recording information in its CDR. If a leg is coming in from or going out to the PSTN, it includes a resource_type
field which tells you if the call originated/terminated from within the network (internal) or externally (external). By fetching all legs involved (using the interaction_id
), you can determine the direction of a call from the end user's perspective.
For example:
Type | Call Direction (A leg) | Resource Type (A leg) | Call Direction (B leg) | Resource Type (B leg) | End User's Direction |
---|---|---|---|---|---|
A call comes in from the PSTN to a registered device on the hosted PBX. | inbound (from PSTN) | external-origination | outbound (from hosted PBX to the device) | undefined | inbound |
A call goes from a registered device to the PSTN | inbound (from a device) | undefined | outbound (to the PSTN) | external-termination | outbound |
Info
The call legs between the hosted PBX and device do not have a resource type.
These scenarios can become complicated in the following examples:
- A call comes in from the PSTN and is then sent to a device with call-forwarding enabled (using PSTN). Both legs have
resource_type
set. - When a device calls another device, no
resource_type
exists on either leg. - When a call is transferred or parked/picked up (sometimes multiple times).
!!! info"Tip"
The leg where the call recording started displays media_recording_id
in the leg's CDR under the custom_channel_vars
object.
For more information about call recording specifically, see Call Recording.