Let me walk you through a friendly, step-by-step guide on how to connect LiveKit to n8n using webhooks:
Step 1: Set Up an n8n Webhook
1. First, open your n8n workflow editor and create a new workflow.
2. Add a "Webhook" trigger node to your workflow. This node will be waiting to catch incoming requests from LiveKit.
3. Save the workflow to activate the webhook. Don’t forget to copy the webhook URL that n8n gives you—you'll need it in the next step!
Step 2: Configure LiveKit Webhook
1. Head over to your LiveKit Cloud dashboard and go to the "Settings" section of your project.
2. Find the webhook configuration area and paste in the n8n webhook URL you grabbed earlier.
3. Set up an API key and secret in LiveKit to keep things secure. These will help n8n verify the requests coming in.
Step 3: Handle Webhook in n8n
1. Back in your n8n workflow, add some extra nodes after the "Webhook" trigger to process the data LiveKit sends. For instance, a "Function" node can help you parse and work with the data.
2. To keep everything safe, make sure to validate the JWT token LiveKit sends along. You can do this with a custom function in n8n or by using a library that handles JWT validation.
Example Code for JWT Validation