Custom script in integration hub fails to execute on lead conversion trigger, blocking downstream sync

We’ve implemented a custom JavaScript in the integration hub that’s supposed to trigger when a lead converts to a contact. The script is meant to send lead data to our external CRM via webhook and validate the payload before transmission.

The webhook event configuration appears correct in the integration hub settings, but the script simply doesn’t execute during lead conversion. We’ve verified the webhook endpoint is active and our payload validation logic works when tested independently. The error handling we built into the client script isn’t even logging anything, which suggests the script isn’t running at all.

Here’s the webhook registration code:

client.on('lead.converted', function(data) {
  validatePayload(data.lead);
  sendToExternalCRM(data);
});

This is blocking our downstream sync process with the external system. Has anyone encountered similar issues with event-based scripts in the integration hub?

I ran into this exact scenario. The problem is usually with how the client library handles asynchronous event registration in zs-2021. Try wrapping your event listener in a client.context() promise to ensure proper initialization timing. Also double-check your error handling isn’t suppressing exceptions that would help you debug.

Check if you’re using the correct client context. The integration hub in zs-2021 requires you to initialize the client with specific context parameters. Your event binding might be correct, but if the client isn’t properly initialized with the right scope, events won’t propagate to your handlers. Also, make sure you’re not accidentally overwriting the client object elsewhere in your code.

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:

  1. First, test with a simple console.log in the ‘app.registered’ event to confirm script loading
  2. Then add the ‘contact.created’ listener with basic logging
  3. 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.

Have you verified the webhook event is actually being triggered by Zendesk? Use the integration hub’s built-in event monitor to see if lead.converted events are firing at all. Sometimes the problem isn’t the script but the event source itself. In my experience with zs-2021, lead conversion events can fail silently if there are validation errors in the lead record itself, like missing required custom fields.

I’ve seen this before with zs-2021. The lead.converted event might not be firing as expected. Try logging in the initialization phase to confirm your script is even loading. Also, check if your app has the proper permissions in the manifest file for lead conversion events.