Though I have configure the dispatch rule for auto...
# ask-ai
b
Though I have configure the dispatch rule for automated call recording, i dont see any webhook events for the webhook. can u pls look into it?
Copy code
{
  "dispatchRule": {
    "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": {
              "accessKey": "your_access_key",
              "secret": "your_secret_key",
              "bucket": "bucket_name",
              "region": "region"
            }
          }
        }
      }
    }
  }
}
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 — I looked at your dispatch rule snippet and what you configured. You set up auto-egress correctly for MP4 S3 recording, but that setup will not emit the usual egress lifecycle webhooks unless you explicitly attach webhook settings to the egress or rely on SIP call webhooks. What to do next (pick one): • Add per-egress webhooks so you receive egress lifecycle events: a. Under
roomConfig.egress.room
add a
webhooks
array with your endpoint and signing key:
Copy code
"webhooks": [
       { "url": "<https://yourserver.com/webhooks/egress>", "signingKey": "your_livekit_signing_key" }
     ]
1. Redeploy the dispatch rule and run a test call — you should get
egress_started
and
egress_ended
events with recording details. • Or rely on SIP call lifecycle webhooks: ◦ Ensure your project-level webhook is configured to receive
sip_call_initiated
and
sip_call_ended
. Those events fire for SIP calls and let you track when recording should start/end. Quick checks while testing: • Is your webhook endpoint publicly reachable and returning HTTP 200? • Does it accept POST with Content-Type
application/webhook+json
and validate the JWT in the Authorization header? • Confirm S3 credentials and filepath produce a successful upload after call end. If you’d like, paste: • your updated dispatch rule (with the
webhooks
block), • or a sample webhook POST (headers + body) you received (or the lack of one), and I’ll review it and suggest the exact next step. Sources: Egress API | LiveKit docs | server-sdk-js | livekit/livekit_composite | DeepWiki | Webhooks | LiveKit docs
b
I'm receiving other webhook events such as room_started, room_finished in the configured webhook handler in the backend with signingKey. but not the egress. why so?
t
Thanks — that helps. You're receiving `room_started`/`room_finished` because project-level room lifecycle webhooks are delivered by default, but egress lifecycle events for recordings started by a dispatch rule's auto-egress are not sent to the project webhook unless you explicitly configure webhooks for that egress (or use SIP call webhooks). What to do next: • Add a
webhooks
array under
roomConfig.egress.room
in your dispatch rule so the auto-egress will emit
egress_started
and
egress_ended
to your endpoint:
Copy code
"egress": {
  "room": {
    "audioOnly": true,
    "file": { ... },
    "webhooks": [
      { "url": "<https://yourserver.com/webhooks/egress>", "signingKey": "your_livekit_signing_key" }
    ]
  }
}
• Or rely on SIP call events: ensure your project webhook is configured to receive
sip_call_initiated
and
sip_call_ended
to track call lifecycles tied to recordings. Validation checklist: • Your endpoint is public and returns HTTP 200. • It accepts POST with Content-Type
application/webhook+json
. • It validates the JWT from the Authorization header using the signing key. If you want, paste your dispatch rule with the
webhooks
block added (or a sample
sip_call_ended
payload you do receive) and I’ll confirm it looks correct.
b
though i did it, no egress webhook event.
t
Thanks — I understand you’ve added the webhooks and signing key but still aren’t getting egress events. Let’s narrow this down. Please confirm/provide the following (small items you can paste or check quickly): 1. Project webhook URL ◦ Is a project-level webhook URL set in your LiveKit project settings (Dashboard -> Settings → Webhooks) or in
livekit.yaml
? (yes / no) 1. Webhook signing key ◦ Is a Signing Key configured in the same Webhooks settings? (yes / no) 1. Which webhook receives room events ◦ Are your
room_started
/
room_finished
events arriving at the same endpoint you expect egress to hit? (yes / no) 1. Dispatch rule (redact secrets) ◦ Paste the dispatch rule JSON you now have (with
webhooks
and S3 fields redacted). I’ll check placement and format. 1. Evidence egress started ◦ Run
lk egress list
(or share any egress log/ID you see). Do you see an egress job created for the call? If you don’t have CLI access, list any
egress_*
entries in your logs. 1. Webhook receiver logs ◦ Any incoming POSTs around call time? If yes, paste the HTTP status your receiver returned and any server log lines for the request. If none, confirm the endpoint is publicly reachable (curl from another host). Quick checks you can try now: • Curl your webhook URL to confirm it returns 200 and accepts Content-Type
application/webhook+json
. • Confirm your receiver validates the Authorization JWT using the project signing key (if validation fails, events may be dropped). If you share answers to 1–5 or paste the redacted dispatch rule and any egress ID/logs, I’ll inspect them and tell you the exact next step. Sources: SIP dispatch rule | LiveKit docs | Webhooks | LiveKit docs
b
after changing it like this, no agent joins the call.
Copy code
{
  "sip_dispatch_rule_id": "SDR_rjcvXxMWXABP",
  "rule": {
    "dispatch_rule_individual": {
      "room_prefix": "call-"
    }
  },
  "trunk_ids": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "room_config": {
    "agents": [
      {
        "agent_name": "farming-telephony-agent41"
      }
    ],
    "egress": {
      "room": {
        "audio_only": true,
        "file": {
          "file_type": "MP4",
          "filepath": "recordings/{room_name}-{time}.mp4",
          "s3": {
            "access_key": "",
            "secret": "",
            "bucket": "prod-rbg-farm-voice-recordings",
            "region": "us-east-1"
          }
        },
        "webhooks": [
          {
            "url": "<https://z6hg6gv987.execute-api.us-east-1.amazonaws.com/api/v1/webhooks/livekit>",
            "signing_key": ""
          }
        ]
      }
    }
  }
}
t
Thanks — I’m looking at the changed rule you pasted. A few likely causes for agents not joining and next steps to check: 1) Field names — use camelCase • In dispatch rules the expected keys are camelCase (e.g.,
agentName
,
roomPrefix
,
fileType
,
accessKey
,
secret
), not snake_case. Try reverting those fields to camelCase. 2) Agent identity & availability • Confirm the agent name exactly matches the agent service registration (
farming-telephony-agent41
). • Verify the agent service/process is running and able to accept assignments. 3) Agent permissions • Ensure the agent has the necessary permissions (room join / SIP agent role) and that the access token used to create the dispatch rule has
sip.admin
/
roomRecord
or appropriate scopes. 4) Dispatch rule applied & matching • Confirm the dispatch rule ID
SDR_rjcvXxMWXABP
is active. • Ensure incoming SIP calls match the `roomPrefix`/trunk IDs so the rule actually triggers. 5) Logs & egress jobs • Check agent logs and LiveKit logs at call time for assignment errors. • Run
lk egress list
or check egress jobs to see if recording was created (if no egress, agent likely never joined). 6) Webhook signing key & S3 creds • Empty
signing_key
,
access_key
, and
secret
are OK for testing only if you rely on project webhook; otherwise provide valid signing key and S3 creds. • If you expect per-egress webhooks, remember egress events are sent to the project webhook URL; per-egress webhooks alone may not be sufficient. If you want, paste a redacted JSON of the rule with camelCase (I can validate), plus: • Agent service logs around the call time, or • The LiveKit server logs or
lk egress list
output. I’ll review and point out the exact misconfigurations.
b
Check & verify it:
Copy code
{
  "sipDispatchRuleId": "SDR_rjcvXxMWXABP",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent41"
      }
    ],
    "egress": {
      "room": {
        "audioOnly": true,
        "file": {
          "fileType": "MP4",
          "filepath": "recordings/{room_name}-{time}.mp4",
          "s3": {
            "accessKey": "",
            "secret": "V+",
            "bucket": "prod-rbg-farm-voice-recordings",
            "region": "us-east-1"
          }
        },
        "webhooks": [
          {
            "url": "<https://z6hg6gv987.execute-api.us-east-1.amazonaws.com/api/v1/webhooks/livekit>",
            "signingKey": ""
          }
        ]
      }
    }
  }
}
t
Thanks — I reviewed your latest rule. Two issues to address so agents join and egress webhooks behave as expected. 1) Webhooks in SIP dispatch rule • Per-SIP-dispatch
webhooks
under
roomConfig.egress.room
is ignored. For auto-egress from a dispatch rule, egress lifecycle events are delivered to the project-level webhook only. Remove the
webhooks
block from the dispatch rule and ensure your project webhook + signing key are configured in the LiveKit dashboard or server config. 2) Agent not joining • Your
agentName
field is correct. Common causes when agents don’t join: ◦ Agent worker is not running or not registered. Run
lk agent list
and check the agent process for errors. ◦ Agent name mismatch or case difference vs. the registered agent. ◦ Agent is overloaded or failing to accept assignments (check agent logs). ◦ Dispatch rule not active or incoming call didn’t match the rule (verify trunk IDs and
roomPrefix
). ◦ Token/permissions used to create the rule lack agent/roomJoin rights. Quick checks for you to run and paste results here: • Does the project-level webhook exist and include a signing key? (yes/no) • Output of
lk agent list
(redact secrets) • Any agent logs around call time (errors) •
lk egress list
or whether an egress job was created for the call If you prefer a step to try now: • Remove the
webhooks
block, confirm project-level webhook/signing key are set, trigger a test call, then share agent list and agent logs — I’ll verify the next step. Sources: SIP APIs | LiveKit docs | Webhooks | LiveKit docs | Egress API | LiveKit docs | sip | livekit/livekit_composite | DeepWiki | SIP dispatch rule | LiveKit docs
b
good enough?
Copy code
{
  "sipDispatchRuleId": "SDR_rjcvXxMWXABP",
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "trunkIds": [
    "ST_fj4X5vtDuCuw",
    "ST_7uxDBNReo7fx"
  ],
  "name": "Farm Equipment SIP Dispatch",
  "roomConfig": {
    "agents": [
      {
        "agentName": "farming-telephony-agent41"
      }
    ],
    "egress": {
      "room": {
        "audioOnly": true,
        "file": {
          "fileType": "MP4",
          "filepath": "recordings/{room_name}-{time}.mp4",
          "s3": {
            "accessKey": "",
            "secret": "V",
            "bucket": "prod-rbg-farm-voice-recordings",
            "region": "us-east-1"
          }
        }
      }
    }
  }
}
t
Thanks — this looks much better. What’s good: • Field names are correct (camelCase). •
agentName
and
roomPrefix
are properly set. • Auto-egress to S3 is configured correctly. Two things to confirm so this works end-to-end: 1. Project-level webhook + signing key • Ensure a project-level webhook URL and signing key are configured in your LiveKit dashboard or server config. Egress lifecycle events from SIP auto-egress are sent to the project webhook, not per-dispatch webhooks. 1. Agent availability & permissions • Confirm the agent worker
farming-telephony-agent41
is running and registered (
lk agent list
). • Confirm agent has correct permissions and isn’t failing to accept assignments (check agent logs). Quick tests to run: • Trigger a test call and check for
participant_joined
,
sip_call_initiated
webhooks at your project webhook. • Run
lk egress list
to see created egress jobs. • If no egress job appears, check agent logs and LiveKit server logs for dispatch/assignment errors. If you share: • Project webhook presence (yes/no), •
lk agent list
output or agent log errors, I’ll review and give the exact next step.
b
Test event works. and even room_started & room_finished works. but not egress... why so?
t
You're receiving `room_started`/`room_finished` but not egress events because egress lifecycle events for auto-egress started by a SIP dispatch rule are sent only to the project-level webhook and only when an egress job is actually created. Let's quickly confirm the two required conditions and gather a couple of diagnostics. Please check/confirm these three items: 1. Project webhook and event selection • Is a project-level webhook URL configured in your LiveKit dashboard or server config? (yes / no) • In that webhook configuration, are egress events enabled/selected? (yes / no) 1. Is an egress job actually created for the call • After a test call, run
lk egress list
and share the output (redact secrets). Do you see an egress job for the room? (paste or say none) 1. Webhook receiver and signature • Does your receiver log any incoming POSTs around the call time (even 4xx/5xx)? If yes, paste the HTTP status and any error lines. If no, confirm the endpoint is publicly reachable (a simple
curl
from another host returning 200 is fine). If the answer to (1) is yes and (2) shows no egress job, the auto-egress did not start (so no egress events will be sent). If an egress job exists but no webhook POST arrived, we’ll inspect your project webhook settings and receiver logs next. Share the answers or the
lk egress list
output and I’ll tell you the exact next step.
b
can we give agentId in dispatch rule?
t
You cannot specify an agentId in the SIP dispatch rule. Dispatch rules accept agents by name (
agentName
), not by numeric/UUID agentId. What you can do to target a specific agent: • Use a unique, exact
agentName
in the dispatch rule (e.g.,
"agentName": "farming-telephony-agent41"
). The dispatcher will attempt to assign that named agent. • Use agent naming conventions to target a specific worker or a small pool (e.g.,
team-alpha-*
) and register only those agents with matching names. • Ensure the named agent is running/registered (
lk agent list
) and able to accept assignments. If you need deterministic assignment (always the same worker), give that worker a unique
agentName
and confirm it’s online. If you want load distribution, list multiple agents in the rule. Tell me which approach you want (single agent vs pool) and I’ll show the exact rule example and checks to ensure the agent will be assigned.