Outgoing Answered Event
Our TeleCMI platform will notify the following sample JSON Live Event to your web server POST or GET method URL, when an outgoing call is answered.
Sample event response
This is the sample JSON Live Event, where the TeleCMI platform will notify your web server via POST or GET method URL.
- Leg A
- Leg B
{
call_id: 'e51d5392-d9cf-123b-fe91-3cecefb9bfb6',
leg: 'a',
type: 'event',
user: '202_2222223',
cmiuuid: 'ccd826f9-67a4-4467-acfb-a53093ff5c9d',
direction: 'outbound',
callerid: '442000000000',
app_id: 2223343,
time: 1650635340436,
custom: '{"crm":"true"}',
extra_params: '{"click2call":"true"}',
request_id: 'bvS68LlqtFunYMQO0db6g9klSdfS0UHHDoK9S9Qvaed',
status: 'answered',
to: '442000000001',
conversation_uuid: 'ccd826f9-67a4-4467-acfb-a53093ff5c9d'
}
{
call_id: 'e51d5392-d9cf-123b-fe91-3cecefb9bfb6',
leg: 'b',
type: 'event',
user: '202_2222223',
cmiuuid: '81b3d612-3473-4ac3-ba6e-030ee508036f',
direction: 'outbound',
callerid: '442000000000',
app_id: 2223343,
time: 1650635340436,
custom: '{"crm":"true"}',
extra_params: '{"click2call":"true"}',
request_id: 'bvS68LlqtFunYMQO0db6g9klSdfS0UHHDoK9S9Qvaed',
status: 'answered',
to: '442000000001',
conversation_uuid: 'ccd826f9-67a4-4467-acfb-a53093ff5c9d'
}
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 |
---|---|---|
call_id | string | A unique ID of an outbound call. |
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. |
user | string | A unique ID of the user. |
cmiuuid | string | A unique identifier for this call. |
direction | string | The direction of this call is outbound. |
callerid | string | Caller ID on this call. |
app_id | number | Your app id. |
time | number | A timestamp indicates the time the call was answered. |
custom | string | Your custom parameters. |
request_id | string | A unique identification of this call was initiated through click2call. |
extra_params | string | Your custom parameters for click2call. |
status | string | The status of this answered call. |
to | string | The call was made using this number. |
conversation_uuid | string | A unique identifier of this overall conversation. |
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.