Web Hooks
💡
Reachout to the Huddle01 Team to set your webhook URL for your subdomain, you'll be able to set it up from the dashboard soon.
Usage:
import { WebhookReceiver } from "@huddle01/server-sdk/webhooks";
const webhookReceiver = new WebhookReceiver({
apiKey: "YOUR_API_KEY",
});
Express Example to listen to webhooks events
💡
To make the webhook work on localhost, you'll have to use something like ngrok
for port forwarding.
import express, { Request, Response } from "express";
import bodyParser from "body-parser";
import { WebhookReceiver } from "@huddle01/server-sdk/webhooks";
type Err = { message: string };
const receiver = new WebhookReceiver({
apiKey: "YOUR_API_KEY",
});
const app = express();
const port: number = 3002;
// Middleware to parse JSON bodies
app.use(bodyParser.text());
app.post("/", (req: Request, res: Response) => {
try {
const header: string | undefined = req.headers[
"huddle01-signature"
] as string;
const data = receiver.receive(req.body, header);
console.log({ data });
res.status(200).send({ success: true });
} catch (error) {
console.error({ error });
}
});
app.listen(port, () => {
console.log(`🦊 Express server running at http://localhost:${port}`);
});
Events
You can listen to these event on your server side and perform various actions based on the events. Following is the list of events you can listen to:
meeting:started
meeting:started
Attributes | Type |
---|---|
roomId | string |
createdAt | number |
meeting:ended
meeting:ended
Attributes | Type |
---|---|
roomId | string |
createdAt | number |
endedAt | number |
duration | number |
participants | number |
maxParticipants | number |
peer:joined
peer:joined
Attributes | Type |
---|---|
id | string |
roomId | string |
joinedAt | number |
metadata | string? |
role | string? |
browser | Browser |
device | Device |
Browser
Attributes | Type |
---|---|
name | string? |
version | string? |
Device
Attributes | Type |
---|---|
model | string? |
type | string? |
vendor | string? |
peer:left
peer:left
Attributes | Type |
---|---|
id | string |
roomId | string |
leftAt | number |
duration | number |
metadata | string? |
role | string? |
peer:trackPublished
peer:trackPublished
Attributes | Type |
---|---|
id | string |
track | string |
peer:trackUnpublished
peer:trackUnpublished
Attributes | Type |
---|---|
id | string |
track | string |
recording:started
recording:started
Attributes | Type |
---|---|
id | string |
roomId | string |
recording:stopped
recording:stopped
Attributes | Type |
---|---|
id | string |
roomId | string |