Inbound Missed
To receive the inbound webhooks, you must complete the webhooks setup. After completing the webhooks setup, our PIOPIY platform will notify your web server POST method URL with JSON call detail record(CDR) when an incoming call got missed.
Implementation
PIOPIY webhooks implementation in different languages.
- Python
- Node.js
- PHP
- Java
from flask import Flask,request
app = Flask(__name__)
# Receive webhooks from PIOPIY platform when call receive or make
@app.route("/webhook/cdr",methods=['POST'])
def hello():
# Received JSON CDR from PIOPIY 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 PIOPIY 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 piopiy_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 PIOPIY 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 PIOPIY platform will notify your web server POST method URL.
- Leg A
- Leg B
{
to: 440000000000,
appid: 2222222,
time: 1632317071000,
start_time: 1632317068,
end_time: 1632317073,
from: 440000000001,
direction: 'inbound',
duration: 0,
extra_params: '{"key":"value"}',
cmiuuid: '33079756-faed-4a29-8b36-c8ead67e047c',
call_rate: 0,
balance: '899.000000',
conversation_uuid: '33079756-faed-4a29-8b36-c8ead67e047c',
leg: 'a',
status: 'missed',
type: 'cdr'
}
{
to: 440000000000,
appid: 2222222,
time: 1632317071000,
start_time: 1632317068,
end_time: 1632317073,
from: 440000000001,
direction: 'outbound',
duration: 0,
extra_params: '{"key":"value"}',
cmiuuid: '33079756-faed-4a29-8b36-c8ead67e047c',
call_rate: 0,
balance: '899.000000',
conversation_uuid: '33079756-faed-4a29-8b36-c8ead67e047c',
callerid: 19170000000,
status: 'missed',
leg: 'b',
type: 'cdr'
}
The above sample JSON live event 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 |
---|---|---|
to | number | Your incoming DID number |
app_id | number | Your app id |
time | number | Timestamp of this call |
start_time | number | The start time of this call |
end_time | number | The end time of this call |
from | number | The number who made a call |
direction | string | Direction of this call |
duration | number | The total duration of this call in seconds |
extra_params | string | Your custom parameters |
cmiuuid | string | A unique identifier of this call |
call_rate | string | The billed call rate for this call |
balance | string | The total available account balance after this call |
conversation_uuid | string | A unique identifier of this conversation |
callerid | number | The incoming DID number |
leg | string | Define the leg of the call either a or b |
status | string | Status of this call |
type | string | Type of notification from PIOPIY platform it may be cdr or event |