When a prospect responds to an outreach campaign or submits an inbound contact form, every second of response delay decreases conversion likelihood. Building an event-driven webhook architecture routes warm leads directly into CRM pipelines (HubSpot, Salesforce, Pipedrive) within sub-second latencies while preventing duplicate records.
1. Webhook Ingestion & Idempotency Pipeline
A resilient ingestion gateway verifies HMAC signatures, checks idempotency keys in Redis, and dispatches leads to asynchronous worker queues:
import crypto from 'crypto';
function verifyWebhookSignature(req, secret) {
const signature = req.headers['x-hubspot-signature-v3'];
const sourceString = req.method + req.originalUrl + JSON.stringify(req.body) + req.headers['x-hubspot-request-timestamp'];
const hash = crypto.createHmac('sha256', secret).update(sourceString).digest('base64');
return hash === signature;
}