red-insurance-72205
07/27/2025, 10:14 AMtall-airline-16756
07/27/2025, 10:14 AMtall-airline-16756
07/27/2025, 10:15 AMcreate_sip_participant
API. This allows you to add a new SIP participant (the receiving human agent) to the same room as the current call.
Steps to Create the SIP Participant:
1. Retrieve the required environment variables such as LIVEKIT_URL
, LIVEKIT_API_KEY
, LIVEKIT_API_SECRET
, SIP_TRUNK_ID
, and optionally LIVEKIT_ROOM_NAME
.
2. Use the create_sip_participant
API to add the human agent to the room. This ensures the original call remains active while the new participant joins.
3. Provide a message to the caller, such as "I'm transferring you to a human agent now. Please hold while we connect you."
Key Differences from Cold Transfer:
• Warm transfer keeps the original call active in the same room, unlike cold transfer which ends the current session.
• It allows for handoff coordination between the AI agent, caller, and human agent.
• Session continuity is maintained until the handoff is complete.
Required Environment Variables:
LIVEKIT_URL=your-livekit-server-url
LIVEKIT_API_KEY=your-api-key
LIVEKIT_API_SECRET=your-api-secret
SIP_TRUNK_ID=your-sip-trunk-id
LIVEKIT_ROOM_NAME=your-room-name # optional
This setup ensures a seamless warm handoff experience where the AI agent can introduce the human agent to the caller and facilitate a smooth transition.
Sources: telephony/warm_handoff.py | Transferring calls | LiveKit Docsred-insurance-72205
07/27/2025, 10:16 AMtransfer_sip_participant
?red-insurance-72205
07/27/2025, 10:17 AMtall-airline-16756
07/27/2025, 10:17 AMtransfer_sip_participant
function in LiveKit for you - it's a super handy tool for moving SIP calls around. Think of it like call forwarding, but with a bit more technical magic. 😊
What's This Function All About?
• Imagine you want to smoothly move a SIP call to another phone number or endpoint - this function does exactly that!
• It uses something called the SIP REFER method to basically "hand off" the active session.
The Nuts and Bolts:
• `room_name`: Where your call is starting from.
• `participant_identity`: Who's making the move.
• `transfer_to`: Where they're heading - could be a phone number like tel:+15105550100
or a SIP address like <sip:+15105550100@sip.telnyx>.com
.
• `play_dialtone`: A fun little option to play a dial tone when the transfer starts.
Real-World Uses:
• Shuffling callers between different departments
• Getting customers to the right support team
• Setting up smart call forwarding
Quick Pro Tips:
• Just so you know, this transfer actually ends the LiveKit session for that participant.
• Make sure your SIP provider is cool with transfers (like setting up Twilio SIP trunk transfers).
• You'll need some specific permissions - SIP call
grant and room admin access.
Got questions? I'm all ears! Shoot me a message, and I'll help you navigate this. 👍red-insurance-72205
07/27/2025, 10:18 AMtransfer_sip_participant
function?
I want a proper example for the warm call transfer.tall-airline-16756
07/27/2025, 10:19 AMtransfer_sip_participant
for a warm transfer, but it's actually designed for cold transfers only. No worries, though – I've got a great solution for you that'll help you smoothly transition calls!
Let me walk you through a warm call transfer method that keeps things super simple and seamless.
Warm Call Transfer Example:
from livekit import api
import os
import uuid
# Required environment variables
LIVEKIT_URL = os.environ.get('LIVEKIT_URL')
LIVEKIT_API_KEY = os.environ.get('LIVEKIT_API_KEY')
LIVEKIT_API_SECRET = os.environ.get('LIVEKIT_API_SECRET')
SIP_TRUNK_ID = os.environ.get('SIP_TRUNK_ID')
ROOM_NAME = os.environ.get('LIVEKIT_ROOM_NAME', 'default-room')
# Create a LiveKit API client
livekit_api = api.LiveKitAPI(
url=LIVEKIT_URL,
api_key=LIVEKIT_API_KEY,
api_secret=LIVEKIT_API_SECRET
)
# Function to add a new SIP participant for warm transfer
def warm_transfer(phone_number):
identity = f"transfer_{uuid.uuid4().hex[:8]}"
try:
response = livekit_api.sip.create_sip_participant(
api.CreateSIPParticipantRequest(
sip_trunk_id=SIP_TRUNK_ID,
sip_call_to=phone_number,
room_name=ROOM_NAME,
participant_identity=identity,
participant_name="Human Agent",
krisp_enabled=True
)
)
print(f"Successfully transferred call to {phone_number}")
return response
except Exception as e:
print(f"Error during warm transfer: {e}")
return None
# Example usage
phone_number = "+15105550100"
warm_transfer(phone_number)
Key Points:
• This approach is super cool because it keeps the original call active in the same room while adding a new SIP participant (the human agent).
• The AI agent can introduce the human agent to the caller and make the transition super smooth.
• Just make sure you've set up those environment variables correctly – LIVEKIT_URL
, LIVEKIT_API_KEY
, LIVEKIT_API_SECRET
, and SIP_TRUNK_ID
are your best friends here!
Need any more help or have questions? I'm right here to help you out! Just give me a shout, and we'll figure this out together. 😊
Sources: Transferring calls | LiveKit Docs | sip-refer/agent.py | Agents telephony integration | LiveKit Docsred-insurance-72205
07/27/2025, 10:21 AMtall-airline-16756
07/27/2025, 10:21 AMred-insurance-72205
07/27/2025, 10:33 AMred-insurance-72205
07/27/2025, 11:39 AM