What webhooks are sent when a inbound call comes i...
# ask-ai
g
What webhooks are sent when a inbound call comes in?
✅ 1
t
Thanks for reaching out, Aumesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When you receive an inbound call, there are a few webhook events that will be sent to keep you informed every step of the way: • SIP_PARTICIPANT_CREATED: This is triggered when a SIP participant is created for the caller—think of it as the call getting ready to connect. • SIP_CALL_STARTED: This lets you know the call has successfully been established. • SIP_CALL_ENDED: You'll see this when the call has ended. • SIP_CALL_UPDATE: This event keeps you updated whenever there's a change in the call status. And there’s more! Once the SIP participant joins a LiveKit room, some standard room webhooks will also be triggered to keep you in the loop: • participant_joined: This tells you when the participant has joined the room. • track_published: This happens when the participant shares their audio track. Sources: livekit-protocol/livekit/protocol/analytics.pyi | Webhooks | LiveKit Docs
g
How to configure on room creation what api key to use to sign a webhook
t
Let's walk through how to configure the API key used to sign webhooks during room creation. You'll want to set it up in the LiveKit server configuration under the
webhook
section. Here's a simple example to guide you:
Copy code
webhook:
  # The API key to use in order to sign the message
  # This must match one of the keys LiveKit is configured with
  api_key: 'your-api-key'
  # List of URLs to be notified of room events
  urls:
    - 'https://yourserver.com/webhook'
When events like
room_started
happen, LiveKit sends an HTTP POST request to the URLs you've set. This request includes a signed JWT token in the
Authorization
header, created using the
api_key
and its secret you specified. To help you validate the webhook smoothly, you can use LiveKit’s server SDKs. Here's how you might do it in Node.js:
Copy code
import { WebhookReceiver } from 'livekit-server-sdk';

const receiver = new WebhookReceiver('your-api-key', 'your-api-secret');

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

app.post('/webhook', async (req, res) => {
  try {
    const event = await receiver.receive(req.body, req.get('Authorization'));
    console.log('Received webhook event:', event);
    res.status(200).send('OK');
  } catch (err) {
    console.error('Failed to validate webhook:', err);
    res.status(401).send('Unauthorized');
  }
});
Just a quick reminder to make sure your server accepts payloads with
Content-Type: application/webhook+json
. If you have any questions or need a hand with any step, please don’t hesitate to ask—I’m here to help! Sources: Webhooks | LiveKit Docs | Docs::Home | examples/webhooks-nextjs/README.md
g
I am using livekit cloud.
t
Hi there! In LiveKit Cloud, you can easily set up the API key for signing webhooks right from your project dashboard. Here’s a simple way to do it: 1. First, log in to your LiveKit Cloud account and head over to the project you want to work on. 2. Next, click on the Settings section within your project dashboard. 3. Then, in the webhook configuration area, enter the
api_key
that LiveKit will use to sign webhook messages. Just make sure this key matches one of the API keys you’ve already set up for your project. When webhook requests come in, they’ll have an
Authorization
header containing a JWT token signed with the API secret linked to your
api_key
. To validate these webhooks on your server, you can use a LiveKit server SDK. Here’s a quick example in Node.js:
Copy code
import { WebhookReceiver } from 'livekit-server-sdk';

const receiver = new WebhookReceiver('your-api-key', 'your-api-secret');

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

app.post('/webhook', async (req, res) => {
  try {
    const event = await receiver.receive(req.body, req.get('Authorization'));
    console.log('Received webhook event:', event);
    res.status(200).send('OK');
  } catch (err) {
    console.error('Failed to validate webhook:', err);
    res.status(401).send('Unauthorized');
  }
});
If you have any questions or need a hand with this setup, just let me know—I’m here to help! Sources: Webhooks | LiveKit Docs | Docs::Home | Egress API | LiveKit Docs
g
This doesn't help because multiple developers may be starting their backend, and I do not want to get webhooks for other developers calls.
t
I'd love to understand a bit more about how your developers are working with LiveKit. For example: • Are they using separate projects in LiveKit Cloud, or are they sharing a single project? • Would you like to filter webhooks based on specific rooms, participants, or maybe other criteria? Knowing this will really help me guide you towards the best way to set up webhooks that fit your needs perfectly.
g
We are sharing a single project, and have multiple dispatch rules for inbound calls
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!