Make a Webhook call
This document describes the procedure for calling Skalin Webhooks.
Note
Make sure you have obtained a Webhook's key beforehand.
# How to call a Webhook
The code below show a Webhook call:
curl --location \
--request POST 'https://connector.skalin.io/webhook/{{YourWebhookId}}?client_id={{ClientId}}' \
--header 'Cache-Control: no-cache' \
--header 'Content-Type: application/json' \
--data-raw '{
"eventId":"{{EventId}}",
"customerId":"{{CustomerId}}",
"ts":"{{EventTs}}",
"localtime":"{{LocalTime}}",
"event": {
"name": "{{FeatureName}}",
"score": "{{Score}}"
}
}'
With NodeJS and axios (opens new window) library
axios({
method: 'POST',
url: 'https://connector.skalin.io/webhook/{{YourWebhookId}}',
headers: {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json'
},
params: {
client_id: '{{ClientId}}'
},
data: {
eventId: "{{EventId}}",
customerId: "{{CustomerId}}",
ts: "{{EventTs}}"
localtime: "{{LocalTime}}",
event: {
name: "{{FeatureName}}",
score: {{Score}}
}
}
});
ClientId | your client ID which was provided to you by Skalin or is available in the |
EventId | Event's unique identifier of 16 characters. Allows you to manage de-duplication (The last transmitted will be kept). |
CustomerId | customer identifier or customer domain name |
EventTs | (facultatif) UTC Event timestamp (`2021-05-08T12:00:05`) |
LocalTime | (facultatif) Event's localtime (`08:00:05`) |
FeatureName | Feature used's name |
Score |
Event's sentiment score. - 1: Very bad (minimum) - 5: Very good (maximum) |
Javascript
axios({
method: 'POST',
url: 'https://connector.skalin.io/webhook/05cb3204b49ff92d',
headers: {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json'
},
params: {
client_id: '2bb91c92dr779103'
},
data: {
eventId: "e07595f29f1928y5",
customerId: "customer1234",
event: {
name: "ActivationService",
score: 5
}
}
});
This sample show a call during a fictitious service's activation on platform and which represents a positive event for the customer.
Shell script
curl --location \
--request POST 'https://connector.skalin.io/webhook/05cb3204b49ff92d?client_id=2bb91c92dr779103' \
--header 'Cache-Control: no-cache' \
--header 'Content-type: application/json' \
--data-raw '{
"eventId":"e07595f29f1928y5",
"customerId":"customer1234",
"event": {
"name": "ActivationService",
"score": 5
}
}'
Python
import requests
import json
url = 'https://connector.skalin.io/webhook/05cb3204b49ff92d'
headers = {'Content-Type': 'application/json', 'Cache-Control': 'no-cache'}
params = {"client_id": "2bb91c92dr779103"}
data = {
"eventId": "e07595f29f1928y5",
"customerId": "customer1234",
"event": {
"name": "ActivationService",
"score": 5
}
}
response = requests.post(url=url, headers=headers, params=params, data=json.dumps(data))
Php
// Your ClientId and webhookId
$clientId = '2bb91c92dr779103';
$webhooId = '05cb3204b49ff92d';
$featureName = 'ActivationService';
$featureScore = 5;
$url = 'https://connector.skalin.io/webhook/'.$webhooId.'?client_id='.$clientId;
// The data to send to the API
$postData = array(
'eventId' => 'e07595f29f1928y5',
'customerId' => 'customer1234',
'event' => array('name' => $featureName, 'score' => $featureScore)
);
// Create the context for the request
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Cache-Control: no-cache\r\n".
"Content-Type: application/json\r\n",
'content' => json_encode($postData)
)
));
// Send the request
$response = file_get_contents($url, FALSE, $context);
// Check for errors
if($response === FALSE){
die('Error');
}
// Decode the response
$responseData = json_decode($response, TRUE);
← Overview