How do I set up web hooks?
# ask-ai
i
How do I set up web hooks?
t
Thanks for reaching out, Pratham. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To set up webhooks in LiveKit, follow these steps: For LiveKit Cloud: • Configure webhooks in the Settings section of your project's dashboard. For Self-hosting: • Enable webhooks by setting the
webhook
section in your config file:
Copy code
webhook:
  # The API key to use to sign the message
  # This must match one of the keys LiveKit is configured with
  api_key: 'api-key-to-sign-with'
  urls:
  - '<https://yourhost>'
Receiving Webhooks: • Set up an HTTP endpoint to receive POST requests. • Ensure your server can handle the
Content-Type: application/webhook+json
header. • Use the WebhookReceiver from the LiveKit server SDK to validate and decode payloads:
Copy code
import { WebhookReceiver } from 'livekit-server-sdk';

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

// If using Express, ensure raw body parsing for webhook endpoint
// app.use(express.raw({type: 'application/webhook+json'}));

<http://app.post|app.post>('/webhook-endpoint', async (req, res) => {
  // Event is a WebhookEvent object
  const event = await receiver.receive(req.body, req.get('Authorization'));
});
Webhooks allow your server to be notified when room events take place, such as when a room has finished or when a participant leaves. Sources: Webhooks | LiveKit Docs | LiveKit JS Server SDK - v2.9.7
i
Where to define config file?
t
Hey there! Let me walk you through how to set up your LiveKit config file. It's actually pretty flexible, and I'll break down the options for you depending on which service you're working with. For the LiveKit server: • You can pass the config file using the
--config
flag when starting the server - super easy! • Or if you prefer, you can set the YAML content directly with the
LIVEKIT_CONFIG
environment variable. Here's a sample config file that works great for production deployments:
Copy code
port: 7880
log_level: info
rtc:
  tcp_port: 7881
  port_range_start: 50000
  port_range_end: 60000
  use_external_ip: true
redis:
  address: my-redis-server.name:6379
keys:
  # key-value pairs
  # your_api_key: <your_api_secret>
turn:
  enabled: true
  domain: <turn.myhost.com>
  tls_port: 3478
For the Egress service: • Just add the config file to a mounted volume and point to its location using the
EGRESS_CONFIG_FILE
environment variable. • Alternatively, you can set the config content directly with the
EGRESS_CONFIG_BODY
environment variable. For the Ingress service: • Pass the config file location using the
INGRESS_CONFIG_FILE
environment variable. • Or set the config content directly with the
INGRESS_CONFIG_BODY
environment variable. Sources: Deploying LiveKit | LiveKit Docs | Self-hosting the Egress Service | LiveKit Docs | Self-hosting the Ingress Service | LiveKit Docs
i
How can I dynamically configure webhooks?
t
Hey there! Let me walk you through how you can set up webhooks in LiveKit – it's actually pretty straightforward. For general LiveKit server webhooks: • If you're using LiveKit Cloud, no worries! Just hop into the Settings section of your project dashboard, and you'll be able to configure webhooks in a few clicks. • Self-hosting? No problem! You can set up your webhooks by adjusting the
webhook
section in your config file with your API keys and URLs. For Egress-specific webhooks: • Here's a cool feature: you can dynamically add extra webhooks right inside your Egress requests using the
WebhookConfig
object. It's super flexible and includes: ◦ `url`: Where you want your webhook to send data ◦ `signing_key`: The API key that'll sign your request (just make sure it's defined for your project) • These specific webhooks will trigger for Egress lifecycle events, giving you additional tracking on top of your project-wide webhooks. Sources: Webhooks | LiveKit Docs | Egress API | LiveKit Docs
i
What is the difference between a general and an egress specific request here?
t
Hey there! Let me break down the webhook differences in LiveKit in a way that's easy to understand. General Webhooks: • You'll find these set up in the Settings section of your LiveKit Cloud project dashboard - super simple! • If you're self-hosting, just enable them in your config file's
webhook
section. • Think of these as your project's notification system - they'll keep you in the loop about room events like when a room wraps up or a participant drops out. Egress-Specific Webhooks: • These are like personalized notifications for a specific Egress request. • They'll catch all the Egress lifecycle events, working right alongside your general webhooks. • You'll set these up using the
WebhookConfig
field when you're making an Egress request. • Just make sure you have a URL and signing key defined for your project, and you're good to go! Bottom line: General webhooks cover your whole project, while egress-specific webhooks give you those extra, tailored notifications for individual Egress requests. Pretty neat, right? Sources: Webhooks | LiveKit Docs | Egress API | LiveKit Docs
i
I have a livekit session running and users can add custom webhook urls where we will send events. If each user has a different webhook url that they are using to send events to, how do I configure this in Livekit?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!