what is livekit webhook
# ask-ai
d
what is livekit webhook
g
LiveKit webhooks are HTTP POST requests sent to a specified server endpoint to notify about events occurring within LiveKit rooms, such as when a room starts or finishes, or when participants join or leave. These webhooks are configured in the LiveKit settings and can be used to trigger backend processes in response to these events. The webhook payloads are sent in JSON format with a content type of
application/webhook+json
and include an authorization header for security purposes, which contains a signed JWT token to verify the source of the request. Would you like more detail on how to set up or handle these webhooks? Sources: - Webhooks | LiveKit Docs - LiveKit JS Server SDK - WebhookReceiver 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
d
@millions-hair-24956 give me complete guidline to setup this
g
To set up LiveKit webhooks, follow these steps: 1. Configure Webhooks: - In the LiveKit Cloud dashboard, navigate to the Settings section of your project to configure webhooks. For self-hosted setups, enable webhooks in your configuration file by specifying the
webhook
section with the
api_key
and
urls
where the webhooks should be sent. 2. Set Up Your Server to Receive Webhooks: - Ensure your server can receive HTTP POST requests with the content type
application/webhook+json
. The server should be able to handle JSON payloads and verify the JWT token in the Authorization header to ensure the request is from LiveKit. 3. Implement Webhook Receiver: - Use LiveKit's server SDKs to implement a webhook receiver. For example, in Node.js, you can use the
WebhookReceiver
class from the
livekit-server-sdk
to validate and decode the webhook payloads. 4. Handle Webhook Events: - Implement logic to handle different webhook events such as
room_started
,
participant_joined
, etc. Each event will have specific data that you can use to trigger actions in your application. Here's a basic example in Node.js:
Copy code
import { WebhookReceiver } from 'livekit-server-sdk';
import express from 'express';

const app = express();
const receiver = new WebhookReceiver('apikey', 'apisecret');

app.use(express.raw({ type: 'application/webhook+json' }));

app.post('/webhook-endpoint', async (req, res) => {
  try {
    const event = await receiver.receive(req.body, req.get('Authorization'));
    console.log('Received event:', event);
    // Handle the event
    res.sendStatus(200);
  } catch (error) {
    console.error('Error processing webhook:', error);
    res.sendStatus(400);
  }
});

app.listen(3000, () => {
  console.log('Server listening on port 3000');
});
Would you like more detailed information on any specific part of this setup? Sources: - Webhooks | LiveKit Docs 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
d
@millions-hair-24956 1. Configure Webhooks: - In the LiveKit Cloud dashboard, navigate to the Settings section of your project to configure webhooks. For self-hosted setups, enable webhooks in your configuration file by specifying the
webhook
section with the
api_key
and
urls
where the webhooks should be sent. explain this step in detail