great-tiger-31125
08/13/2025, 1:49 PMtransfer_sip_participant API and was hoping you could provide some clarity.
Here is the relevant code I'm using:
async def cold_sip_transfer(
participant_identity: str,
room_name: str,
transfer_to: str,
) -> str | None:
"""
Transfer a SIP participant to another number.
"""
try:
async with get_livekit_api() as livekit_api:
transfer_request = TransferSIPParticipantRequest(
participant_identity=participant_identity,
room_name=room_name,
transfer_to=f"tel:{transfer_to}",
play_dialtone=True,
)
logger.debug(f"Transfer request: {transfer_request}")
await livekit_api.sip.transfer_sip_participant(transfer_request)
logger.info(f"Successfully transferred participant {participant_identity} to {transfer_to}")
return None
except Exception as e:
raise ToolError(f"Failed to transfer SIP participant {participant_identity} to {transfer_to}: {str(e)}") from e
My issue is that the livekit_api.sip.transfer_sip_participant function completes without raising an exception if the transferee's line is busy (Transferee Rejected the call) and logging Successfully transferred participant.... This leads my application to incorrectly log the transfer as successful. It should have gone to exception.
In contrast, if the call rings and then times out (no answer), the function correctly raises an exception, which my try...except block handles as expected.
Any guidance on how to accurately handle this "busy" or "handoff" scenario would be greatly appreciated.
Thank you!