Skip to content

Commit c7f23c5

Browse files
authored
Merge pull request #68 from zoom/0.0.3-dev
0.0.3
2 parents 4cb7222 + 114a07c commit c7f23c5

9 files changed

Lines changed: 787 additions & 260 deletions

File tree

README.MD

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The RTMS SDK allows developers to:
2323
- Process real-time media streams (audio, video, transcripts)
2424
- Receive events about session and participant updates
2525
- Build applications that interact with Zoom meetings in real-time
26+
- Handle webhook events with full control over validation and responses
2627

2728
## Installation
2829

@@ -65,6 +66,51 @@ rtms.onWebhookEvent(({event, payload}) => {
6566
});
6667
```
6768

69+
### Node.js - Advanced Webhook Handling
70+
71+
For advanced use cases requiring custom webhook validation or response handling (e.g., Zoom's webhook validation challenge), you can use the enhanced callback with raw HTTP access:
72+
73+
```javascript
74+
import rtms from "@zoom/rtms";
75+
76+
rtms.onWebhookEvent((payload, req, res) => {
77+
// Access request headers for webhook validation
78+
const signature = req.headers['x-zoom-signature'];
79+
80+
// Handle Zoom's webhook validation challenge
81+
if (req.headers['x-zoom-webhook-validator']) {
82+
const validationToken = req.headers['x-zoom-webhook-validator'];
83+
84+
// Echo back the validation token
85+
res.writeHead(200, { 'Content-Type': 'application/json' });
86+
res.end(JSON.stringify({ plainToken: validationToken }));
87+
return;
88+
}
89+
90+
// Custom validation logic
91+
if (!validateWebhookSignature(payload, signature)) {
92+
res.writeHead(401, { 'Content-Type': 'application/json' });
93+
res.end(JSON.stringify({ error: 'Invalid signature' }));
94+
return;
95+
}
96+
97+
// Process the webhook payload
98+
if (payload.event === "meeting.rtms_started") {
99+
const client = new rtms.Client();
100+
101+
client.onAudioData((data, timestamp, metadata) => {
102+
console.log(`Received audio from ${metadata.userName}`);
103+
});
104+
105+
client.join(payload.payload);
106+
}
107+
108+
// Send custom response
109+
res.writeHead(200, { 'Content-Type': 'application/json' });
110+
res.end(JSON.stringify({ status: 'ok' }));
111+
});
112+
```
113+
68114
### Node.js - Class-Based Approach
69115

70116
For greater control or connecting to multiple streams simultaneously:

0 commit comments

Comments
 (0)