Webhooks Setup
The PIOPIY platform will notify your web server POST method URL with JSON CDR (Call Detail Record) when incoming and outgoing calls are completed.
How to setup webhooks ?
To set up webhooks for receiving Live Events and CDR (Call Detail Record) from the PIOPIY platform, follow these steps:
1. Login to the Dashboard :
- Go to the PIOPIY dashboard and login.
2. Access App Details :
- Your app id and app name will be displayed in the panel, click the app id and enter into the dashboard.
Where to place your web server URL ?
1. Create a public URL using ngrok :
- To expose your local server to the internet, use ngrok to create a public URL:
ngrok http 5000
- You will receive a public
ngrok
URL, for example:https://7dc6-103-163-248-90.ngrok-free.app
.
2. Enter Your URLs in the Dashboard :
- In the CDR URL section of the PIOPIY dashboard, paste your
ngrok
URL (e.g.,https://7dc6-103-163-248-90.ngrok-free.app/cdr
).
- In the Event URL section, paste your event handler URL (e.g.,
https://7dc6-103-163-248-90.ngrok-free.app/event
).
3. Map the URLs :
- Once you've entered the URLs, click the MAP APP button to successfully map your webhook URLs to your app.
4. Run Your Local Server :
- Node.js
- Python
- If you're using Node.js, run your server with the following command:
// server.js file
const express = require("express"),
bodyParser = require("body-parser"),
app = express();
app.use(bodyParser.json());
app.post("/cdr", (req, res) => {
console.log("CDR Received:", req.body);
res.send("Received");
});
app.post("/event", (req, res) => {
console.log("Event Received:", req.body);
res.send("Received");
});
app.listen(5000, () => {
console.log("Server running on port 5000");
});
Run the code :
- Execute the code using Node.js:
node sever.js
- If you're using Python, run your server with the following command:
# server.py file
from flask import Flask, request
app = Flask(__name__)
@app.route("/cdr", methods=["POST"])
def inbound():
print("CDR Received:", request.get_json())
return "Received"
@app.route("/event", methods=["POST"])
def event():
print("Event Received:", request.get_json())
return "Received"
if __name__ == "__main__":
app.run(debug=True, port=5000)
Run the code :
- Execute the code using Python:
python server.py
Note
- Your web server URL is the POST method.
- Ensure that your web server URL (e.g.,
ngrok
URL) is publicly accessible from the internet.
Now your webhook setup is ready to receive Live Events and CDR (Call Detail Record) from the PIOPIY platform.