Title
Date
Description
Status
Current Column
Person
Writer
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 👇
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.’
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
});