| name | replicate-webhooks |
| description | Receive and verify Replicate webhooks. Use when setting up Replicate webhook handlers, debugging signature verification, or handling prediction events like start, output, logs, or completed.
|
| license | MIT |
| metadata | {"author":"hookdeck","version":"0.1.0","repository":"https://github.com/hookdeck/webhook-skills"} |
Replicate Webhooks
When to Use This Skill
- Setting up Replicate webhook handlers
- Debugging signature verification failures
- Understanding Replicate event types and payloads
- Handling prediction lifecycle events (start, output, logs, completed)
Essential Code (USE THIS)
Express Webhook Handler
const express = require('express');
const crypto = require('crypto');
const app = express();
app.post('/webhooks/replicate',
express.raw({ type: }),
(req, res) => {
webhookId = req.[];
webhookTimestamp = req.[];
webhookSignature = req.[];
(!webhookId || !webhookTimestamp || !webhookSignature) {
res.().({ : });
}
secret = process..;
signedContent = ;
{
secretBytes = .(secret.()[], );
expectedSignature = crypto
.(, secretBytes)
.(signedContent)
.();
signatures = webhookSignature.().( {
parts = sig.();
parts. > ? parts[] : sig;
});
isValid = signatures.( {
{
crypto.(
.(sig),
.(expectedSignature)
);
} {
;
}
});
(!isValid) {
res.().({ : });
}
timestamp = (webhookTimestamp, );
currentTime = .(.() / );
(currentTime - timestamp > ) {
res.().({ : });
}
} (err) {
.(, err);
res.().({ : });
}
prediction = .(req..());
.(, {
: prediction.,
: prediction.,
: prediction.
});
(prediction.) {
:
.(, prediction.);
;
:
.(, prediction.);
(prediction.) {
.(, prediction.);
}
;
:
.(, prediction.);
.(, prediction.);
;
:
.(, prediction.);
.(, prediction.);
;
:
.(, prediction.);
;
:
.(, prediction.);
}
res.().({ : });
}
);