Sincronizza il consenso con il tuo CRM tramite webhook
Mantieni le opt-in di email marketing del tuo CRM sincronizzate con le decisioni di consenso ConsentForge automaticamente.
Architettura
Utente accetta/rifiuta marketing → Webhook ConsentForge → Il tuo backend → API CRM
Passo 1: Crea un endpoint webhook
Configura un endpoint sul tuo backend che gestisca il payload ConsentForge:
// Esempio Express
app.post('/webhooks/consentforge', express.raw({ type: '*/*' }), async (req, res) => {
// 1. Verifica la firma
const valid = verifyConsentForgeWebhook(
req.body.toString(),
req.headers['x-consentforge-signature'],
req.headers['x-consentforge-timestamp'],
process.env.CONSENTFORGE_WEBHOOK_SECRET
);
if (!valid) return res.status(401).send('Unauthorized');
// 2. Analizza il payload
const payload = JSON.parse(req.body);
// 3. Gestisci solo gli eventi di consenso marketing
if (['consent.created', 'consent.updated'].includes(payload.event)) {
const hasMarketingConsent = payload.data.choices.marketing === true;
// 4. Aggiorna CRM
await updateCRMContact({
ip_hash: payload.data.ip_hash,
marketing_opt_in: hasMarketingConsent,
consent_timestamp: payload.timestamp,
receipt_id: payload.data.receipt_id,
});
}
res.json({ received: true });
});
Passo 2: Registra il webhook in ConsentForge
Proprietà → Webhook → Aggiungi endpoint
- URL:
https://tuaapp.com/webhooks/consentforge - Eventi:
consent.created,consent.updated - Copia il segreto del webhook
Passo 3: Mappa il contatto CRM
Poiché ConsentForge archivia identificatori hashati (non email), hai bisogno di un modo per collegare la ricevuta a un contatto CRM. Opzioni:
- Utenti loggati: Archivia l'ID ricevuta ConsentForge nel record utente al login
- Form email: Dopo l'invio di un form, chiama
ConsentForge.getReceiptId()e archivialo insieme all'email
Vedi anche: Webhook · Sicurezza webhook