I can help you resolve this - I’ve dealt with this exact issue multiple times in zs-2021. The problem is threefold and addresses all your concerns about webhook event configuration, payload validation, and error handling.
Webhook Event Configuration Issue:
The event name ‘lead.converted’ doesn’t exist in zs-2021’s integration hub. You need to use ‘deal.won’ combined with a lead source check, or better yet, use the ‘contact.created’ event with metadata filtering. Here’s the corrected approach:
client.on('contact.created', function(data) {
if (data.metadata.source === 'lead_conversion') {
processLeadConversion(data);
}
});
Payload Validation:
Your validation needs to happen within a proper error boundary. The integration hub requires explicit error catching because uncaught exceptions terminate the script silently:
function validatePayload(lead) {
try {
if (!lead.email || !lead.name) {
throw new Error('Missing required fields');
}
return true;
} catch (e) {
client.trigger('error.log', {message: e.message});
return false;
}
}
Error Handling in Client Script:
The client script error handling isn’t working because you need to explicitly register an error handler at the global level before any event listeners:
client.on('app.registered', function() {
client.on('error', function(err) {
console.error('Integration error:', err);
});
// Now register your business logic events
});
Additional Configuration:
In your manifest.json, ensure you have these permissions:
"domainWhitelist": ["your-external-crm.com"],
"events": ["contact.created", "contact.updated"]
Testing Workflow:
- First, test with a simple console.log in the ‘app.registered’ event to confirm script loading
- Then add the ‘contact.created’ listener with basic logging
- Finally, add your validation and webhook logic incrementally
The key issue is that zs-2021’s integration hub doesn’t support direct lead conversion events - you must listen to the resulting contact creation event and filter by source metadata. This approach also gives you better error visibility and more reliable webhook execution.
After implementing these changes, your downstream sync should work reliably. Let me know if you need help with the external CRM webhook payload formatting.