Does livekit provide options to play hold ringtone...
# ask-ai
r
Does livekit provide options to play hold ringtone when we transfer a call to new number ?
t
Thanks for reaching out, pritesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just wanted to let you know that LiveKit offers a handy option to play a dial tone when you’re transferring a call to a new number. You can use the
play_dialtone
parameter, which is available in different SDKs and backend setups. This dial tone acts like the usual ringing sound you’d expect when a call is on hold during a transfer—pretty neat, right? Sources: pkg/sip/inbound.go | examples/warm-transfer/warm_transfer.py | packages/livekit-server-sdk/src/SipClient.ts | sip-refer/agent.py | protobufs/rpc/sip.proto
r
elif transfer_type in ["warm_message", "warm_summary"]: target_phone_number = transfer_to_phone.replace("tel:", "") # Warm transfer - add agent to current room sip_trunk_id = await get_outbound_trunk_id_from_number( livekit_api, target_phone_number ) # Create SIP participant request to add new agent to room supervisor_identity = f"supervisor-{participant_identity}" create_request = api.CreateSIPParticipantRequest( _sip_trunk_id_=sip_trunk_id, _sip_call_to_=target_phone_number, _room_name_=room_name, _participant_identity_=supervisor_identity, _krisp_enabled_=True, _wait_until_answered_=True, ) logger.debug(f"Warm transfer request: {create_request}") # Add new agent to the room await livekit_api.sip.create_sip_participant(create_request) logger.info( f"Successfully added new agent to room {room_name} ({transfer_type})" ) # Wait for the supervisor to actually connect to the room supervisor_connected = False max_wait_time = 30 # Maximum 30 seconds to wait wait_interval = 1 # Check every second for _ in range(max_wait_time): # Check if supervisor is in the room room_participants = await livekit_api.room.list_participants( api.ListParticipantsRequest(room=room_name) ) supervisor_in_room = any( p.identity == supervisor_identity for p in room_participants.participants ) if supervisor_in_room: supervisor_connected = True logger.info(f"Supervisor {supervisor_identity} connected to room") break await asyncio.sleep(wait_interval) if not supervisor_connected: logger.warning( f"Supervisor did not connect within {max_wait_time} seconds" ) return "Supervisor could not be reached. Please try again." # Get supervisor's audio track SID participant_info = await livekit_api.room.get_participant( api.RoomParticipantIdentity( room=room_name, identity=supervisor_identity ) ) audio_track_sid = None for track in participant_info.tracks: if track.type == api.TrackType.AUDIO: audio_track_sid = track.sid break if not audio_track_sid: logger.warning( f"No audio track found for supervisor {supervisor_identity}" ) return "Failed to mute supervisor: No audio track found." # Mute the supervisor's audio track await livekit_api.room.mute_published_track( api.MuteRoomTrackRequest( room=room_name, identity=supervisor_identity, _track_sid_=audio_track_sid, muted=True, ) ) logger.info(f"Supervisor {supervisor_identity} audio track muted") # Wait a brief moment for supervisor to settle await asyncio.sleep(2) # Deliver the warm transfer message if warm_transfer_message: await session.say(warm_transfer_message, _add_to_chat_ctx_=True) await asyncio.sleep(3) # Wait for message to complete # Unmute the supervisor's audio track await livekit_api.room.mute_published_track( api.MuteRoomTrackRequest( room=room_name, identity=supervisor_identity, _track_sid_=audio_track_sid, muted=False, ) ) logger.info(f"Supervisor {supervisor_identity} audio track unmuted") # Brief pause before agent disconnects await asyncio.sleep(1) # Disconnect the current agent await session.aclose() logger.info("Current agent disconnected - supervisor taking over") logger.info( f"Successfully transferred participant {participant_identity} to {transfer_to_phone} (warm transfer)" ) return warm_transfer_message except Exception as e: error_msg = f"Failed to transfer call: {e}" logger.error(error_msg) return error_msg How we can play a ringtone while transferring ?
t
If you want to play a ringtone while transferring a call in LiveKit, you can use the
play_dialtone
parameter in your transfer request. This will play a dial tone as a little audible cue during the transfer, which can be really helpful. For example, in Python, just set
play_dialtone=True
when you create the transfer request like this:
Copy code
# Transfer with dialtone playback
await api.sip.transfer_sip_participant(
    api.TransferSIPParticipantRequest(
        room_name="my-room",
        participant_identity="sip-participant",
        transfer_to="+1234567890",
        play_dialtone=True
    )
)
Also, make sure your SIP trunk supports call transfers and that your token has the right authorization grants. If you have any questions or need a hand with this, just let me know—I’m here to help! Sources: src/main/kotlin/io/livekit/server/SipServiceClient.kt | cmd/lk/sip.go | SIP APIs | LiveKit Docs | livekit/livekit_sip.pb.go | packages/livekit-server-sdk/src/SipClient.ts