Validate webhook notifications
Obtain the secret token
When you create an integration, you provide outboundNotificationWebhookSignatureSecretToken
.
Validate a notification from an outbound open message
To validate outbound open messages use the outboundNotificationWebhookSignatureSecretToken
from the X-Hub-Signature-256 header. This header automatically accompanies all webhook requests sent to outboundNotificationWebhookUrl
.
const crypto = require('crypto');
// integration - the integration object
// normalizedMessage - the NormalizedMessage payload
// request - webhook request object
const normalizedMessage = request.data;
const signature = request.headers['X-Hub-Signature-256'];
const secretToken = integration.outboundNotificationWebhookSignatureSecretToken;
const messageHash = crypto.createHmac('sha256', secretToken)
.update(JSON.stringify(normalizedMessage))
.digest('base64');
if (`sha256=${messageHash}` !== signature) {
throw new Error("Webhook Validation Failed! Throw this away.");
} else {
processMessages(normalizedMessage);
}
Webhook retry policy
The Genesys Cloud Messaging platform retries a webhook request up to 5 times if the request times out (10 seconds) or responds with a retryable HTTP status code (429, 5xx).
Note Your webhook is required to respond to the Genesys within (10 seconds).
A full retry sequence with timeouts would take 85 seconds and looks like this:
- Initial request (10-second timeout)
- 5-second delay
- 1st retry (10-second timeout)
- 5-second delay
- 2nd retry (10-second timeout)
- 5-second delay
- 3rd retry (10-second timeout)
- 5-second delay
- 4th retry (10-second timeout)
- 5-second delay
- 5th retry (10-second timeout)