creamy-tiger-14805
10/28/2025, 8:19 AMtall-airline-16756
10/28/2025, 8:19 AMtall-airline-16756
10/28/2025, 8:20 AMcreamy-tiger-14805
10/28/2025, 8:23 AMtall-airline-16756
10/28/2025, 8:24 AMWorkerOptions. This helps ensure your agent is dispatched correctly. Here’s an example to guide you: cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, agent_name="your-agent-name"))
2. Set Up Inbound Trunk and Dispatch Rule:
◦ Begin by configuring a SIP trunk with your provider so calls can route to LiveKit smoothly.
◦ Next, create an inbound trunk within LiveKit and set up a dispatch rule that directs calls to a room and triggers your agent.
1. Define the Entrypoint Function: This function is key—it initializes the agent session and connects it to the call room. Here’s a friendly example: async def entrypoint(ctx: JobContext):
session = AgentSession()
await session.start(
agent=YourCustomAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(),
room_output_options=RoomOutputOptions(transcription_enabled=True),
)
2. Answer and Interact with Calls: When you’re ready to respond, use generate_reply to engage dynamically. For instance: await session.generate_reply("Hello, how can I assist you today?")
3. Run and Test: Finally, start your agent application and give it a test by dialing the phone number you’ve set up.
If you run into any questions or want a hand with specific parts, like setting up your SIP provider or crafting dispatch rules, just reach out—I’m here to help!
Sources: README.md | packages/sip--um-actually/README.md | Agents telephony integration | LiveKit Docs | Accepting inbound calls | LiveKit Docs | examples/voice_agents/weather_agent.pycreamy-tiger-14805
10/28/2025, 9:37 AMtall-airline-16756
10/28/2025, 9:37 AMcreamy-tiger-14805
10/28/2025, 11:33 AMtall-airline-16756
10/28/2025, 11:33 AMbrew upgrade livekit-cli.
• Linux: You can update by running curl -sSL https://get.livekit.io/cli | bash.
• Windows: For those who installed via Winget, just run winget upgrade LiveKit.LiveKitCLI.
If you prefer, you can also grab the latest precompiled binaries directly from the GitHub releases page. Feel free to reach out if you need any help along the way!
Sources: LiveKit CLI Setup | LiveKit Docs | README.mdcreamy-tiger-14805
10/28/2025, 1:20 PMtall-airline-16756
10/28/2025, 1:21 PMmetadata field like this: {
"metadata": "{\"is_internal\": true}"
}
1. Using the API:
◦ Simply include the metadata field in your CreateSIPDispatchRuleRequest payload. Here's an example: {
"dispatch_rule": {
"name": "My Dispatch Rule",
"metadata": "{\"is_internal\": true}",
"rule": { /* your dispatch rule type */ }
}
}
1. Using SDKs (e.g., Python): await sip_service.update_dispatch_rule_fields(
rule_id="your-rule-id",
metadata='{\"is_internal\": true}'
)
Just a quick note: the metadata field expects a string, and using JSON is a great way to keep your data structured. This metadata will be passed along to any SIP participants created through the dispatch rule. If you have any questions or need further help, feel free to ask—I'm here for you!
Sources: SIP dispatch rule | LiveKit Docs | protobufs/livekit_sip.proto | livekit-api/livekit/api/sip_service.py | Agent dispatch | LiveKit Docscreamy-tiger-14805
10/28/2025, 1:23 PMtall-airline-16756
10/28/2025, 1:24 PMheaders_to_attributes field in your inbound trunk configuration. Here's a simple example: {
"headers_to_attributes": {
"From": "caller_number",
"P-Asserted-Identity": "verified_caller_id"
}
}
2. Create the Inbound Trunk: Use the LiveKit CLI to create the trunk with your updated configuration.
3. Access Caller Information: The attributes you mapped (like caller_number) will then be available as participant attributes in your LiveKit room.
If you’d like, I’m here to help you configure this for your specific SIP provider or guide you on how to access these attributes in your app. Just let me know—I'm happy to assist!
Sources: rpc/sip.pb.go | SIP inbound trunk | LiveKit Docs | Agent dispatch | LiveKit Docs | Inbound calls with Twilio Voice | LiveKit Docs | Create and configure a Plivo SIP trunk | LiveKit Docscreamy-tiger-14805
10/28/2025, 1:30 PMtall-airline-16756
10/28/2025, 1:31 PMCreateSIPParticipant API, which connects a SIP participant to the room you specify. This involves outbound trunks, which are separate setups dedicated to managing outbound SIP traffic.
Sources: SIP overview | LiveKit Docs | SIP dispatch rule | LiveKit Docs | livekit/livekit_sip.pb.gocreamy-tiger-14805
10/29/2025, 5:30 AMtall-airline-16756
10/29/2025, 5:30 AMheaders field in the dispatch rule configuration. This lets you include custom SIP X-* headers, which will be added to the 200 OK response during the SIP INVITE process.
Here’s a simple example to show you how to include headers in a dispatch rule:
{
"headers": {
"X-Custom-Header": "value1",
"X-Another-Header": "value2"
}
}
You can set this up either through the LiveKit Cloud dashboard using the JSON editor, or programmatically via the API or SDKs. If you’d like, I’m here to help you with any specific implementation or questions you might have!
Sources: SIP APIs | LiveKit Docs | rpc/io.pb.go | SIP dispatch rule | LiveKit Docscreamy-tiger-14805
10/29/2025, 5:32 AM{
"sipDispatchRuleId": "SDR_kaks6rsafdsdffas9b3",
"rule": {
"dispatchRuleIndividual": {
"roomPrefix": "inbound_"
}
},
"trunkIds": [
"ST_XguXMasdfsdfQmvy73"
],
"name": "inbound-dispatch-rule",
"roomConfig": {
"agents": [
{
"agentName": "livekit_master_inbound_agent"
}
]
}
}tall-airline-16756
10/29/2025, 5:32 AMheaders field to your JSON. Here's a friendly example to guide you:
{
"sipDispatchRuleId": "SDR_kaks6rsafdsdffas9b3",
"rule": {
"dispatchRuleIndividual": {
"roomPrefix": "inbound_"
}
},
"trunkIds": [
"ST_XguXMasdfsdfQmvy73"
],
"name": "inbound-dispatch-rule",
"roomConfig": {
"agents": [
{
"agentName": "livekit_master_inbound_agent"
}
]
},
"headers": {
"X-Custom-Header": "value1",
"X-Another-Header": "value2"
}
}
If you have any questions or need a hand with this setup, please don’t hesitate to reach out—I’m here to help!creamy-tiger-14805
10/29/2025, 5:38 AMinbound_<caller-number> I want to capture this number and use it in my attributes.tall-airline-16756
10/29/2025, 5:39 AMsip.phoneNumber. This is the easiest and most reliable way to get the caller’s number.
If you prefer to use the room name to store and extract the caller number (for example, inbound_<caller-number>), you would need to add some custom application logic outside of LiveKit to parse the room name and pull out the number. Just a heads-up, this method isn’t natively supported by LiveKit.
Please feel free to reach out if you’d like a hand accessing sip.phoneNumber or if you want to set up custom attributes tailored to your needs—I’m here to help!
Sources: SIP participant | LiveKit Docs | livekit-protocol/src/livekit.rs | SIP dispatch rule | LiveKit Docs | livekit/livekit_connector_whatsapp.pb.gocreamy-tiger-14805
10/29/2025, 5:41 AMtall-airline-16756
10/29/2025, 5:41 AMsip.phoneNumber through the participant attributes in the LiveKit room. This field holds the caller's phone number for inbound calls or the dialed number for outbound calls. Just a quick heads-up—it might not be available if the HidePhoneNumber setting is enabled in the dispatch rule.
Here are some other useful fields passed to the agent:
• SIP Participant Attributes:
◦ `sip.callID`: This is LiveKit’s SIP call ID.
◦ `sip.callStatus`: Shows the current call status, like active or dialing.
◦ `sip.ruleID`: The dispatch rule ID used for the call.
◦ `sip.trunkID`: The SIP trunk ID involved in the call.
◦ `sip.trunkPhoneNumber`: The phone number linked to the SIP trunk.
• Job Metadata: You can pass custom data such as user_id, user_name, or user_phone when dispatching to an agent.
• Room and Participant Metadata: This includes room metadata, participant name, and any custom attributes you’ve set.
If you’d like, I’m here to guide you through accessing these fields or using them in your agent workflows—just let me know!
Sources: SIP participant | LiveKit Docs | Job lifecycle | LiveKit Docs | Preserving Caller ID During SIP Transfers in LiveKit Agentscreamy-tiger-14805
10/29/2025, 5:43 AMtall-airline-16756
10/29/2025, 5:43 AMsip.h.x-custom-id.
You’ll find these attributes available in room events like participant_attributes_changed, which you can use to tailor the agent’s experience.
Regarding job metadata, it’s a flexible string field that you pass during agent dispatch. This usually includes structured data like:
• User-specific details (for example, user ID, name, or phone number).
• Custom workflow parameters that fit your needs.
• Authentication tokens or context IDs.
You can access job metadata in the agent’s entrypoint function through the JobContext. If you’d like, I’m here to guide you through implementing these features step-by-step!
Sources: telephony/sip_lifecycle.py | rpc/io.pb.go | livekit-protocol/src/livekit.rs | Job lifecycle | LiveKit Docs | Agent dispatch | LiveKit Docscreamy-tiger-14805
10/29/2025, 5:47 AMtall-airline-16756
10/29/2025, 5:47 AMuser_name and user_phone with an agent, a great way is to include them in the job_metadata field when you dispatch the agent. Here’s a simple example of how your JSON for the dispatch request might look:
{
"agent_name": "your-agent-name",
"job_metadata": {
"user_name": "John Doe",
"user_phone": "+1234567890"
}
}
Then, in the agent’s entrypoint function, you can easily grab these values from the JobContext object. Here’s a quick example in Python:
async def entrypoint(ctx: JobContext):
user_name = ctx.job_metadata.get("user_name")
user_phone = ctx.job_metadata.get("user_phone")
print(f"User Name: {user_name}, User Phone: {user_phone}")
If you’d like, I’m here to help you walk through this setup or answer any other questions you might have!creamy-tiger-14805
10/29/2025, 5:48 AMtall-airline-16756
10/29/2025, 5:48 AMuser_phone (the caller’s phone number) and stores it in the SIP participant attribute sip.phoneNumber. You can easily retrieve it from this attribute as soon as the SIP participant joins the room.
If you'd like to pass it explicitly in job_metadata, you can simply extract it from sip.phoneNumber and include it in your dispatch request. Here’s a quick example to guide you:
{
"agent_name": "your-agent-name",
"job_metadata": {
"user_name": "John Doe",
"user_phone": "{sip.phoneNumber}"
}
}
If you have any questions or need a hand with implementing this, just let me know—I’m here to help!creamy-tiger-14805
10/30/2025, 9:58 AM{
"agent_name": "your-agent-name",
"job_metadata": {
"user_name": "John Doe",
"user_phone": "{sip.phoneNumber}"
}
}
should the {sip.phoneNumber} be in code block?tall-airline-16756
10/30/2025, 9:59 AM{sip.phoneNumber} placeholder shouldn’t be included exactly like that in the JSON. Instead, you’ll want to dynamically replace it with the real value of sip.phoneNumber from the SIP participant attributes when you’re building the dispatch request.
Here’s a simple example in Python to help illustrate:
user_phone = participant.attributes.get("sip.phoneNumber")
job_metadata = {
"user_name": "John Doe",
"user_phone": user_phone
}
This way, the actual phone number gets passed in the job_metadata field. If you’d like me to walk you through this further or have any other questions, just let me know—I’m here to help!creamy-tiger-14805
10/30/2025, 9:59 AMtall-airline-16756
10/30/2025, 10:00 AMsip.h.x-custom-id.
You can find these attributes in room events, and they’re great for customizing your workflows. If you’d like, I’m here to help you access or use any of these attributes—just let me know!creamy-tiger-14805
10/30/2025, 10:01 AMtall-airline-16756
10/30/2025, 10:02 AMsip.callID, sip.phoneNumber, sip.callStatus, and others—are accessible in the participant.attributes field whenever a SIP participant joins a room.
To capture these SIP attributes, you can set up an event handler for on_participant_connected or on_participant_attributes_changed. Here’s a simple example to get you started:
def on_participant_attributes_changed_handler(changed_attributes: dict, participant: rtc.Participant):
if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
call_id = participant.attributes.get("sip.callID", "Unknown")
phone_number = participant.attributes.get("sip.phoneNumber", "Unknown")
logger.info(f"SIP Call ID: {call_id}, Phone Number: {phone_number}")
If you’d like, I’m here to help you set up this logging in your application—just let me know!
Sources: protobufs/rpc/sip.proto | SIP participant | LiveKit Docs | telephony/sip_lifecycle.pycreamy-tiger-14805
10/30/2025, 10:10 AMtall-airline-16756
10/30/2025, 10:11 AMentrypoint function of your agent, you can use the JobContext object, which holds all the room and participant details. Here’s a friendly example in Python to guide you:
async def entrypoint(ctx: JobContext):
# Access the room participants
for participant in ctx.room.participants:
if participant.kind == "SIP":
# Extract SIP attributes
call_id = participant.attributes.get("sip.callID", "Unknown")
phone_number = participant.attributes.get("sip.phoneNumber", "Unknown")
call_status = participant.attributes.get("sip.callStatus", "Unknown")
# Log or use the extracted attributes
print(f"SIP Call ID: {call_id}")
print(f"Phone Number: {phone_number}")
print(f"Call Status: {call_status}")
This snippet goes through each participant in the room, checks if they are of kind SIP, and then gently pulls out the SIP attributes from participant.attributes.
If you have any questions or want to explore this further, please don’t hesitate to reach out—I’m here to help you every step of the way!