Outgoing Missed CDR
To receive the outgoing missed cdr, you must complete the webhooks setup. After completing the webhooks setup, our TeleCMI platform will notify your web server POST or GET method URL with JSON call detail record(CDR) when an outgoing call missed.
Sample CDR response
This is the sample JSON Call Detail Record(CDR) where the TeleCMI platform will notify your web server POST or GET method URL.
- Leg A
- Leg B
{
virtual_number: '440000000000',
call_id: 'c4504776-d91e-123b-29a7-56000429abc3',
custom: '{"crm":"true"}',
leg: 'a',
type: 'cdr',
appid: 2222223,
to: 442000000000,
cmiuuid: '15b58236-734f-4000-a5e8-78284068f5c7',
status: 'missed',
user: '202_2222223',
time: 1650628175336,
direction: 'outbound',
hangup_reason: 'recv_cancel',
request_id: 'D8qpRb27mpXEYgEdAMY6arnQ2ONAB04Y86QrfKbOWZQ',
extra_params: '{"click2call":"true"}'
}
{
virtual_number: '440000000000',
call_id: 'c4504776-d91e-123b-29a7-56000429abc3',
custom: '{"crm":"true"}',
leg: 'b',
type: 'cdr',
appid: 2222223,
to: 442000000001,
cmiuuid: '7686c396-ecdf-436d-9633-94c307f093e7',
status: 'missed',
user: '202_2222223',
time: 1650628237610,
direction: 'outbound',
hangup_reason: 'sent_reject',
request_id: 'bsGsOLY9QBUc6URW5olXiGmO58cDH6X3VetRFjZjfKS',
extra_params: '{"click2call":"true"}',
}
The above sample JSON Call Detail Record(CDR) consists of several properties. Each property has a description, so take a look at it.
Properties
This is the list of properties and their descriptions.
Property | Type | Description |
---|---|---|
virtual_number | string | The caller ID of the outbound call. |
call_id | string | A unique ID of an outbound call. |
custom | string | Your custom parameters. |
leg | string | Define the leg of the call either a or b. |
type | string | Type of notification from TeleCMI platform it may be cdr or event. |
appid | number | Your app id. |
to | number | The call was made using this number. |
cmiuuid | string | A unique identifier for this call. |
status | string | The status of this missed call. |
user | string | A unique ID of the user. |
time | number | A timestamp indicates the time the call was missed. |
direction | string | The direction of this call is outbound. |
hangup_reason | string |
|
request_id | string | A unique identification of this call was initiated through click2call. |
extra_params | string | Your custom parameters for click2call. |
Note
The request_id and extra_params will be sent, when the outbound call is initiated through click2call.
Implementation
TeleCMI webhooks implementation in different languages.
- Python
- Node.js
- PHP
- Java
from flask import Flask,request
app = Flask(__name__)
# Receive webhooks from TeleCMI platform when call receive or make
@app.route("/webhook/cdr",methods=['POST'])
def hello():
# Received JSON CDR from TeleCMI Platform
cdr = request.get_json()
print(cdr)
return "got it"
if __name__ == "__main__":
app.run(debug=True, port=5000)
const express = require('express'),
bodyParser = require('body-parser'),
app = express();
// parse application/json
app.use(bodyParser.json());
app.post('/webhook/cdr',(req,res)=>{
//Received CDR JSON Object from TeleCMI platform
var cdr = req.body;
console.log(cdr);
res.send('got it');
})
app.listen(5000);
app.run(debug=True, port=5000)
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
$app = new \Slim\App;
$handler = function (Request $req, Response $res) {
$cdr = $req->getParsedBody();
error_log(print_r($cdr, true));
return $res->withStatus(204);
};
$app->post('/webhook/cdr', $handler);
$app->run();
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package telecmi_example_java;
import static spark.Spark.*;
import com.cedarsoftware.util.io.JsonWriter;
public class App {
public static void main(String[] args) {
port(5000);
post("/webhook/cdr", (req, res) -> {
System.out.println("You got CDR from TeleCMI Platform");
String cmiJSON = JsonWriter.formatJson(req.body());
System.out.println(cmiJSON);
res.status(204);
return "";
});
}
}
To know more about testing webhooks for local development purposes, go to examples.