This is demo for Webhook integration with Wildix infrastructure. For setup instructions, check this page
Install dependencies:
npm install
In this demo, we use the localtunnel
library to create a public URL for your local server.
You can use another library if needed (ngrok, etc.).
-
Open
src/server.js
and set your unique subdomain name (random string) -
Run Webhook server:
npm run webhook:serve
-
Copy & open the link from console in the browser
-
Confirm your public IP: paste your public IP to the form
-
Go to PBX and install Webhook integration with URL from step 3
-
Copy integration secret and paste it to the
src/server.js
, to the following field:
const secret = 'pasteCopiedSecretHere';
-
Restart the server with the correct secret (step 2)
-
Make calls and view logs in the server console
-
Open the file
src/sqs.js
; -
Set your
queueUrl
and yourAWS region & credentials
-
Run AWS SQS queue pooling:
npm run sqs:pool
- Make calls and view logs in the server console
{
"id": "it_w118741_1693389850.110",
"pbx": "221100001bab",
"time": 1693389850810,
"company": "it_w118741",
"type": "call:start",
"integrationId": "8qkmnq",
"data": {
"status": "CONNECTING",
"caller": {
"type": "LOCAL",
"phone": "1001",
"name": "admin",
"company": null,
"email": "vladimir.gorobets@wildix.com",
"userId": "1257510555",
"userExtension": "1001",
"userDepartment": null,
"groupId": "62177694",
"groupName": "Admin",
"userAgent": "Wildix Zero Distance 4.0.1 WebRTC-f2a0f5f1-6c4e-444f-b99f-a968bb5f7297",
"userDevice": "COLLABORATION_WEB"
},
"callee": null,
"service": null,
"destination": "10020",
"trunkName": null,
"queueName": null,
"queueId": null,
"tags": [],
"flags": [],
"endCause": null,
"endCauseStr": null,
"endBy": null
}
}
{
"id": "it_w118741_1693389850.110",
"pbx": "221100001bab",
"time": 1693389850810,
"company": "it_w118741",
"type": "call:update",
"integrationId": "8qkmnq",
"data": {
"status": "CONNECTING",
"caller": {
"type": "LOCAL",
"phone": "1001",
"name": "admin",
"company": null,
"email": "vladimir.gorobets@wildix.com",
"userId": "1257510555",
"userExtension": "1001",
"userDepartment": null,
"groupId": "62177694",
"groupName": "Admin",
"userAgent": "Wildix Zero Distance 4.0.1 WebRTC-f2a0f5f1-6c4e-444f-b99f-a968bb5f7297",
"userDevice": "COLLABORATION_WEB"
},
"callee": {
"type": "LOCAL",
"phone": "10020",
"name": "user20",
"company": null,
"email": "vladimir.gorobets+3@wildix.com",
"userId": "5753746",
"userExtension": "10020",
"userDepartment": null,
"groupId": "874629312",
"groupName": "Default",
"userAgent": null,
"userDevice": null
},
"service": null,
"destination": "10020",
"trunkName": null,
"queueName": null,
"queueId": null,
"tags": [],
"flags": [],
"endCause": null,
"endCauseStr": null,
"endBy": null
}
}
{
"id": "it_w118741_1693389850.110",
"pbx": "221100001bab",
"time": 1693389853611,
"company": "it_w118741",
"type": "call:end",
"integrationId": "8qkmnq",
"data": {
"status": "CONNECTING",
"caller": {
"type": "LOCAL",
"phone": "1001",
"name": "admin",
"company": null,
"email": "vladimir.gorobets@wildix.com",
"userId": "1257510555",
"userExtension": "1001",
"userDepartment": null,
"groupId": "62177694",
"groupName": "Admin",
"userAgent": "Wildix Zero Distance 4.0.1 WebRTC-f2a0f5f1-6c4e-444f-b99f-a968bb5f7297",
"userDevice": "COLLABORATION_WEB"
},
"callee": {
"type": "LOCAL",
"phone": "10020",
"name": "user20",
"company": null,
"email": "vladimir.gorobets+3@wildix.com",
"userId": "5753746",
"userExtension": "10020",
"userDepartment": null,
"groupId": "874629312",
"groupName": "Default",
"userAgent": null,
"userDevice": null
},
"service": null,
"destination": "10020",
"trunkName": null,
"queueName": null,
"queueId": null,
"tags": [],
"flags": [],
"endCause": "21",
"endCauseStr": "Call Rejected",
"endBy": "CALLER"
}
}
Important: For security reasons, we recommend to check
signature
for all received events
- For
webhook transport
you can findsignature
in the request's headerx-signature
- For
SQS transport
you can findsignature
in theMessageAttributes.['X-SIGNATURE']
import crypto from 'crypto';
const checkSignature = function (body, secret, signature) {
const key = Buffer.from(secret, 'utf8');
const hash = crypto.createHmac('sha256', key).update(body).digest('hex');
try {
return crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(signature));
} catch {
return false;
}
}
// stringBody - raw message body as a string
// secret - secret from webhook configuration
// signature - received message signature
if (!checkSignature(stringBody, secret, signature)) {
// skip incorrect message
return;
}
// process message