![Introducing Testimonial Webhook Integration](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2F0d90f893-ac8d-4fa3-9464-b24875e43f5b%252F16b1afae-2e22-40d7-876a-2f55b4c3f6fa%252FAdd_a_heading_(10).png&optimizer=image&quality=80&width=280)
Writer
Title
Status
Person
Current Column
Date
Description
Introduction
Webhook allows you to send real-time notifications of events within testimonial.to to external services.
You can create/manage the webhook on your Settings page. Scroll down, and you will find the Webhook section 👇
![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2F93b1ea3a-3eb9-4704-969c-b30cb062dd14%252Fb9adea9b-b1ab-452a-8e44-bd118d66aac8%252FScreen_Shot_2022-05-10_at_10.29.44_PM.png&optimizer=image&quality=80&width=280)
A webhook consists of:
- An endpoint URL you have configured, to which a webhook event will be posted
- A secret key, which can be used to verify a webhook payload was sent by testimonial.to
- One or more events, which will be posted to a specified URL
When a webhook is triggered, a POST request will be made to the URL configured along with a JSON payload specific for each event type.
All events
You can configure a webhook to be sent on the following events:
- create - when a testimonial is created
- like - when a testimonial is liked
- unlike - when a testimonial is unliked
- delete - when a testimonial is deleted
Sample automation use cases
- Send a message to your Slack channel when a new testimonial is received
- Publish a tweet on Twitter when a testimonial is liked
- Attach your customer's testimonial along with its entry in your CRM when a testimonial is received
- Save the video to your Google Drive/Dropbox when a video testimonial is received
Sample payload
1. create event
Generated when a video/text testimonial is created
{
"type": "create",
"data": {
"type": "video",
"id": "b1f8b3e1-c52d-4cf6-a1a7-*********",
"createdAt": "2022-05-10T18:07:34.000Z",
"testimonial": {
"video_url": "https://stream.testimonial.to/*****/medium.mp4",
"duration": 87.2, // in seconds
"aspect_ratio": "4:3",
"img_thumbnail": "https://image.testimonial.to/*****/thumbnail.jpg",
"gif_thumbnail": "https://image.testimonial.to/*****/animated.gif?width=350",
"sent_by": {
"email": "johndoe@gmail.com",
"name": "John Doe"
}
},
"space": {
"id": "space-id",
"url": "https://testimonial.to/products/space-id"
}
}
}
2. like event
Generated when a video/text testimonial is liked
{
"type": "like",
"data": {
"type": "video",
"id": "b1f8b3e1-c52d-4cf6-a1a7-*********",
"createdAt": "2022-05-10T18:07:34.000Z",
"testimonial": {
"video_url": "https://stream.testimonial.to/*****/medium.mp4",
"duration": 87.2, // in seconds
"aspect_ratio": "4:3",
"img_thumbnail": "https://image.testimonial.to/*****/thumbnail.jpg",
"gif_thumbnail": "https://image.testimonial.to/*****/animated.gif?width=350",
"sent_by": {
"email": "johndoe@gmail.com",
"name": "John Doe"
}
},
"space": {
"id": "space-id",
"url": "https://testimonial.to/products/space-id"
}
}
}
3. unlike event
Generated when a video/text testimonial is unliked
{
"type": "unlike",
"data": {
"type": "video",
"id": "5d05a6ef-8123-4341-81d8-**********",
"space": {
"id": "space-id",
"url": "https://testimonial.to/products/space-id"
}
}
}
4. delete event
Generated when a video/text testimonial is deleted
{
"type": "delete",
"data": {
"type": "video",
"id": "b16a3c9c-ef2f-48b7-aa11-**********",
"space": {
"id": "space-id",
"url": "https://testimonial.to/products/space-id"
}
}
}
Verifying webhook signature
Each webhook event is signed via a Hash-based Message Authentication Code (HMAC) using the webhook’s secret key.
The HMAC-SHA1 algorithm is used to generate the webhook payload signature. Each request's signature is passed along in the headers as ‘X-Testimonial-Signature.’
![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2F9145fcff-b94d-453d-a1bb-e6160b38935e%252Ff09d8d05-75ba-43a5-8812-fb0ab694c1c8%252FScreen_Shot_2022-05-10_at_10.38.07_PM.png&optimizer=image&quality=80&width=280)
Node.js verify example
const WEBHOOK_SECRET = 'webhook secret key';
const crypto = require('crypto');
function verifySignature (body, signature) {
const digest = crypto
.createHmac('sha1', WEBHOOK_SECRET)
.update(JSON.stringify(body)) // Convert body from JSON to string
.digest('hex');
return signature === digest;
};
app.post('/webhooks', function (req, res, next) {
if (!verifySignature(req.body, req.headers['x-testimonial-signature'])) {
// verification failed
}
// verification success
});