@zoom/rtms
    Preparing search index...

    Function onWebhookEvent

    • Sets up a webhook server to receive events from Zoom

      This function creates an HTTP or HTTPS server that listens for webhook events from Zoom. When a webhook event is received, it parses the JSON payload and passes it to the provided callback function.

      For secure HTTPS connections, provide the following environment variables:

      • ZM_RTMS_CERT: Path to SSL certificate file
      • ZM_RTMS_KEY: Path to SSL certificate key file
      • ZM_RTMS_CA_WEBHOOK: (Optional) Path to CA certificate for client verification

      The callback can be either a basic WebhookCallback (receives only the payload) or a RawWebhookCallback (receives payload, request, and response objects for custom handling of webhook validation challenges).

      Parameters

      Returns void

      import rtms from '@zoom/rtms';

      // Basic webhook handler (automatically responds with 200 OK)
      rtms.onWebhookEvent((payload) => {
      if (payload.event === "meeting.rtms.started") {
      console.log(`RTMS started for meeting: ${payload.meeting_uuid}`);
      }
      });
      // Advanced webhook handler with raw HTTP access for custom validation
      rtms.onWebhookEvent((payload, req, res) => {
      // Access headers for webhook validation
      const authorization = req.headers.authorization;
      const signature = req.headers['x-zoom-signature'];

      // Custom validation logic here
      if (!validateSignature(payload, signature)) {
      res.writeHead(401);
      res.end('Unauthorized');
      return;
      }

      // Process the event
      if (payload.event === "meeting.rtms.started") {
      console.log(`RTMS started for meeting: ${payload.meeting_uuid}`);
      }

      // Custom response
      res.writeHead(200, { 'Content-Type': 'application/json' });
      res.end(JSON.stringify({ status: 'ok' }));
      });