Hello, How can we implement the warm call transfer...
# ask-ai
r
Hello, How can we implement the warm call transfer with some message or contextual summary ? I see there is a cold transfer doc: https://docs.livekit.io/sip/transfer-cold/ I want to implement the following types of call transfers: 1. Cold transfer 2. Warm transfer with message 3. Warm transfer with summary
t
Thanks for reaching out, pritesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Here’s a friendly guide to setting up warm call transfers with a message or some helpful context in LiveKit: 1. First, put the customer on hold by turning off their audio input/output and playing some hold music to keep things smooth. 2. Next, create a new room for the supervisor and connect them using SIP with
create_sip_participant
. 3. Give the supervisor a quick summary or context of the conversation by sharing the conversation history in a clear, easy-to-understand way. 4. Once the supervisor is ready to take the call, use the
MoveParticipant
API to bring them into the customer’s room. 5. Finally, stop the hold music, turn the customer’s audio back on, and let them know they’re connected with the supervisor. This way, the supervisor gets all the info they need before joining, making the whole warm transfer feel smooth and thoughtful. If you want me to walk you through any part or have questions, just let me know—I’m here to help! Sources: examples/warm-transfer/hold_music.mp3
r
Copy code
sync def transfer_call(participant_identity: str, room_name: str) -> None:
  async with api.LiveKitAPI() as livekit_api:
    transfer_to = 'tel:+14155550100'
    
    # Create transfer request
    transfer_request = TransferSIPParticipantRequest(
        participant_identity=participant_identity,
        room_name=room_name,
        transfer_to=transfer_to,
        play_dialtone=False
    )
    logger.debug(f"Transfer request: {transfer_request}")

    # Transfer caller
    await livekit_api.sip.transfer_sip_participant(transfer_request)
    logger.info(f"Successfully transferred participant {participant_identity} to {transfer_to}"
We are doing this at the moment for cold transfer How can I then pass mesage or context to the transfer_to ?
t
If you want to pass a message or some context to the
transfer_to
participant during a SIP transfer, you can do this easily using the
headers
field in the
TransferSIPParticipantRequest
. This lets you add custom SIP headers that get sent along to the destination endpoint in the SIP REFER request. Here’s a quick example to show you how it works:
Copy code
transfer_request = TransferSIPParticipantRequest(
    participant_identity=participant_identity,
    room_name=room_name,
    transfer_to=transfer_to,
    play_dialtone=False,
    headers={
        "X-Context-Message": "Caller transferred from Billing queue",
        "X-Department": "Support"
    }
)
So, these headers like
X-Context-Message
and
X-Department
will be sent to the receiving SIP endpoint, which can then understand and use the context you’ve provided. If you have any questions or want me to walk you through it, just let me know—I’m here to help! Sources: livekit/livekit_sip.pb.go | livekit-protocol/livekit/protocol/sip.pyi | Transferring calls | LiveKit Docs
r
How the context message or contexual summry will be added to the human or agent?
t
Here’s a friendly guide on how to add a context message or summary for the human agent during a SIP transfer: 1. Capture the Conversation History: Grab the
ChatContext
from the current session to gather all the messages exchanged between the customer and the agent. 2. Create a Separate Room for the Supervisor: Set up a new room specifically for the SIP call to the supervisor or human agent. 3. Pass the Contextual Summary: Turn the conversation history into a clear, easy-to-read summary and share it with the supervisor. For example:
Copy code
context_copy = prev_ctx.copy(exclude_empty_message=True, exclude_instructions=True, exclude_function_call=True)
prev_convo = ""
for msg in context_copy.items:
    if msg.role == "user":
        prev_convo += f"Customer: {msg.text_content}\n"
    else:
        prev_convo += f"Assistant: {msg.text_content}\n"
4. Initiate the SIP Call: Use
create_sip_participant
to dial the supervisor and pass along the summary either verbally or through SIP headers. 5. Merge the Supervisor into the Customer's Room: When the supervisor is ready, bring them into the customer’s room with
move_participant
and let the customer know they’re connected. This way, the human agent has all the important context before chatting with the customer, making the whole experience smoother and more helpful. Feel free to ask if you want me to walk you through any part of this! Sources: examples/warm-transfer/README.md | ChatContext | LiveKit Agents
r
Will they understand the headers automatically? I think no.
t
You're absolutely right—sometimes the receiving system or human agent might not automatically pick up on the headers unless it's set up to do so. If that’s the case, here are a few ways to make sure the context gets through: 1. Providing a Verbal Summary: You can have a dedicated agent or system give the human agent a quick verbal rundown of the call’s context when they answer. 2. Using a Supervisor Room: Set up a separate room for the supervisor or human agent, and share the context during the session setup before bringing them into the customer’s room. 3. Custom Integration: If the system on the receiving end can handle custom SIP header processing, just make sure it’s configured to read and show the headers correctly. Feel free to reach out if you want a hand with any of these options—I’m here to help!