@zoom/rtms
    Preparing search index...

    Function createWebhookHandler

    • Creates a request handler for webhook events that can be mounted on existing HTTP servers

      This function returns a Node.js request handler compatible with Express, Fastify, and other HTTP frameworks. It allows you to integrate Zoom webhook handling with your existing application routes on a shared port.

      The handler validates that requests are POST requests to the specified path, parses JSON payloads, and invokes your callback with the webhook data.

      Parameters

      • callback: WebhookCallback | RawWebhookCallback

        Function to call when webhook events are received (WebhookCallback or RawWebhookCallback)

      • path: string

        The URL path to listen on (e.g., '/zoom/webhook')

      Returns (req: IncomingMessage, res: ServerResponse<IncomingMessage>) => void

      A request handler function compatible with http.Server

      import express from 'express';
      import rtms from '@zoom/rtms';

      const app = express();
      app.use(express.json());

      // Your application routes
      app.get('/health', (req, res) => {
      res.json({ status: 'healthy' });
      });

      // Mount Zoom webhook handler on the same server
      const webhookHandler = rtms.createWebhookHandler(
      (payload) => {
      console.log(`Received webhook: ${payload.event}`);

      if (payload.event === "meeting.rtms.started") {
      // Create a client and join the meeting
      const client = new rtms.Client();
      client.join({
      meeting_uuid: payload.payload.meeting_uuid,
      rtms_stream_id: payload.payload.rtms_stream_id,
      server_urls: payload.payload.server_urls
      });
      }
      },
      '/zoom/webhook'
      );

      // Mount the handler on your Express app
      app.post('/zoom/webhook', webhookHandler);

      // Single port for all routes (Cloud Run, Kubernetes, etc.)
      const PORT = process.env.PORT || 8080;
      app.listen(PORT, () => {
      console.log(`Server listening on port ${PORT}`);
      });