clever-rose-90056
11/10/2025, 4:52 PMTransferSIPParticipantRequest after ctx.connect and ctx.wait_for_participant, but getting:
`livekit.api.twirp_client.TwirpError: TwirpError(code=failed_precondition, message=twirp error unknown: can't transfer non established call, status=412)`Any ideas how to fix this? Not sure how to wait for the call to be "established".
Code:
async def entrypoint(ctx: JobContext):
logger.info(f"connecting to room {ctx.room.name}")
await ctx.connect()
user_participant = await ctx.wait_for_participant()
logger.info(
f"participant joined, participant={user_participant}"
)
session_data, init_job_metadata = await get_init_userdata(
ctx, user_participant
)
# Cold transfer if needed
if session_data.transfer_on_callback:
logger.info("transfer_on_callback is true, initiating cold transfer")
async with api.LiveKitAPI() as livekit_api:
transfer_to = "tel:" + env("TRANSFER_PHONE_NUMBER")
transfer_request = TransferSIPParticipantRequest(
participant_identity=user_participant.identity,
room_name=ctx.room.name,
transfer_to=transfer_to,
play_dialtone=False,
)
logger.debug(f"Transfer request: {transfer_request}")
await livekit_api.sip.transfer_sip_participant(transfer_request)
logger.info(
f"Successfully transferred participant {user_participant.identity} to {transfer_to}"
)
returnrefined-appointment-81829
11/10/2025, 5:12 PMactive before attempting the transfer. sip_lifecycle.py:183-210 The sip.callStatus attribute indicates the current state of the call, and it needs to be active (not dialing or ringing) before a transfer can succeed.clever-rose-90056
11/10/2025, 6:38 PMringing, I'm guessing I need to "answer" the call somehow. Is there a way to do that without setting up a full AgentSession?refined-appointment-81829
11/10/2025, 8:57 PMasync def entrypoint(ctx: JobContext):
await ctx.connect()
user_participant = await ctx.wait_for_participant()
# Answer the call by publishing a track
source = rtc.AudioSource(24000, 1)
track = rtc.LocalAudioTrack.create_audio_track("audio", source)
await ctx.room.local_participant.publish_track(track)
# Wait for call status to become active
while user_participant.attributes.get('sip.callStatus') != 'active':
await asyncio.sleep(0.1)
# Now transfer
await livekit_api.sip.transfer_sip_participant(transfer_request)clever-rose-90056
11/10/2025, 9:33 PM