Cold transfer the caller to a human agent (PSTN number) via SIP REFER when the user requests it. We call transfer_sip_participant from inside a @function_tool:
job_ctx = get_job_context()
room = job_ctx.room
sip_participant = next(
(p for p in room.remote_participants.values()
if p.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP),
None
)
await job_ctx.api.sip.transfer_sip_participant(
livekit_api.TransferSIPParticipantRequest(
room_name=room.name,
participant_identity=sip_participant.identity,
transfer_to="sip:+16282606639@sip.telnyx.com",
play_dialtone=True,
headers={
"Diversion": "<sip:+16187338098@sip.telnyx.com>",
"X-Detected-Topic": "...",
},
)
)
What happens:
The agent confirms the transfer verbally, the tool is called, the call disconnects immediately — the caller hears silence and the room closes. No actual transfer to the target number occurs.
On the Telnyx portal → Outbound Call Reports we see 7 outbound call attempts, all failing with SIP 603 Decline.
Questions:
-
Does the Telnyx FQDN connection that receives the SIP REFER need an outbound voice profile to route the transfer leg to PSTN? Or does Telnyx route it differently from a regular outbound call?
-
Should
transfer_tousetel:+16282606639format instead ofsip:+16282606639@sip.telnyx.com? -
Is there anything specific that needs to be enabled on the LiveKit SIP trunk side (not just Telnyx) to allow REFER to pass through? We only have one trunk and one dispatch rule.
-
Has anyone successfully done a cold transfer to a PSTN number via Telnyx? What was the exact Telnyx configuration required?
Any help appreciated — we’ve been going in circles on this one.