Incoming Hangup Leg B
Our TeleCMI platform will notify the following sample JSON Live Event to your web server POST or GET method URL, when an incoming call hit on your virtual number and user hangup.
Sample event response
This is the sample JSON Live Event, where the TeleCMI platform will notify your web server via a POST or GET method URL.
{
leg: 'b',
type: 'event',
team: 'Sales_2222223',
user: '204_2222223',
conversation_uuid: '5202a928-07c3-4d32-a1a4-d304c9275971',
cmiuuid: 'f4c65be7-4b4d-4d38-8aa9-4392fab50bd8',
direction: 'outbound',
from: '440000000000',
app_id: 2222223,
time: 1634724629956,
custom: '{"crm": "true"}',
status: 'hangup'
}
The above sample JSON Live Event 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 |
---|---|---|
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. |
team | string | Name of the team where the call was hangup. |
user | string | A unique Id of the user. |
conversation_uuid | string | A unique identifier for this overall conversation. |
cmiuuid | string | A unique identifier for this call. |
direction | string | The direction of this call is outbound. |
from | string | The call was made from this number. |
app_id | number | Your app id. |
time | number | A timestamp indicates the time the call was hanged up. |
custom | string | Your custom parameters. |
status | string | The status of this hangup call. |
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.