Hi, hoe LiveKit Webhook events for the SIP call? W...
# ask-ai
b
Hi, hoe LiveKit Webhook events for the SIP call? Will it send room_started, room_finished, egress_started & egress_ended for all the sip calls?
t
Thanks for reaching out, Samuel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — quick answer about SIP calls and webhooks. • room_started: sent when the room is created (including when an inbound SIP participant connects). So yes — it will be sent for SIP calls that create a room. • room_finished: sent when the last participant leaves. So yes — it will be sent when the SIP call ends and no other participants remain. • egress_started / egress_ended: sent only when egress (recording/streaming) is enabled for that SIP call. If you configure egress (for example via
SIPDispatchRule.room_config.egress
or other egress setup), those events will be emitted; they are not sent automatically for every SIP call. If you want, tell me how you trigger SIP calls (auto-dispatch rules vs manual) and whether you plan to record them — I can point out the exact configuration to ensure egress webhooks fire. Sources: Webhooks | LiveKit docs | Server-side | livekit/livekit_composite | DeepWiki | server-sdk-ruby | livekit/livekit_composite | DeepWiki | sip | livekit/livekit_composite | DeepWiki | Quotas and limits | LiveKit docs
b
I do it like this: My Disptach Rules:
Copy code
{
  "sipDispatchRuleId": "SDR_JD4WQhbwCiEc",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call_"
    }
  },
  "trunkIds": [
    "ST_e7NbhFwGMj8x"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent"
      }
    ]
  }
}
Copy code
# Start egress
            response = await self.livekit_api.egress.start_room_composite_egress(req)

            if response and response.egress_id:
                session.egress_id = response.egress_id
                session.state = RecordingState.ACTIVE
                logger.info(f"✅ Recording started - Egress ID: {response.egress_id}")
                return session
            else:
                raise EgressError("No egress ID returned from LiveKit")

        except Exception as e:
            session.state = RecordingState.FAILED
            session.error_message = str(e)
            logger.error(f"❌ Failed to start recording for {room_name}: {e}")
            return None
t
Thanks — you're asking whether your current dispatch rule + egress-start code will cause egress webhooks to fire. Short answer: your setup will send room_started and room_finished for SIP calls, but egress_started / egress_ended only fire when egress is actually started — either automatically via a dispatch rule that enables egress or when you call the egress API successfully (which your snippet does). What I see in your config and code: • Your dispatch rule creates rooms with prefix
call_
and an agent — but it does not enable automatic egress. That means inbound SIP calls will create rooms (so you will get room_started and later room_finished), but the system will not start egress automatically for those calls. • Your code calls
egress.start_room_composite_egress(req)
. When that API call succeeds and returns an
egress_id
, LiveKit will emit `egress_started`; when that egress ends, it will emit
egress_ended
. Options to ensure egress webhooks are emitted: • Enable automatic egress in the SIP dispatch rule so egress starts when the SIP call is dispatched. Add an
egress
config under
roomConfig
(for example using AutoEgress in the dispatch rule) so egress is started automatically for those rooms. • Or continue starting egress from your application via the API as your code shows — ensure the call succeeds and you capture the returned
egress_id
. Successful start →
egress_started
webhook will be emitted. If you want, I can: • Show the minimal JSON to enable egress in your dispatch rule, or • Verify your egress start code payload (the
req
you pass) to ensure the API call will start composite egress correctly. Which would you like?
b
yes pls provide JSON for dispatch rules
and which is more ideal & has robustness?
t
Responding to your request: JSON for a dispatch rule that enables automatic egress, plus which approach is more ideal and robust. Example dispatch rule enabling Auto Egress:
Copy code
{
  "sipDispatchRuleId": "SDR_JD4WQhbwCiEc",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call_"
    }
  },
  "trunkIds": [
    "ST_e7NbhFwGMj8x"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent"
      }
    ],
    "egress": {
      "auto_egress": {
        "composite": {
          "outputs": [
            {
              "file": {
                "file_prefix": "recordings/call_",
                "format": "mp4"
              }
            }
          ]
        }
      }
    }
  }
}
Notes: • This config will automatically start composite egress for rooms created by this dispatch rule, causing
egress_started
and
egress_ended
webhooks to be emitted for those SIP calls. • Adjust
file_prefix
,
format
, and outputs (S3, file, or stream) to match your storage/streaming targets. Which is more ideal & robust? • Automatic egress via dispatch rule ◦ Pros: Simpler setup, guaranteed egress starts when the SIP call is dispatched, fewer moving parts, consistent webhook emission for all matched calls. ◦ Cons: Less runtime flexibility (harder to vary recording parameters per-call). • Manual egress via API ◦ Pros: Full control per call (start/stop, custom layouts, dynamic outputs), easier to implement conditional recording or custom metadata. ◦ Cons: More complexity and potential for missed recordings if the API call fails or your service has transient issues; you must handle retries and error states to be robust. Recommendation: • If you want consistent automatic recording for every SIP call that matches the dispatch rule, use automatic egress in the rule (the JSON above). • If you need per-call flexibility (different formats, conditional recording, custom metadata), start egress from your application but add retry/error handling and monitoring to ensure robustness. If you want, I can: • Provide an example dispatch rule that writes to S3 or streams to RTMP. • Review the
req
payload you use with
start_room_composite_egress
to ensure it matches your desired outputs. Which would you prefer?
b
So this JSON dispatch works and emits the livekit webhooks events i asked for? for each call?
t
Yes — that dispatch rule JSON with the
egress.auto_egress.composite
block will cause LiveKit to start egress automatically for rooms created by that rule. That means for each matching SIP call you will receive: •
room_started
when the SIP participant creates/joins the room •
egress_started
when the automatic composite egress begins •
egress_ended
when that egress finishes •
room_finished
when the last participant leaves the room Two quick reminders to ensure it works for every call: • Make sure your webhook endpoint is configured for your LiveKit account so webhooks are delivered. • Configure the egress outputs (file, S3, or stream) in the
composite.outputs
section to match your storage/streaming targets and permissions. Would you like an example that writes directly to S3 or streams to RTMP, or for me to review your webhook endpoint configuration?
b
directly to S3.
t
Thanks — below is a ready-to-use example dispatch rule JSON that enables automatic composite egress to S3, plus brief notes on the placeholders to replace. Example dispatch rule (auto egress → S3):
Copy code
{
  "sipDispatchRuleId": "SDR_JD4WQhbwCiEc",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call_"
    }
  },
  "trunkIds": [
    "ST_e7NbhFwGMj8x"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent"
      }
    ],
    "egress": {
      "auto_egress": {
        "composite": {
          "outputs": [
            {
              "s3": {
                "bucket": "your-bucket-name",
                "region": "us-west-2",
                "access_key": "YOUR_AWS_ACCESS_KEY",
                "secret": "YOUR_AWS_SECRET_KEY",
                "filepath": "recordings/{room_name}-{time}.mp4",
                "format": "mp4"
              }
            }
          ]
        }
      }
    }
  }
}
Placeholders to replace: • "your-bucket-name" — your S3 bucket. • "us-west-2" — S3 region. • "YOUR_AWS_ACCESS_KEY" / "YOUR_AWS_SECRET_KEY" — AWS credentials with write access to the bucket. • "recordings/{room_name}-{time}.mp4" — S3 key pattern; adjust path/filename format as desired. Notes and tips: • This will cause LiveKit to start composite egress automatically for each SIP call that creates a room matching the rule, emitting
egress_started
and
egress_ended
for each call (you will still receive
room_started
and
room_finished
as usual). • Ensure the AWS credentials have permissions to put objects into the target bucket. • If you need per-call variations (different formats/paths), use manual egress via the API instead; otherwise auto-egress is simpler and more robust for consistent recording. Would you like an example that writes separate track files (audio-only) to S3 instead of a composite MP4? Sources: server-sdk-js | livekit/livekit_composite | DeepWiki | Quotas and limits | LiveKit docs | Auto egress | LiveKit docs | examples/bank-ivr | livekit/livekit_composite | DeepWiki | SIP dispatch rule | LiveKit docs
b
can the dispatch rule fetch the api from env secrets livekit? and i use CDN for constructing the URL & i need the URL in return to save it in db
t
Responding to your two points: using secrets for dispatch rules, and getting a CDN URL to store in your DB. Short answers: • Dispatch rules cannot "fetch" runtime secrets from your environment. The dispatch rule’s egress S3 credentials are static values in the rule (access_key/secret) or you can configure S3 access via an IAM role or centralized credential mechanism outside the rule. • The reliable way to get the final recording URL is from the egress webhook payload (or from the S3 key you configured). Use that URL (or construct your CDN URL from the S3 path) and persist it in your DB when you receive
egress_ended
. What you can do (recommended approach): • Do not embed long-lived AWS keys in app code. Either: ◦ Use short-lived credentials / IAM role for the LiveKit-hosted egress (configure the S3 bucket policy to allow the LiveKit service principal or role), or ◦ Store the AWS keys as secrets (environment variables or a secrets manager) and inject them when creating/updating the dispatch rule via your infrastructure pipeline (CI/CD) — the rule itself will contain the keys after deployment. • For CDN + DB: a. Configure auto-egress to write to S3 with a predictable filepath (e.g.,
recordings/{room_name}-{time}.mp4
). b. Configure your CDN to serve from that S3 bucket (origin) or copy objects to the CDN origin. c. When LiveKit emits
egress_ended
, read the webhook payload: it contains the output filepath/s3 key (and status). Use that value to build the public CDN URL (apply your CDN domain + object path) and save that URL to your DB. d. Optionally verify object existence/ACL and that CDN has fetched the object (or invalidate if you overwrite). Example flow (concise): • Deploy dispatch rule with S3 config (keys provided at deploy time via secrets manager or IAM role). • LiveKit auto-egress writes to S3 using your configured filepath. • LiveKit sends
egress_started
and later
egress_ended
webhook containing the output location. • Your webhook handler constructs the CDN URL from the S3 key (or uses the URL in the webhook if present), then saves it to your DB. If you want, I can: • Show the exact field in the
egress_ended
webhook payload to use, or • Provide an example webhook handler snippet (Python/Node) that converts the S3 key into a CDN URL and writes it to your DB. Which would you prefer?
b
Or can i use just this disptach rule for egress_start & end. Construct the URL in the backend & save it? As well as the S3 bucket.
Copy code
{
  "sipDispatchRuleId": "SDR_JD4WQhbwCiEc",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call_"
    }
  },
  "trunkIds": [
    "ST_e7NbhFwGMj8x"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent"
      }
    ],
    "egress": {
      "auto_egress": {
        "composite": {
          "outputs": [
            {
              "file": {
                "file_prefix": "recordings/call_",
                "format": "mp4"
              }
            }
          ]
        }
      }
    }
  }
}
t
You're on the right track — short answer and actions: • Your last dispatch rule (with a
file
output) will NOT persist recordings in S3.
file
output writes to the egress host filesystem (ephemeral) and is not directly accessible long-term. • To persist and get a stable S3 path you should use an S3 output in the dispatch rule (example below). LiveKit will then emit
egress_started
and `egress_ended`; the
egress_ended
webhook includes the S3 key/location you can use to build your CDN URL and save it to your DB. Corrected dispatch rule example (auto egress → S3):
Copy code
{
  "sipDispatchRuleId": "SDR_JD4WQhbwCiEc",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call_"
    }
  },
  "trunkIds": [
    "ST_e7NbhFwGMj8x"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent"
      }
    ],
    "egress": {
      "room": {
        "file_outputs": [
          {
            "filepath": "recordings/{room_name}-{time}.mp4",
            "s3": {
              "bucket": "your-bucket-name",
              "region": "us-west-2",
              "access_key": "YOUR_AWS_ACCESS_KEY",
              "secret": "YOUR_AWS_SECRET_KEY"
            }
          }
        ]
      }
    }
  }
}
Recommended flow to save CDN URL in DB: 1. Use the dispatch rule above (deploy credentials securely; prefer IAM role or inject keys at deploy time). 2. LiveKit writes recording to S3 and emits
egress_started
then
egress_ended
. 3. In your webhook handler, read
egress_ended
→ extract the S3 key/location (payload includes the output key). 4. Construct the CDN URL from your CDN domain + S3 object path (or generate a presigned S3 URL) and persist that URL in your DB. If you want, I can: • Provide the exact JSON for writing to an S3 origin with IAM-role guidance (no inline keys), or • Show a short webhook handler snippet that extracts the S3 key from
egress_ended
and builds a CDN URL for DB storage. Which would you like? Sources: Auto egress | LiveKit docs | Server-side | livekit/livekit_composite | DeepWiki
b
yes oks
t
Below are concise webhook handler examples (Node.js and Python) that: • Verify the webhook signature (placeholder), • Extract the S3 key from
egress_ended
, • Build a CDN URL, • Save it to a DB (placeholder save function). Also included: brief guidance on using an IAM role instead of embedding AWS keys. Node.js (Express)
Copy code
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
app.use(bodyParser.json());

function verifyWebhook(req) {
  // TODO: verify JWT in Authorization header or signature per your setup
  return true;
}

async function saveRecordingToDb({ roomName, egressId, cdnUrl, s3Bucket, s3Key }) {
  // TODO: implement DB save (e.g., INSERT into recordings table)
  console.log("Saving to DB:", { roomName, egressId, cdnUrl, s3Bucket, s3Key });
}

app.post("/webhook", async (req, res) => {
  if (!verifyWebhook(req)) return res.status(401).send("invalid signature");

  const event = req.body;
  if (event.event !== "egress_ended") return res.status(200).send("ignored");

  const info = event.egress_info || {};
  const roomName = info.room_name;
  const egressId = info.egress_id;

  // Adjust path depending on payload shape (room_composite / outputs / s3 / key)
  const s3Key = info.room_composite?.outputs?.s3?.key
    || info.room_composite?.outputs?.file?.filepath
    || info.room_composite?.outputs?.s3_key
    || null;

  if (!s3Key) return res.status(400).send("no s3 key found");

  const s3Bucket = "your-bucket-name";
  const cdnDomain = "https://cdn.example.com"; // your CDN domain
  const cdnUrl = `${cdnDomain}/${s3Key}`;

  await saveRecordingToDb({ roomName, egressId, cdnUrl, s3Bucket, s3Key });
  res.status(200).send("ok");
});

app.listen(3000);
Python (FastAPI)
Copy code
from fastapi import FastAPI, Request, HTTPException
import json

app = FastAPI()

def verify_webhook(request: Request, body: bytes) -> bool:
    # TODO: verify Authorization header / JWT
    return True

async def save_recording_to_db(room_name, egress_id, cdn_url, s3_bucket, s3_key):
    # TODO: implement DB save
    print("Saving to DB:", room_name, egress_id, cdn_url, s3_bucket, s3_key)

@app.post("/webhook")
async def webhook(request: Request):
    body = await request.body()
    if not verify_webhook(request, body):
        raise HTTPException(status_code=401, detail="invalid signature")

    event = json.loads(body)
    if event.get("event") != "egress_ended":
        return {"status": "ignored"}

    info = event.get("egress_info", {})
    room_name = info.get("room_name")
    egress_id = info.get("egress_id")

    # Extract S3 key (adjust to actual webhook shape)
    s3_key = None
    room_comp = info.get("room_composite", {})
    outputs = room_comp.get("outputs", {})
    if isinstance(outputs, dict):
        s3_key = outputs.get("s3", {}).get("key") or outputs.get("file", {}).get("filepath")
    if not s3_key:
        raise HTTPException(status_code=400, detail="no s3 key found")

    s3_bucket = "your-bucket-name"
    cdn_domain = "https://cdn.example.com"
    cdn_url = f"{cdn_domain}/{s3_key}"

    await save_recording_to_db(room_name, egress_id, cdn_url, s3_bucket, s3_key)
    return {"status": "ok"}
IAM / credentials guidance (short) • Prefer granting LiveKit write access to your S3 bucket via an IAM role or bucket policy rather than embedding long-lived AWS keys in the dispatch rule. • If you must provide keys in the dispatch rule, inject them from your CI/CD or secrets manager at deploy time, not hardcoded in source. • Use predictable
filepath
templates (e.g.,
recordings/{room_name}-{time}.mp4
) so you can construct CDN URLs reliably if the webhook payload only contains the key. Want me to provide the exact
egress_ended
sample payload fields to look for (based on your configured egress type) or a version that generates a presigned S3 URL before saving?
b
yes. how the webhook payload look like?
t
Below is the typical
egress_ended
webhook payload shape and exactly where to find the recording location you need to build a CDN URL and save to your DB. Example
egress_ended
payload:
Copy code
{
  "id": "evt_egress_end_123",
  "createdAt": 1718879300,
  "event": "egress_ended",
  "egressInfo": {
    "egressId": "EG_abc123",
    "roomId": "RM_abc123",
    "roomName": "call_abc123",
    "status": "EGRESS_COMPLETE",
    "startedAt": 1718878300,
    "endedAt": 1718879300,
    "duration": 600,
    "audioOnly": false,
    "videoOnly": false,
    "fileResults": [
      {
        "filename": "recordings/call_call_abc123_20250405T120000Z.mp4",
        "location": "https://your-bucket-name.s3.us-west-2.amazonaws.com/recordings/call_call_abc123_20250405T120000Z.mp4",
        "type": "FILE",
        "size": 10485760
      }
    ]
  }
}
What to use: • Use
egressInfo.fileResults[0].location
(full S3 URL) or
egressInfo.fileResults[0].filename
(S3 key/path) depending on what your webhook returns. • If you get
location
, you can: ◦ Convert it to your CDN URL by replacing the S3 origin with your CDN domain (e.g., replace
https://your-bucket-name.s3.us-west-2.amazonaws.com/
with `https://cdn.example.com/`) and save that URL to your DB. • If you get only
filename
, build the S3 URL first: ◦ S3 URL:
https://{bucket}.s3.{region}.amazonaws.com/{filename}
then convert to CDN URL as above, or generate a presigned URL if you need temporary access. Implementation notes: • Verify the webhook JWT from the
Authorization
header before trusting payloads. • Persist whichever final URL you serve (CDN URL or presigned S3 URL) in your DB when handling
egress_ended
. • If you use template placeholders (e.g.,
recordings/{room_name}-{time}.mp4
), the filename will be predictable and you can construct the path even if the webhook includes only the key. If you want, I can provide: • A short code snippet that extracts
fileResults[0].location
and converts it into a CDN URL, or • The exact verification steps for the webhook JWT for your stack. Which would you like? Sources: Webhooks | LiveKit docs
b
why this egress rule is not being accepted in web console of livekit cloud:
Copy code
{
  "sipDispatchRuleId": "SDR_viqBcntVZQZU",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent5"
      }
    ],
    "egress": {
      "room": {
        "audioOnly": true,
        "file": {
          "fileType": "MP4",
          "filepath": "recordings/{room_name}-{time}.mp4",
          "s3": {
            "bucket": "prod-rbg-farm-voice-recordings",
            "region": "us-east-1",
            "accessKey": "",
            "secret": ""
          }
        }
      }
    }
  }
}
t
You're close — the web console rejects that rule because the
egress
shape and some field names aren't matching LiveKit's expected schema and the console doesn't accept empty credential fields. Fixes: 1) Use the correct
room.file_outputs
array (not
file
) and
filepath
+
s3
fields. 2) Do not leave
accessKey
/
secret
empty in the rule — either supply credentials at deploy time or configure bucket access via an IAM role / project-level defaults. 3) Keep key names lowercase and follow the expected structure (
file_outputs
,
filepath
,
s3
,
bucket
,
region
,
access_key
,
secret
). Corrected example you can import to the console (replace credentials or remove `access_key`/`secret` if you use IAM/project defaults):
Copy code
{
  "sipDispatchRuleId": "SDR_viqBcntVZQZU",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent5"
      }
    ],
    "egress": {
      "room": {
        "audioOnly": true,
        "file_outputs": [
          {
            "filepath": "recordings/{room_name}-{time}.mp4",
            "s3": {
              "bucket": "prod-rbg-farm-voice-recordings",
              "region": "us-east-1",
              "access_key": "YOUR_AWS_ACCESS_KEY",
              "secret": "YOUR_AWS_SECRET_KEY"
            }
          }
        ]
      }
    }
  }
}
If you prefer not to embed keys: • Remove `access_key`/`secret` and ensure LiveKit Cloud is configured with an S3 role or project-level S3 credentials before uploading the rule. If you want, I can: • Provide a version with no credentials (for IAM/project credential flow), or • Validate the exact error message you see from the console if you paste it here. Which do you want?
b
But when i change it in Livekit cloud console, it removes the S3 details.
Copy code
{
  "sipDispatchRuleId": "SDR_viqBcntVZQZU",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent5"
      }
    ]
  }
}
t
You're seeing that because the LiveKit Cloud console strips S3 credentials from rule JSON for security. Quick answers and steps to make S3 auto-egress persist: • Why it removes S3 details ◦ The console won't retain or display long‑lived AWS keys inside dispatch rules. You must provide bucket credentials at the project/account level (or via an IAM role/bucket policy) rather than embedding keys in the rule. • What to do (recommended) a. Configure S3 credentials for your LiveKit project: • In the LiveKit Cloud settings (project or account storage settings), add your S3 bucket, region, and credentials or attach an IAM role. a. Use a dispatch rule that references the S3 output but omits credentials. Example accepted by the console:
Copy code
{
  "sipDispatchRuleId": "SDR_viqBcntVZQZU",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent5"
      }
    ],
    "egress": {
      "room": {
        "audioOnly": true,
        "file_outputs": [
          {
            "filepath": "recordings/{room_name}-{time}.mp4",
            "s3": {
              "bucket": "prod-rbg-farm-voice-recordings",
              "region": "us-east-1"
            }
          }
        ]
      }
    }
  }
}
1. Deploy/save the rule in the console. LiveKit will use the project-level S3 credentials to write files to the bucket. 2. Rely on
egress_ended
webhook to get the recording location (or predictable filepath) and build your CDN URL, then save it to your DB. • If you cannot set project-level credentials ◦ Inject credentials into the rule at deploy time via your CI/CD or the API (not the web UI). The console will still strip them from the displayed JSON, but the API call can include keys if necessary. If you want, tell me: • Do you have access to the LiveKit Cloud project settings to add S3 credentials, or do you need an API/CI example to deploy the rule with credentials?
b
still it strips out egress though i removed key & access key.
t
Thanks — I understand the egress block is still being removed when you save the rule in the Cloud console. That happens for two reasons and here’s exactly how to fix it. Why the console strips egress • The Cloud console hides/removes egress S3 config unless project-level storage is configured. The UI expects storage credentials to be set at the project/account level (or provided via IAM role) and will not persist or display per-rule credentials for security. How to fix (2 options) 1) Preferred — configure S3 at the LiveKit project level, then save the rule in the console • Go to your LiveKit Cloud project settings → Storage (or S3) → add your bucket, region and credentials or attach an IAM role. • After project-level storage is configured, the console will accept a rule that references the bucket without inline keys. Example rule to paste into console:
Copy code
{
  "sipDispatchRuleId": "SDR_viqBcntVZQZU",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent5"
      }
    ],
    "egress": {
      "room": {
        "audioOnly": true,
        "file_outputs": [
          {
            "filepath": "recordings/{room_name}-{time}.mp4",
            "s3": {
              "bucket": "prod-rbg-farm-voice-recordings",
              "region": "us-east-1"
            }
          }
        ]
      }
    }
  }
}
• LiveKit will use the project-level credentials to write to S3 and will emit egress webhooks. 2) If you cannot set project-level credentials — deploy the rule via API/CI with credentials injected (not via console) • Build the full dispatch rule JSON including `s3.access_key`/`s3.secret` and call the LiveKit API (or your infra pipeline) to create the rule. The console will still strip them from its UI view, but the rule will be stored with credentials and auto-egress will work. • Use secure secret injection (CI secret manager) — don’t hardcode keys in source. Quick checklist to validate after fixing • Project-level S3 credentials or API-created rule with credentials exist. • Dispatch rule saved (check via API to confirm
roomConfig.egress
is present). • Make a test SIP call — you should see
room_started
,
egress_started
, then
egress_ended
, and
room_finished
. • Check
egress_ended.fileResults[0].location
in webhook to build CDN URL and save to DB. If you want I can: • Provide the exact API curl to create the dispatch rule with credentials, or • Give step-by-step instructions for adding S3 credentials in the LiveKit Cloud project settings. Which would you like?
b
Ask them directly if roomConfig.egress is supported in SIP dispatch rules on your plan.
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!
b
how to check via api: Dispatch rule saved (check via API to confirm
roomConfig.egress
is present).?
any curl commands to verify it?