How can we achieve a classic call forward flow in ...
# ask-ai
l
How can we achieve a classic call forward flow in LiveKit? Expected behavior: • If the forwarded call is not answered within ringing_timeout, the transfer ends and control returns to the agent. • If the forwarded phone is busy, the transfer should fail immediately and control should return to the agent. • If the forwarded party answers, the agent session ends and the caller continues directly with the answered participant. • If either the caller or the forwarded participant hangs up, the whole call ends. Can you provide an example or guidance on how to implement this flow with LiveKit?
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.
Let's walk through how you can implement a call forward flow in LiveKit with the conditions you mentioned. Here’s a step-by-step guide to help you along the way: 1. Initiate Outbound Call: Start by using
create_sip_participant
to place the call. This method begins dialing right away without waiting for an answer, giving you a smooth start. 2. Monitor Call Status: Keep an eye on the
sip.callStatus
participant attribute. This lets you track important states like dialing, ringing, active (when the call is answered), hangup, or unavailable (if the line is busy). 3. Set Ringing Timeout: You can set the
ringing_timeout
parameter to control how long the call rings. By default, it’s 3 minutes, but you can adjust it up to a maximum of 80 seconds to fit your needs. 4. Forward/Transfer Call: When it’s time to forward, use the
transferCall
method. You also have the option to play a dial tone during the transfer, which can enhance the caller’s experience. 5. Handle Answered Call: Once
sip.callStatus
switches to active, it means the forwarded party has picked up. At this point, you can end the agent session so the caller can continue seamlessly with the forwarded participant. 6. Handle Hang-Up: Finally, when either the caller or the forwarded participant hangs up, use the
delete_room
API to end the call for everyone involved. This method helps you manage ringing timeouts, busy signals, answered calls, and hang-ups smoothly and effectively. If you have any questions or need further clarification, feel free to ask—I’m here to help! Sources: Agents telephony integration | LiveKit Docs | SIP Integration | livekit/livekit_composite | DeepWiki | Making calls using SIP | LiveKit Docs | Making outbound calls | LiveKit Docs | pkg/sip/outbound.go
l
Keeping ringing_timeout=20s doesn't disconnect the transfer-target ringing
t
Could you please check if the
ringing_timeout
parameter is being set as a proper
Duration
object in your
TransferSIPParticipant
API call? Also, if possible, would you mind taking a look at the SIP signaling logs to see if LiveKit sends a disconnect (like a BYE or CANCEL) after the timeout? I'm here to help you through this! Sources: packages/livekit-server-sdk/src/SipClient.ts | lib/livekit/sip_service_client.rb | livekit/livekit_sip.pb.go | livekit-protocol/livekit/protocol/sip.pyi | SIP APIs | LiveKit Docs