Webhook

A webhook can be configured in order to push CDRs to your own platform or API endpoint. When a new CDR is created on our system, a POST request will be sent with the CDR details. This is used when you either need to keep information about the call being made or to activate an application after a dial or an inbound call is made.

On installation, the webhook is not enabled by default. If it’s to be used, check it’s enabled.

An Endpoint needs to be configured where the CDR are going to be submitted at https://HOSTNAME/admin/user_profile/staff/1/change/. Put the URL that you want to use in the ‘Webhook Endpoint’ field

_images/admin-create-webhookendpoint.png

The Webhook comes with a UI on the admin, https://HOSTNAME/admin/webhook/webhook/ and it has a retry mechanism, which ensures that CDRs are pushed correctly. If there is an error, for instance your endpoint didn’t accept the API call, it will be displayed on the UI.

_images/admin-webhookcdr.png

The Webhook endpoint needs to accept the POST method, all the following fields will be sent:

* cdr_id:
    type: "string"
    description: "CDR API id. ie GET /rest-api/cdr/<id>"

* callerid:
    type: "string"
    description: "Caller id presented used by the dialer"

* callrequest_id:
    type: "string"
    description: "Dialer root call id"

* call_id:
    type: "string"
    description: "Dialer FreeSwitch call id"

* user_id:
    type: "number"
    description: "User ID"

* campaign_id:
    type: "number"
    description: "Dialer campaign id"

* campaign_name:
    type: "string"
    description: "Dialer campaign name"

* leg_type:
    type: "number"
    description: "Call leg type"

* phone_number:
    type: "string"
    description: "Phone number of the lead"

* gateway_id:
    type: "string"
    description: "Gateway Id used by the dialer to place the call"

* amd_status:
    type: "number"
    description: "AMD status returned by dialer"

* hangup_cause_code:
    type: "number"
    description: "Hangup cause code returned by dialer"

* disposition:
    type: "string"
    description: "Call disposition/Hangup cause string returned by dialer"

* lead_disposition:
    type: "string"
    description: "Lead disposition - Agents will mark a contact with this disposition"

* lead_disposition_id:
    type: "string"
    description: "Lead disposition ID - Agents will mark a contact with this disposition"

* cost:
    type: "number"
    description: "Cost of the dial"

* billed_duration:
    type: "number"
    description: "Billable time"

* incremental_duration:
    type: "number"
    description: "Incremental duration on the CDR record"

* call_date:
    type: "string"
    format: "date-time"
    description: "Timestamp of when the dial was placed"

* url_bleg_recordings:
    type: "array"
    description: "List of bleg (xfer) recordings"

* survey_result:
    DEPRECIATED!
    type: "array"
    description: "IVR/Survey interactions and results"

* extra_data:
    type: "array"
    description: "IVR/Survey interactions and results"
    example: "{\"survey_result\": [{\"result\": [\"Sub-Option\", \"\"], \"section_id\": 227}, {\"result\": [\"41\", \"\"], \"section_id\": 229}, {\"result\": [\"Recorded\", \"/usermedia/recording/bleg-recording-cr_6-ct_1-cpg_BANRSDS.mp3\"], \"section_id\": 230}]}"

* subscriber:
    type: "array"
    description: information about the subscriber/contact
    this will contain the following fields: {subscriber_id: Value, full_name: "Value", additional_vars: JSON}

* agent:
    type: "string"
    description: "Agent username to whom the call has been transfered/"

Additionally, there is an header ‘x-api-key’ which can be set for authentication.

Fields information

DISPOSITION:

This is the call disposition, a more simplistic version of hangup Q850.

It can be one of those values: ANSWER, BUSY, NOANSWER, REJECTED, CANCEL, CONGESTION, DNC, UNAUTHORIZED or FAILED.

The hangup_cause_code will translate like this:

  • 16 -> ANSWER
  • 17 -> BUSY
  • 19 -> NOANSWER
  • 21 -> REJECTED
  • 487 -> CANCEL
  • 42 -> CONGESTION
  • -1 -> DNC
  • -2 -> UNAUTHORIZED
  • others -> FAILED

HANGUP_CAUSE_CODE:

This is Q850, reference to https://freeswitch.org/confluence/display/FREESWITCH/Hangup+Cause+Code+Table

LEG TYPE:

It can be one of those values:

  • 1: A-Leg
  • 2: B-Leg
  • 3: COLD_XFER
  • 4: WARM_XFER
  • 5: WAY3_XFER

AMD STATUS:

It can be one of those values:

  • 0: NODETECT
  • 1: PERSON
  • 2: MACHINE
  • 3: UNSURE

Payload sample

Sample of the payload, a webhook will be sent for each call (CDR):

{
    "phone_number": "14155130001",
    "gateway_id": 2,
    "lead_disposition": "",
    "callrequest_id": "6",
    "cost": 0.0,
    "amd_status": 0,
    "callerid": "+1212450012",
    "lead_disposition_id": null,
    "url_bleg_recordings": [
        "/usermedia/recording/bleg-recording-cr_6-ct_1-cpg_BANRSDS.mp3"
    ],
    "incremental_duration": 6,
    "hangup_cause_code": 16,
    "campaign_id": 2,
    "call_id": "06991405-277b-4200-bad3-c3de5e0930b4",
    "leg_type": 2,
    "survey_result": {
        "phone_number": "14155130001",
        "Enter your age": "",
        "Press 1 to talk to an Agent  press 2 to go to the next option": "Agent",
        "transfer": "phonenumber: sofia/gateway/mygateway/14155130001",
        "Record a message": "",
        "disposition": "ANSWER",
        "Bye now!": "",
        "billsec": 6,
        "starting_date": "2020-03-10 19:04:31",
        "Transfering to agent": ""
    },
    "extra_data": {
        "survey_result": [
            {"result": ["Sub-Option", ""], "section_id": 227},
            {"result": ["41", ""], "section_id": 229},
            {"result": ["Recorded", "/usermedia/recording/bleg-recording-cr_6-ct_1-cpg_BANRSDS.mp3"], "section_id": 230}
        ]
    },
    "billed_duration": 6,
    "disposition": "ANSWER",
    "campaign_name": "Voice Campaign, Mar 10, 18:59",
    "original__phone_number": "",
    "cdr_id": "15",
    "call_date": "2020-03-10T18:04:31.000+00:00",
    "agent": "agent01"
}