call legs logic

  • 1
  • Question
  • Updated 4 months ago
what is the logic of the call legs?
i mean - what's the rationale behind the creation of each leg?

i need to download call recordings. some times, the call has a few legs, each one has a recording element inside it. since i need to use the name of the caller and the called, how can
i decide, programmatically, which leg to use?
the names in the call's data ("to" \ "from" elements), most of the time if not in all cases, doesn't match the names in the legs' data ("leg.to" \ "leg.from" elements).

for instance, in the following call, there are 3 legs with recording elements.
what's the difference between them?

thanks,




        {
            "uri": URI,
            "id": ID,
            "sessionId": ID,
            "startTime": "2017-10-18T16:00:44.059Z",
            "duration": 60,
            "type": "Voice",
            "direction": "Inbound",
            "action": "Phone Call",
            "result": "Accepted",
            "to": {
                "phoneNumber": SOME_NUMBER
            },
            "from": {
                "phoneNumber": SOME_NUMBER,
                "name": SOME_NAME,
                "location": SOME_LOCATION
            },
            "recording": {
                "uri": CALL_URI,
                "id": ID,
                "type": "Automatic",
                "contentUri": CONTENT_URI
            },
            "transport": "PSTN",
            "lastModifiedTime": "2017-10-18T16:00:44.059Z",
            "billing": {
                "costIncluded": 0,
                "costPurchased": 0
            },
            "legs": [
                {
                    "startTime": "2017-10-18T16:00:44.059Z",
                    "duration": 60,
                    "type": "Voice",
                    "direction": "Inbound",
                    "action": "Phone Call",
                    "result": "Accepted",
                    "to": {
                        "phoneNumber": SOME_NUMBER
                    },
                    "from": {
                        "phoneNumber": SOME_NUMBER,
                        "name": SOME_NAME,
                        "location": SOME_LOCATION
                    },
                    "recording": {
                        "uri": SOME_URI,
                        "id": ID,
                        "type": "Automatic",
                        "contentUri": CONTENT_URI
                    },
                    "transport": "PSTN",
                    "billing": {
                        "costIncluded": 0,
                        "costPurchased": 0
                    },
                    "legType": "Accept"
                },
                {
                    "startTime": "2017-10-18T16:00:44.059Z",
                    "duration": 60,
                    "type": "Voice",
                    "direction": "Inbound",
                    "action": "Phone Call",
                    "result": "Accepted",
                    "to": {
                        "phoneNumber": SOME_NUMBER,
                        "name": SOME_NAME
                    },
                    "from": {
                        "phoneNumber": SOME_NUMBER,
                        "name": SOME_NAME,
                        "location": SOME_LOCATION
                    },
                    "recording": {
                        "uri": CALL_URI,
                        "id": ID,
                        "type": "Automatic",
                        "contentUri": CONTENT_URI
                    },
                    "transport": "PSTN",
                    "legType": "Accept",
                    "extension": {
                        "uri": SOME_URI,
                        "id": ID
                    }
                },
                {
                    "startTime": "2017-10-18T16:00:44.059Z",
                    "duration": 42,
                    "type": "Voice",
                    "direction": "Outbound",
                    "action": "FindMe",
                    "result": "Accepted",
                    "to": {
                        "phoneNumber": SOME_NUMBER,
                        "name": SOME_NAME,
                        "location": SOME_LOCATION
                    },
                    "from": {
                        "phoneNumber": SOME_NUMBER,
                        "name": SOME_NAME,
                        "device": {
                            "uri": ID,
                            "id": ID
                        }
                    },
                    "recording": {
                        "uri": CALL_URI,
                        "id": ID,
                        "type": "Automatic",
                        "contentUri": CONTENT_URI
                    },
                    "transport": "PSTN",
                    "legType": "FindMe",
                    "extension": {
                        "uri": ID,
                        "id": ID
                    }
                }
            ]
        },
Photo of Gaash Granot

Gaash Granot

  • 206 Points 100 badge 2x thumb

Posted 5 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 1,754 Points 1k badge 2x thumb
Hi Gaash,

This doc should give you an overall about call legs. https://www.hh.se/download/18.70cf2e49129168da015800092965/4_1_Call_Establishment_Principles.pdf.

Or the short description of call legs:
A voice call over a packet network is segmented into discrete call legs. Each call leg is associated with a dial peer. A call leg is a logical connection between two voice gateways or between a gateway and an IP telephony device.

Hope this helps,
+ Phong
Photo of Gaash Granot

Gaash Granot

  • 206 Points 100 badge 2x thumb
thanks! i'll read it in depth later on, but a first glimpse show that it's exactly what i needed!
:)
Photo of AK

AK, Official Rep

  • 4,362 Points 4k badge 2x thumb
Thanks Phong. 

Hi Gaash,

To add to Phong's answer, you can also look at the FAQ below on:
Using Detailed Call Log Data