When I recieve an Inbound Call. How can i modify t...
# ask-ai
w
When I recieve an Inbound Call. How can i modify the Agents metadata e.g. via an WebHook dynamically (not static metadata via a Disaptch Rule) before the Agent starts / is dispatched?
t
Thanks for reaching out, Lukas. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking how to change an agent's metadata dynamically (via webhook) for an inbound call before the agent starts/gets dispatched. Short answer: you can't mutate a dispatch rule's static metadata at runtime, but you can achieve the behavior you want by delaying dispatch and injecting dynamic metadata when you create the dispatch. Here’s how to do that. 1) Flow overview (what to do) • Receive the inbound-call webhook (e.g., room_started or participant_joined). • In your backend, perform any lookups/logic (CRM, caller ID, segment, routing rules). • Call the Agent Dispatch API and include the dynamic data in the dispatch request’s
metadata
(job metadata). • The agent’s entrypoint (
@rtc_session
/ job handler) reads
ctx.job.metadata
and configures behavior based on that data. 2) Why this works • Dispatch rule metadata is static and cannot be changed at runtime. • Webhooks are notifications; they let you run logic but do not directly modify an already-dispatched agent. • Passing metadata in
CreateAgentDispatchRequest
ensures the agent receives dynamic context before it starts. 3) Minimal example (conceptual) • Webhook handler: a. Receive webhook with caller info. b. Lookup customer segment / required behavior. c. Call CreateAgentDispatchRequest with
metadata
containing caller attributes. • Agent entrypoint: ◦ Read
ctx.job.metadata
, then set STT/LLM/tools/initial context or routing behavior accordingly before starting session. 4) Optional alternatives • Use participant attributes to surface caller info into the room and let the agent read those attributes in its entrypoint — but you still need to delay or control dispatch so the agent sees the updated attributes. • If immediate auto-dispatch is required by SIP flow, consider adjusting the SIP workflow to pause dispatch until your backend returns the desired metadata and triggers the explicit dispatch. If you want, tell me: • Which webhook event you receive for inbound calls (e.g.,
participant_joined
or
room_started
), and • Whether your current SIP setup auto-dispatches immediately I’ll give a concise example tailored to your webhook event and language (Node/Python). Sources: Agents telephony integration | LiveKit Docs | Webhooks | LiveKit docs | SIP participant | LiveKit docs | Agent dispatch | LiveKit docs | Job lifecycle | LiveKit docs