After Call Webhook

After Call Webhook

Overview

Webhooks are HTTP callbacks that receive notification messages for events. MyOperator uses webhooks to notify your application any time a call event happens in your account. For example, if a call has been received by your agent, you will receive a webhook during the call (incall webhook), and after the call has finished (aftercall webhook).

After-call webhook is the feature of MyOperator which is used to share the call data at the end of every call through HTTP request.

Purpose

After-call Webhook enables clients to do actions on the data at the end of every call. Webhook data can be used to do the below things at the client's end:
  1. Collect call data in the datastore at the client's end.
  2. Invoking custom integrations like adding a lead in the CRM.
The call log records all associated information related to the given call. After each call, we send the same log via webhooks. How we send the log (in post body or GET params) depends on the type of webhook requested by the client.

Components

A webhook is made up of components. Each component allows you to configure certain parts of the webhook. This gives you the flexibility in configuration each part of the webhook separately.

Target URL

Target URL allows you to configure your webhook listener URL. When you code your system, which will receive the data after each call, you give the url for that code in this input.


Method

There are two types of methods supported by webhooks:
  1. GET
  2. POST

GET

GET Method, as the name suggests, will send a webhook using HTTP GET requests. This means you will need to look for in your GET requests for data. We use query parameters to send the data that you have set.

Hence, the request looks something like this:

curl -X GET http://your-service-url.com/webhook.php?parameter1=<call log value>&parameter2=
 <another call log value>

To get the above data in your code (PHP sample):


// If you have set Query string parameters, you can still get them here too.
$some_value = $_GET['parameter1'];

In the above example, you can see that parameter1 and parameter2 seem important. These parameters contain certain call log information. For example, parameter1 may have the caller's number, and parameter2 might have the call duration. To know how to configure these parameters in detail, see the Query parameter section

POST

POST method sends an HTTP POST request to your webhook listener. This allows you to take additional decisions based on the call log. This is why we recommend you use the POST method.

We send the following data in POST format:

myoperator=
{
'_ai': '5f114f490dbe2437',
'_so': '1',
'_ci': '5cd40f6554442586',
'_cr': '9711636496',
'_cm': '',
'_cl': '+919711636496',
'_cy': '91',
'_se': 'DL, IN',
'_ts': 1594969967,
'_st': 1594969929,
'_ms': 1594969929000,
'_ss': 25929,
'_et': 1594969968,
'_dr': '00:00:39',
'_drm': 0.65,
'_ty': 1,
'_ev': 1,
'_fn': 'e673ba2e1747cb32960b19275f459c1869776c7b673901bb1f20ddd779117e93b148825cb28ce1d0.mp3',
'_fu':
'http:\\/\\/app.myoperator.co\\/audio\\/e673ba2e1747cb32960b19275f459c1869776c7b673901bb1f20ddd7
79117e93b148825cb28ce1d0',
'_ns': '0',
'_su': 1,
'_dn': 'sales',
'_di': '5cd40f6559784843',
'_pm': [{'ky': 'ui', 'vl': 'd5.1594969927.2496720'},
{'ky': 'is', 'vl': '0'},
{'ky': 'vt', 'vl': '2'},
{'ky': 'ic', 'vl': '1'},
{'ky': 'ia', 'vl': '0'},
{'ky': 'ib', 'vl': '1'}],
'_cn': [{'_tx': 'asdfg',
'_cd': '5f114f54741cc966',
'_ce': 1594969940,
'_id': '5cd40f6556f2f124',
'_na': 'Sumit',
'_em': 'sumit.arya@myoperator.co',
'_ex': '10',
'_ct': '8586848544',
'_nr': '+918586848544'}],
'_ld': [{'_rst': '2020-07-17 07:12:28',
'_ds': 'ANSWER',
'_did': '1161568087',
'_rr': [{'_id': '5cd40f6556f2f124',
'_na': 'Sumit',
'_em': 'sumit.arya@myoperator.co',
'_ex': '10',
'_ct': '8586848544',
'_nr': '+918586848544'}],
'_tt': [],
'_su': '1',
'_st': 1594969959,
'_et': 1594969968,
'_dr': '00:00:09',
'_ac': 'received'}],
'_an': 0,
'_bp': [{'_tm': [{'type': 'local', 'use': 1}],
'_ti': [{'type': 'local', 'use': 0}],
'_ta': [{'type': 'local', 'use': 0}],
'_tr': [{'type': 'local', 'use': 1}]}],
'_us': [{'ky': '5cd40f6556f2f124', 'vl': 'received'}],
'_tc': [{'ye': '5cd40f6556f2f124', 'yf': 9}],
'_ri': '',
'_ji': '',
'_ivid': '',
'_cri': ''}

we send the data in POST body inside myoperator key. A basic cURL request for it looks like this:

curl -X POST http://your-service-url.com/webhook.php -d myoperator=<call log>

NOTE - We send the data in json format. So, you should json decode the data on your side to ensure the correctness of it. See the example below.

You can get the call log data from a POST webhook like this (PHP code sample):

$call_data = $_POST['myoperator'];
/*
The data is in this string format:
{"_ai": "xyz", "_ci": "123abc", ...}
Hence you should decode it to array to get particular call data
*/
$call_data_array = json_decode($call_data, true);


// get caller's number
$caller_number = $call_data_array['_cr'];


/*
Remember, POST request doesn't mean you won't get query parameters.
If you have set Query string parameters, you can still get them here too.
*/


$caller_numer = $_GET['caller_number'];

This component allows you to send any custom headers with the webhook request. Headers is a way to pass any key value pair from our side.

Suppose, in your code, you want to verify if the request is actually coming from our side, and not from someone outside or hackers, you can easily check this using headers.

You can set any secret token in this component, which we will append in the webhook request before sending it to your service. Once you receive a request from us, you can check if the header has the secret token. If it does, you can confirm we are the one sending the request.

Example:
Suppose, you set the header:

["my-super-secret-token: abc123def"]

Then we will send this cURL request to your webhook listener:

curl -X POST http://your-service-url.com/webhook.php -H 'my-super-secret-token: abc123def'

which you can check like this (PHP code sample):

$my_secret_header = $_SERVER['HTTP_my-super-secret-token'];


if( $my_secret_header == 'abc123def' ) {
// Request come from MyOperator webhook echo "Good";
} else {
// Request didn't came from MyOperator webhook echo "Bad";
}

Credentials

Sometimes, you may have a service which requires authentication. There are several types of possible authentications, such as, OAuth, Basic, API Key based, etc.

However, we only support BASIC auth for now. If your service has BASIC Auth enabled, You can configure the username and password in this component. The format we use is
{"username": <your username>, "password": <password>}

For example, if my service has "admin" as username and "123456" as a password, I will enter the following in the panel:

{"username": "admin", "password": "123456"}

When we detect that you have configured your credentials, we will invoke the webhook with credentials.

curl -u admin:123456 http://your-service-url.com/webhook.php

Log Criteria

This component allows you to choose which type of data you want to receive from webhook. Sometimes, you want the call log (from panel), while sometimes, you want to receive mobile logs only. In this component, you can only pick one out of two.

If you want both the call logs and mobile logs, you can create two webhooks - one for call logs and one for mobile logs.

Query string parameters

This section is the most important of all. In this component, you can pick which part of the call log you are interested in receiving.

This component allows you to mention a name, and map it to a particular call record value you are interested in. Once you choose a name and map it to a value, we will send the webhook to you with that name in the query parameters.

For example, let's say you are interested in receiving the caller's number. You can choose the name to be "caller_number" (do not put spaces and URL encodable values in the name). From the dropdown, pick "Caller number with country code". Once you save, we will send the webhook to your webhook listener like this:

curl -XGET http://your-service-url.com/webhook.php?caller_number=+919876543210

So, you can get the caller_number in your code (PHP code sample) like:

$caller_number = $_GET['caller_number']; 
echo $caller_number; //+919876543210

The dropdown, which you have selected the value from, is called query parameters fields. The description of each field is documented in the Query parameter fields section.

NOTE: If you have set the Method as POST, we will have sent the data like this:

curl -XPOST http://your-service-url.com/webhook.php?caller_number=+919876543210 -d myoperator=
<call log>

Query parameter fields

Query parameters are a set of key-value pairs. You configure which call log should be mapped to the key of your choosing. This section focus on explaining what each call log (from the dropdown) means, with an example.

Caller number with country code

This field gives the caller's mobile number, along with the country code. For example +919876543210

This field is the same as _cl in the Call log (the data that you receive in the POST body)

Caller number without country code

This field gives the caller's mobile number, without country code. This basically means the raw call data we got in call records. For example 9876543210

This field is the same as _cr in the Call log (the data that you receive in the POST body)

Creation date of log (epoch)

This field gives you the time (in UNIX Epoch format), in the UTC timezone when the log was created. For example 1577797873 (Tuesday, 31 December 2019 13:11:13)

Event of log

This gives you the type of call record. Possible values are:
  1. Incoming
  2. Outgoing

Status of log

This gives you the overall call status of the record. Possible values are:
  1. Connected (the call was picked by at least one agent and for some non zero duration)
  2. Missed (the call was dialed by never picked by any of the agents)
  3. Voicemail (call landed on voicemail)

UID

We use UID as a unique identifier for each call. Each call log has its own UID. It helps us trace the call and routes. An example UID looks like: s5.347638.78643857

This field is the same as _pm.ui in the Call log

Company ID

Company ID gives you the company in which the call took place. It can help you get the company details and in which country the agent was in. It is alphanumeric in nature. Example: abc123.

This field is the same as _ci in the Call log.

User's phone number

This gives you the agent's contact number who picked up the call(in incoming cases) or dialed the number (in outgoing cases). An agent represents a user within a company. Agent contact number contains 10 digits contact number, without country code. For example- 9876543210

This field is the same as _ld._rr._ct in the Call log.

Department name

This field provides the name of the department that the call went through. For example- Sales department.

This field is the same as _dn in the Call log

Recording file name

This field gives you the call recording file name. For example, 9bb6eab4c44519dsdkhj884d3d40b3995991d9.mp3

This field is the same as _fn in the Call log.

Recording URL

Use this field to download your call recording. This field gives you the link to the call recording. Note that, the only logged-in user is allowed to download the recording. For example, http://app.myoperator.dev/audio/9bb6eab4c44519dsdkhj884d3d40b3995991d9

This field is the same as _fu in the Call log.

Start time of call (epoch)

This gives out the call start time in UNIX Epoch format. For example, 1577085001 (which translates to Monday, 23 December 2019 07:10:01). To convert unix epoch to human date format, you can use https://www.epochconverter.com/

This field is the same as _st in the Call log.

End time of call (epoch)

This gives out the call end time in UNIX Epoch format. For example, 1577085001 (which translates to Monday, 23 December 2019 07:10:01). To convert unix epoch to human date format, you can use https://www.epochconverter.com/

This field is the same as _et in the Call log.

Log push timestamp (microseconds)

This field gives the exact time (in microseconds, unix epoch format) at which this call log was pushed via webhook to your webhook listener (URL). Example: 1577971356261. To convert unix epoch to human date format, you can use https://www.epochconverter.com/

Unique caller id

Each call that we have in our system has a unique caller id attached to it. It helps us identify the entire call record as well as other call-related queries. This field gives the unique caller id (an alphanumeric string). For example: 5e01684774c24532.

This field is the same as _ai in the Call log.

Location

This field gives the location of the caller present in the call log. We record the location in (State, Country) format. The country is a 2 digit short representation of country name (ISO 3166 format).

If we are unable to locate the state, we only record the country code. For example: "DL, IN" represents a caller location in New Delhi, India.

Whole log data

Use this option to get all the call data in the request. Explanation of each call log field is explained in the section: Call log

Status of log

This field gives you the entire call status. A call can have the following statuses:
  1. Connected (A call was picked by at least one agent)
  2. Missed (A call was picked by no agent)
  3. Voicemail (Call landed on voicemail)
Each status gives you a basic understanding of the whole call. We also give this status in integer format, when you select the "Status of log(integer format)" option:
  1. (Connected)
  2. (missed)
  3. (voicemail)
Additional statuses are also provided if you chose the type of log to be SMS.
  1. (Success - SMS sent successfully)
  2. (Failed - SMS sending failed)

Duration (hh:mm:ss)

This field gives the call duration in hh:mm:ss format. Example: 00:01:22 (represents 1min and 22 seconds call).

This field is the same as _dc in the Call log.

Formatted duration

This field gives the call duration in minutes. Example: 1.37 (represents 1min and 22 seconds call).

Department id

This field gives the department id of the department in the call. For example, if the call landed in the sales department, this will give you the sales department id. Example: 5da80d5d1cb3c532

Custom

You can also set any type of custom key-value pair to be included in the webhook request. Selecting this option will allow you to set a custom key to the name of your choosing.

Call Log

A call log is a hashmap (key-value pair) composed of several short field names with their values, related to the call. The call log is in JSON format. We use short field names to save bandwidth and storage requirements. However, it may become difficult to understand the field meaning, hence this section explores the fields, with their meanings, as well as example value inside it.

Log Field name

Description

Example

_an

Is Anonymous User

1=yes, 0=no

_ai

Call log id (unique for each call)

abcdef123

_cl

Caller's number (formatted)

+919876543210

_cr

Caller's number (raw)

919876543210

_cm

Caller's contact name (if found)

My Contact

_cy

Caller's contact country code*

My Contact

_ev

Call event type (1=incoming/2=outgoing)

1= incoming, 2= outgoing

_fu

Call recording file link

http://myoperator.co/audio/abc

_fn

Call recording file name

abc.mp3

_ts

Log timestamp (unix epoch)

1572505408

_ms

Log timestamp (unix epoch) in milliseconds

1572505408000

_st

Call start time

1572505408

_et

Call end time

1572505438

_ss

diff b/w call end time and start time in seconds

31131

_ns

Notification Status

1 = clickocall, 2 = obd, 3 = webrtc

_se

call location*

RJ,IN

_su

Status of call

1 =connected, 2 =missed, 3 =voicemail

_so

Call source (IVR/Mobile)

1 =IVR, 2 =Mobile

_ci

Company id

abc123

_dr

Call duration (hh:mm:ss)

00:06:23

_drm

Call duration (in minutes)

6.38

_di

Department id

5c80e49e7d452564

_dn

Department name

sales

_ty

Call log type

1 =call, 2 =sms

_ri

Reference id (obd v2 calls)

abcdef123

_ji

Obd v2 job id

abcdef123 - obd v2 call, empty - otherwise

_ivid

Public IVR ID

abcdef123

_cri

Client reference id (obd v2 calls)

abcdef123 - obd v2 call, empty - otherwise

_ld._rst

Ring start time(In GMT)

2019-12-04 11:22:30

_ld._rr._na

Agent Name

Agent Sharma

_ld._rr._id

Agent id

abcdef123

_ld._rr._em

Agent email id

agent@example.com

_ld._rr._ct

Agent contact number

9876543210

_ld._rr._nr

Agent contact number with country code

+919876543210

_ld._su

Status of call

1= connected, 2= missed, 3=voicemail,

4=success

_ld._st

Call start time

1572424745

_ld._et

Call end time

1572424750

_ld._dr

Call duration

00:00:05

_ld._ds

Dial String

ANSWER/NOANSWER/CANCEL

_ld._did

Last Caller Id (used in callback)

abcdef123

_ld._ac

Call status

received/missed/transferred

_ld._tt._na

Transferred Agent Name

Agent Sharma

_ld._tt._id

Transferred Agent id

abcdef123

_ld._tt._em

Transferred Agent email id

agent@example.com

_ld._tt._ct

Transferred Agent contact number

9876543210

_ld._tt._nr

Transferred Agent contact number with country code

+919876543210

_pm._ky

ui = Call UID

s4.1572424727.994

_pm._ky

is = Is Call starred

0 = not starred, 1 = starred

_pm._ky

ic = Is Commented

1 = yes, 0 = no

_pm._ky

ia = Is archived log

1 = yes, 0 = no

_pm._ky

ib = Is Billable log

1 = yes, 0 = no

_pm._ky

vt = View Type

1 - personal, 2 - public/corporate


Need Help?

In case of any query please contact the support team at support@myoperator.co. Or generate a support ticket from MyOperator Panel.


    • Related Articles

    • In-Call Webhook

      Overview Webhooks are HTTP callbacks that receive notification messages for events. MyOperator uses webhooks to notify your application any time a call event happens in your account. For example, if a call has been received by your agent, you will ...
    • How to add after-call webhook in the panel?

      Please add the following after-call webhook in the panel. Login MyOperator→ Manage→ API Integration→ Webhook→ Add new (AfterCall Webhook) Method: POST URL: https://connect.myoperator.com/api/1.1/wf/phonebridge_aftercall/ Content-Type: JSON Save it
    • How to add in-call webhook in the panel?

      Please add the following incall webhook in the panel. Login MyOperator→ Manage→ API Integration→ Webhook→ Add new (InCall Webhook) Method: POST URL: https://connect.myoperator.com/api/1.1/wf/phonebridge_incall/ Content-Type: JSON Save it
    • How a webhook works?

      The following image can explain how a webhook work. Now lets see what are the steps to be followed: 1. Login to your MyOperator panel and click on “Manage” at the top. 2. In the funtionality section click on “API integration”. 3. From the left list, ...
    • What is webhook?

      Webhook is HTTP push API, delivers real-time call information to other applications. It is an incredibly useful and a resource-light way to implement event reactions.  Web hooks provide a mechanism where by a server-side application can notify a ...