Incoming Missed Webhooks
To receive the incoming missed webhooks, you must complete the incoming webhooks setup. After completing the incoming webhooks setup, our TeleCMI platform will notify your web server POST method URL with JSON call detail record(CDR) when an incoming call missed.
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.
Sample CDR response
This is the sample JSON call detail record(CDR), where the TeleCMI platform will notify your web server POST method URL.
{
"appid": 1111113,
"type": "cdr",
"direction": "inbound",
"cmiuuid": "5f0fc753-064f-4c58-82d3-ce62f294fad3",
"status": "missed",
"from": 9110000000,
"time": 1570114018000,
"waitedsec": 119,
"team": "Support_1111113",
"voicemail": "true",
"voicename": "157009452516312171051293_919677551xxx.mp3"
}
The above sample JSON call detail record(CDR) consists of several properties. Each property has a description and take a look at it.
Properties
These are the list of properties and its description
Property | Type | Description |
---|---|---|
app_id | number | Your app id |
type | string | Type of notification from TeleCMI platform it may be cdr or event |
direction | string | The direction of this call it may be inbound or outbound |
cmiuuid | string | A unique identifier of this call |
status | string | Status of this call |
from | number | The number the call came from |
time | number | Timestamp of this call |
waitedsec | number | The duration of caller waited in seconds |
team | string | Name of the team where the call has waited |
voicemail | string | Voicemail is enabled |
voicename | string | The file name of the voicemail |