how can I implement call transfers?
# ask-ai
m
how can I implement call transfers?
t
Thanks for reaching out, Daniel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you’re looking to set up call transfers in LiveKit, the
TransferSIPParticipant
API is your go-to. It helps you move a SIP participant to another phone number or SIP endpoint. Here’s a quick rundown: 1. Configure SIP Trunk: First, make sure your SIP trunk (like Twilio) is ready to handle transfers. For Twilio, you can easily enable this with their CLI command. 2. Use the API: Then, just call the
TransferSIPParticipant
API with details like the participant’s identity, room name, and where you want to transfer them (phone number or SIP URI). 3. Optional Dial Tone: If you want, you can even play a dial tone before the transfer happens. If you’d like me to walk you through the steps or share some code examples, just give me a shout—I’m happy to help! Sources: Transferring calls | LiveKit Docs | SIP APIs | LiveKit Docs | Company directory phone assistant | LiveKit Docs | README.md | telephony/warm_handoff.py
m
I am using Telnyx. What do I need to do here?
t
Hey there! To get Telnyx set up for call transfers in LiveKit, here’s a simple step-by-step guide for you: 1. Set Up Telnyx SIP Trunk: ◦ First, log into your Telnyx portal and create a SIP trunk using FQDN authentication. You’ll want to use your LiveKit SIP endpoint (like
vjnxecm0tjk.sip.livekit.cloud
) as the FQDN. ◦ Make sure the Destination Number Format is set to
+E.164
, and pick TCP or UDP for the transport protocol (just a heads up, TLS won’t work here). ◦ Don’t forget to assign your purchased phone number to this trunk. 1. Enable Call Transfers: You can use the
TransferSIPParticipant
API to transfer calls. Just provide the room name, participant identity, and the destination number (for example,
tel:+15105550100
or
sip:+15105550100@sip.telnyx.com
). 2. Important: Since SIP REFER (which handles transfers) doesn’t work with TLS, please make sure your trunk uses TCP or UDP. If you run into any trouble, double-check that SIP REFER is enabled in your Telnyx account and that the destination number is reachable. And hey, if you want me to walk you through anything else or share some examples, just let me know—I’m here to help! Sources: Secure trunking | LiveKit Docs | Create and configure Telnyx SIP trunk | LiveKit Docs | Transferring calls | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs
m
I already have a Telnyx SIP Trunk. Do I need to enable anything here regarding call transfers?
t
Hey there! To make sure call transfers work smoothly with your Telnyx SIP trunk, here are a few things to double-check: 1. Transport Protocol: Go with TCP or UDP for your trunk. Just a heads-up, TLS won’t work because SIP REFER (which handles transfers) isn’t supported with TLS. 2. SIP REFER Support: It’s a good idea to confirm with Telnyx support that SIP REFER is enabled on your trunk since it’s essential for call transfers. 3. Destination Format: Make sure your destination number or SIP URI is formatted correctly—something like
tel:+15105550100
or
sip:+15105550100@sip.telnyx.com
. If you’ve got these set up already, you’re all set to use the
TransferSIPParticipant
API for your call transfers. And hey, if you want a hand checking these settings or getting the API up and running, just let me know—I’m here to help!
m
I need to transfer the call to a non-SIP participant (PSTN). Do I need to make an outbound call? Or can I still just use create_sip_participant?
t
Hey there! If you want to transfer a call to someone who’s not using SIP (like a regular phone number on the PSTN), the best way is to use the
TransferSIPParticipant
API. This lets you move an active SIP participant over to a PSTN number by setting the
transfer_to
parameter to the phone number you want, like
tel:+15105550100
. Just a quick heads-up: the
CreateSIPParticipant
API is actually for starting new outbound SIP or PSTN calls, not for transferring calls that are already happening. So, if you’re looking to transfer an active call, sticking with
TransferSIPParticipant
is the way to go. If you have any questions or need a hand with this, feel free to reach out—I’m here to help! Sources: lib/livekit/sip_service_client.rb | packages/livekit-server-sdk/src/SipClient.ts | Transferring calls | LiveKit Docs | SIP overview | LiveKit Docs | sipclient.go
m
I set up an outbound trunk with Telnyx and LiveKit. This is how I am forwarding my call:
Copy code
response = await self.job_ctx.api.sip.transfer_sip_participant(
            api.TransferSIPParticipantRequest(
                room_name=room_name,
                participant_identity=identity,
                transfer_to=f"tel:{phone_number}",
            )
        )
The call is successfully transferred except that the receiver see "No Caller ID". How can I show the number with whom I do the outbound?
t
Hey there! Just a quick note: the
TransferSIPParticipant
API doesn’t let you set the caller ID directly. But no worries! To make sure the right caller ID shows up during call transfers, here’s what you can do: 1. Configure Caller ID Passthrough on Telnyx: Head over to your Telnyx SIP trunk settings and enable caller ID (ANI) passthrough. Just double-check that the number you want to display is verified or allowed by Telnyx. 2. Set Trunk Caller ID Behavior: Make sure your trunk is set to use the original caller’s number (from-transferee) instead of the system’s number (from-transferor). 3. Optional SIP Headers: You can also use the
headers
field in
TransferSIPParticipantRequest
to add custom SIP headers like
From
, which might help with caller ID. Here’s a quick example:
Copy code
transfer_request = TransferSIPParticipantRequest(
    participant_identity=participant_identity,
    room_name=room_name,
    transfer_to=f"tel:{phone_number}",
    headers={"From": "original_caller@sip.telnyx.com"}
)
If you want, I’m happy to help you check your Telnyx trunk settings or walk you through testing this setup. Just let me know! Sources: Transferring calls | LiveKit Docs | livekit/livekit_sip.twirp.go | Preserving Caller ID During SIP Transfers in LiveKit Agents