chilly-plumber-14235
11/17/2025, 9:45 PMtall-airline-16756
11/17/2025, 9:45 PMtall-airline-16756
11/17/2025, 9:46 PMCreateSIPParticipant API for outbound calls or by setting up SIP dispatch rules for inbound calls.
Outbound SIP Calls:
• You can specify the room context by using the room_name, room_config, or room_preset parameters.
• Adding participant metadata and attributes is a great way to provide extra context.
• Don't forget, custom SIP headers can also be used to pass context, and these can be mapped to participant attributes.
Inbound SIP Calls:
• Setting up SIP dispatch rules allows you to define the room context and route calls to the right rooms.
• For more precise control, you can use the room_config.agents field to explicitly dispatch agents.
If you'd like, I can share detailed examples or walk you through any part of this—just let me know!
Sources: SIP APIs | LiveKit docs | protobufs/livekit_sip.proto | Agent dispatch | LiveKit Docs | test/lktest-sip-outbound/README.mdchilly-plumber-14235
11/17/2025, 9:48 PMtall-airline-16756
11/17/2025, 9:49 PMsip.phoneNumber) once the call connects to a LiveKit room.
You can definitely use this attribute to programmatically call an external API after the call connects. For example, an AI agent or backend service can grab the phone number and pull in additional context from a CRM or database. Here’s a simple flow to guide you:
1. Detect when the SIP participant joins the room.
2. Extract the sip.phoneNumber attribute.
3. Call your external API using this number.
4. Use the returned context to enhance the session (like updating attributes or customizing agent behavior).
Also, if your SIP provider supports custom headers, you can pass pre-call data (such as a customer ID) through SIP headers and map them to participant attributes using the headers_to_attributes configuration. This can be really handy!
Please feel free to ask if you'd like me to walk you through more details or provide examples—I’m here to help!
Sources: SIP participant | LiveKit docschilly-plumber-14235
11/17/2025, 9:51 PMtall-airline-16756
11/17/2025, 9:52 PMconst livekit = require('livekit-server-sdk');
// Initialize LiveKit Room
const room = new livekit.Room();
// Listen for participant connection events
room.on('participant_connected', async (participant) => {
if (participant.kind === 'SIP') {
// Extract the caller's phone number from participant attributes
const phoneNumber = participant.attributes['sip.phoneNumber'];
// Call an external API to fetch context using the phone number
const context = await fetchUserContextFromAPI(phoneNumber);
// Apply the returned context (e.g., update participant metadata)
participant.metadata = JSON.stringify(context);
console.log(`Context for ${phoneNumber}:`, context);
}
});
// Example function to call an external API
async function fetchUserContextFromAPI(phoneNumber) {
const response = await fetch(`${process.env.BASE_API_URL}/user-context?phone=${phoneNumber}`);
if (!response.ok) {
throw new Error('Failed to fetch user context');
}
return response.json();
}
// Start the room (replace with your actual room connection logic)
room.connect('ws://your-livekit-server', 'your-api-key', 'your-api-secret');
This example walks you through:
• Listening for the participant_connected event.
• Extracting the sip.phoneNumber attribute.
• Calling an external API to fetch user context.
• Applying the fetched context to the participant’s metadata.
Just a quick note: be sure to replace process.env.BASE_API_URL with your actual API base URL. If anything isn’t clear or if you'd like me to provide more examples, please don’t hesitate to ask—I’m here to help!chilly-plumber-14235
11/17/2025, 9:53 PMtall-airline-16756
11/17/2025, 9:53 PMsip.phoneNumber attribute. You can use this to reach out to an external API and gather extra context, like customer details, preferences, or history.
To make sure this happens before the agent steps in, here’s a simple approach:
1. Set up your backend or AI agent to listen for the participant_connected event.
2. Use the phone number from the sip.phoneNumber attribute to fetch the caller’s details.
3. Process and store the information you get (for example, update participant metadata or get it ready for the agent).
4. Only let the agent join the room once all this context is prepared.
This way, your agent will have all the important information about the caller before they start the interaction. If you’d like, I’m here to help you set up this flow—just let me know!chilly-plumber-14235
11/17/2025, 10:10 PMtall-airline-16756
11/17/2025, 10:11 PMsip.phoneNumber key.
Here’s how you can access it:
• Make sure the HidePhoneNumber option is turned off in your SIP dispatch rule.
• Once the call connects to the room, you can retrieve the sip.phoneNumber attribute from the participant's metadata.
The phone number will be in E.164 format, which means it includes the country code and the full number without any special characters or spaces. If you have any questions or need a hand with this, just let me know—I’m here to help!
Sources: SIP participant | LiveKit docs | protobufs/rpc/sip.protochilly-plumber-14235
11/17/2025, 10:12 PMtall-airline-16756
11/17/2025, 10:12 PMsip.phoneNumber attribute, which is taken from the SIP INVITE request.
• Number Being Called: This shows up in the call_to field, representing the number the caller is dialing.
Both of these values come from the SIP signaling information that LiveKit processes. Just make sure your SIP trunk configuration includes the relevant numbers in the numbers field of your inbound trunk setup, so calls to those numbers are accepted smoothly.
If you'd like, I’m happy to provide more details or examples—just let me know!
Sources: protobufs/livekit_sip.protochilly-plumber-14235
11/17/2025, 10:15 PMtall-airline-16756
11/17/2025, 10:16 PMchilly-plumber-14235
11/17/2025, 10:39 PMtall-airline-16756
11/20/2025, 12:39 PMTransferSIPParticipant API, which supports cold transfers. Here’s a simple breakdown:
• Cold Transfer: The agent transfers the call to another phone number or SIP URI, and the current session ends once the transfer is complete.
• The key parameters you’ll need include:
◦ `participant_identity`: This is the identity of the participant you want to transfer.
◦ `room_name`: The name of the room where the participant is currently.
◦ `transfer_to`: The destination phone number or SIP URI (for example, tel:+15105550100 or sip:user@domain.com).
◦ play_dialtone (optional): You can choose whether to play a dial tone during the transfer.
If you’re looking to do a warm transfer, where the agent first connects with the transferee to provide some context, you can use CreateSIPParticipant to call the transferee and then MoveParticipant to bring them into the original call.
Also, just a quick reminder to make sure your SIP trunk is set up to allow call transfers. If you’d like, I’m more than happy to share more details or walk you through some examples—just let me know!
Sources: SIP APIs | LiveKit docs | README.md | agent.py | Agent-assisted warm transfer | LiveKit docs | examples/warm-transfer/README.md