For example, when a Zoom meeting invite is sent via email, and the recipient opens the link and signs in, their information should be captured and stored in a custom Salesforce object.
I have created a public site in Salesforce, enabled my Apex class through public access settings, and set up a webhook app in the Zoom Marketplace.
However, when I enter my public site URL in the Event Notification Endpoint URL section in Zoom, I receive the error: “URL validation failed. Try again later.”
My apex class:
@RestResource(urlMapping=‘/zoomWebhook/*’)
global with sharing class ZoomWebhookHandler {
@HttpPost
global static void handleWebhook() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
try {
// Parse JSON request
String requestBody = req.requestBody.toString();
System.debug('Zoom Webhook Payload: ' + requestBody);
Map<String, Object> jsonMap = (Map<String, Object>) JSON.deserializeUntyped(requestBody);
Map<String, Object> payload = (Map<String, Object>) jsonMap.get('payload');
if (payload != null) {
String meetingId = (String) payload.get('id');
List<Object> participants = (List<Object>) payload.get('participant');
for (Object participantObj : participants) {
Map<String, Object> participant = (Map<String, Object>) participantObj;
String email = (String) participant.get('email');
String userName = (String) participant.get('user_name');
// Find the matching Contact
List<Contact> contactList = [SELECT Id FROM Contact WHERE Email = :email LIMIT 1];
if (!contactList.isEmpty()) {
// Create a new Zoom Meeting record
Zoom_Meeting__c zoomRecord = new Zoom_Meeting__c(
Contact__c = contactList[0].Id,
Meeting_ID__c = meetingId,
Participant_Email__c = email,
Participant_Name__c = userName
);
insert zoomRecord;
}
}
}
// Respond with HTTP 200 OK
res.statusCode = 200;
res.responseBody = Blob.valueOf('{"message": "Success"}');
} catch (Exception e) {
System.debug('Error processing webhook: ' + e.getMessage());
// Respond with HTTP 400 Bad Request
res.statusCode = 400;
res.responseBody = Blob.valueOf('{"message": "Error: ' + e.getMessage() + '"}');
}
}