can we do call transfer in outbound calling (where...
# ask-ai
l
can we do call transfer in outbound calling (where agent is calling a person)
t
Thanks for reaching out, Deepak. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, LiveKit does support call transfer during outbound calls made by an agent. You can easily achieve this using the
TransferSIPParticipant
API, which lets you transfer a call to another phone number or SIP URI. Here are some important points to keep in mind: • Both cold and warm transfer workflows are available. With a cold transfer, the agent simply hands off the call and the session ends. Warm transfers take a bit more care, as they involve managing the session to provide context before connecting the caller. • To get this up and running, you’d use the
transfer_sip_participant
method, passing parameters like
room_name
,
participant_identity
, and
transfer_to
(which is the destination number or SIP URI). • There’s also an optional
play_dialtone
parameter if you want to play a dial tone during the transfer. Just a quick reminder to make sure SIP REFER is enabled on your SIP trunk provider. And if you’re using Twilio, don’t forget to activate the "Enable PSTN Transfer" setting. If you’d like, I’m here to help you through the implementation or answer any other questions you might have! Sources: SIP overview | LiveKit Docs | Agents telephony integration | LiveKit Docs | agent.py | Transferring calls | LiveKit Docs | Agent-assisted warm transfer | LiveKit Docs
l
can you show the code, And what is the value for participant_identity?
t
I'd love to share an example of how you can transfer a SIP participant using code:
Copy code
await job_ctx.api.sip.transfer_sip_participant(
    api.TransferSIPParticipantRequest(
        room_name=job_ctx.room.name,  # Replace with the name of the room where the call is taking place
        participant_identity=participant_identity,  # Replace with the identity of the SIP participant to be transferred
        transfer_to="tel:+15105550123",  # Replace with the destination number or SIP URI
        play_dialtone=True  # Optional: Set to True to play a dial tone during the transfer
    )
)
Just a quick note: the
participant_identity
is the unique ID for the SIP participant in the room. Usually, this gets assigned when they join, and you can find it in the participant list or session details. If you're unsure about how to find the
participant_identity
in your setup, please don't hesitate to ask—I'm here to help!
r
Hey I am getting 408 error from twilio Error transferring call: TwirpError(code=canceled, message=twirp error unknown: call transfer failed, status=408) while doing transfer in ouotbound calls
t
I'm sorry to hear you're encountering the 408 error during call transfer—it usually means the transfer request timed out, often due to some hiccups with the destination or SIP trunk setup. Let’s work through this together with a few steps that might help: 1. Verify the Transfer Destination: Double-check that the
transfer_to
URI is correctly formatted (for example,
tel:+15105550100
) and that it’s reachable. 2. Enable SIP REFER and PSTN Transfer on Twilio: Head over to the Twilio Console, navigate to Elastic SIP Trunking » Manage » Trunks, select your trunk, and make sure Call Transfer (SIP REFER) and Enable PSTN Transfer are turned on. Don’t forget to save your changes! 3. Ensure Trunk Permissions: Check that your trunk has the right permissions to transfer calls to the destination you’re targeting. 4. Test Outside LiveKit (Optional): If you want, you can try verifying SIP REFER functionality directly with Twilio’s API to help pinpoint where the issue might be. If you’ve gone through these steps and things still aren’t working quite right, please don’t hesitate to reach out—I’m here to help you get this sorted! Sources: SIP troubleshooting guide | LiveKit Docs | Agents telephony integration | LiveKit Docs | Transferring calls | LiveKit Docs
r
Error transferring call: TwirpError(code=canceled, message=twirp error unknown: call transfer failed: sip status: 403: Caller ID verification rejected, status=408) getting this error now
t
Hi there! The error "Caller ID verification rejected" usually happens when Twilio doesn’t accept the caller ID being used during the transfer. No worries—let’s walk through some steps to get this sorted out together: 1. Verify Caller ID: First, please make sure the caller ID (like
sip_number
) is either a Twilio-purchased number or a verified outbound caller ID in your Twilio account. You can easily check and verify numbers in the Twilio Console. 2. Enable SIP REFER and PSTN Transfer: Next, head over to the Twilio Console, go to Elastic SIP Trunking » Manage » Trunks, and enable both Call Transfer (SIP REFER) and Enable PSTN Transfer. Don’t forget to save your changes! 3. Set Caller ID in Transfer Requests: When making your transfer request, use a verified number as the
sip_number
. If the number isn’t verified, you can leave out
sip_number
so it defaults to the trunk’s inbound number. 4. Use Trunk’s Caller ID: You might want to configure your Twilio trunk to use the trunk’s own number as the caller ID by setting Transfer Caller ID to From Transferor. 5. Validate Destination: Lastly, double-check that the
transfer_to
URI is properly formatted (for example,
tel:+15105550100
) and that it’s reachable. Following these steps should help clear up the issue. If you run into any hiccups or have more questions, please don’t hesitate to reach out—I’m here to help! Sources: SIP troubleshooting guide | LiveKit Docs | Preserving Caller ID During SIP Transfers in LiveKit Agents | Transferring calls | LiveKit Docs | Agents telephony integration | LiveKit Docs | livekit-protocol/livekit/protocol/sip.py
r
So i want to initiate the transfer such that the number that i called should go as from phone number in tranfer call
t
To make sure the number you called shows up as the "From" phone number during the transfer call, here’s a simple guide to help you through the process: 1. Verify the Caller ID: First, please check that the number you called is either verified in your Twilio account or is a Twilio-purchased number. You can easily verify numbers in the Twilio Console. 2. Set Caller ID in Transfer Request: When you’re ready to initiate the transfer, make sure to set the
sip_number
parameter in your transfer request to the number you originally called. Here’s an example for clarity:
Copy code
await job_ctx.api.sip.transfer_sip_participant(
    api.TransferSIPParticipantRequest(
        room_name=job_ctx.room.name,
        participant_identity=participant_identity,
        transfer_to="tel:+15105550123",
        play_dialtone=True,
        sip_number="tel:+15105550100"  # The number you called
    )
)
1. Configure Twilio Trunk: Next, in your Twilio Console, please set the Transfer Caller ID option to From Transferee within your SIP trunk settings. This step ensures the original caller’s number is used as the "From" number during the transfer. If any part of this feels unclear or you’d like a hand with these steps, don’t hesitate to reach out—I’m here to help!
r
The number that i am calling is a cutomer number that cannot be verified
t
I completely understand that verifying customer numbers can sometimes be a bit tricky. A helpful way to work around this is by configuring the transfer to use the Twilio trunk’s number as the "From" phone number instead. This means you won’t need to verify the customer’s number, making things smoother for you! Here’s a simple step-by-step guide to get this set up: 1. Set Caller ID in Twilio Trunk: Head over to the Twilio Console, then navigate to Elastic SIP Trunking » Manage » Trunks. There, set the Transfer Caller ID option to From Transferor. This way, the Twilio trunk’s number will be used as the "From" number during the transfer. 2. Omit the
sip_number
Parameter:
When you initiate the transfer, simply leave out the
sip_number
parameter in your request. This will automatically default the caller ID to the Twilio trunk’s number. Here’s an example to illustrate:
Copy code
await job_ctx.api.sip.transfer_sip_participant(
    api.TransferSIPParticipantRequest(
        room_name=job_ctx.room.name,
        participant_identity=participant_identity,
        transfer_to="tel:+15105550123",
        play_dialtone=True
    )
)
This method helps keep everything compliant with Twilio’s policies while ensuring your calls go through just as you need. If you have any questions or need a hand with this, please don’t hesitate to reach out—I’m here to help!