polite-furniture-24847
09/25/2025, 7:36 AMtall-airline-16756
09/25/2025, 7:37 AMtall-airline-16756
09/25/2025, 7:37 AMpolite-furniture-24847
09/25/2025, 7:38 AMtall-airline-16756
09/25/2025, 7:39 AMTransferSIPParticipant API. This API uses the SIP REFER method to smoothly forward a caller to another phone number or SIP endpoint. Let me walk you through the process:
1. Ensure Trunk Provider Support: It’s important that your SIP trunk provider supports SIP REFER. For example, if you’re using Twilio, you’ll want to make sure “Call Transfer (SIP REFER)” and “Enable PSTN Transfer” are enabled in your trunk settings.
2. Call the API: You’ll use the TransferSIPParticipant API, providing details like the room name, participant identity, and the destination number or SIP URI (such as tel:+1234567890 or sip:user@host).
3. Session Termination: Once the transfer is complete, the caller will leave the LiveKit room, and the session will end.
Here’s a friendly example of how you might use the API in Node.js:
import { SipClient } from 'livekit-server-sdk';
async function transferParticipant(participant) {
const sipClient = new SipClient(
process.env.LIVEKIT_URL,
process.env.LIVEKIT_API_KEY,
process.env.LIVEKIT_API_SECRET
);
const transferTo = "tel:+15105550100";
await sipClient.transferSipParticipant(
'open-room',
participant.identity,
transferTo
);
console.log('Transfer initiated');
}
If you’d like, I’m here to provide more details or examples in Python and CLI too—just let me know how I can assist you further!
Sources: test/integration/sip_test.go | Transferring calls | LiveKit Docs | Agents telephony integration | LiveKit Docs | Using Wavix to accept and make calls | LiveKit Docs | pkg/service/sip.gopolite-furniture-24847
09/25/2025, 7:55 AMtall-airline-16756
09/25/2025, 7:56 AMimport asyncio
import logging
from livekit import api
from livekit.protocol.sip import TransferSIPParticipantRequest
# Set up logging
logger = logging.getLogger("transfer-logger")
logger.setLevel(<http://logging.INFO|logging.INFO>)
async def transfer_call(participant_identity: str, room_name: str):
async with api.LiveKitAPI() as livekit_api:
transfer_to = 'tel:+14155550100' # Replace with the destination number or SIP URI
transfer_request = TransferSIPParticipantRequest(
participant_identity=participant_identity,
room_name=room_name,
transfer_to=transfer_to,
play_dialtone=False # Optional: Set to True to play a dialtone during transfer
)
await livekit_api.sip.transfer_sip_participant(transfer_request)
<http://logger.info|logger.info>(f"Successfully transferred participant {participant_identity} to {transfer_to}")
# Example usage
if __name__ == "__main__":
participant_id = "example-participant" # Replace with the participant's identity
room_name = "example-room" # Replace with the room name
asyncio.run(transfer_call(participant_id, room_name))
Just make sure to replace participant_identity, room_name, and transfer_to with the values that fit your situation. If anything feels unclear or you want to dive deeper, please don't hesitate to reach out—I'm here to help!