Skip to main content

WarmTransferTask

Execute an agent-assisted warm transfer with SIP dialing, hold music, and context handoff.

Available in
Beta
|
Python

Overview

Use WarmTransferTask to execute an agent-assisted warm transfer. The task automatically manages the complexities of the transfer workflow, including dialing the supervisor, providing context, and merging the calls.

WarmTransferTask handles the following:

  • Creating a separate room for the human agent.
  • Dialing the supervisor/human agent using SIP.
  • Playing hold music to the caller while connecting.
  • Providing the human agent with conversation history and context.
  • Disabling I/O for the caller during the transfer process.
  • Providing tools for the human agent to:
    • connect_to_caller: Connect the human agent to the original caller.
    • decline_transfer: Decline the transfer with a reason.
    • voicemail_detected: Handle voicemail detection.

The task returns a WarmTransferResult data class with one field: human_agent_identity.

Agent-assisted warm transfer

A comprehensive guide to transferring calls using an AI agent to provide context.

Usage

For a basic example, see the following code snippet:

from livekit.agents.beta.workflows import WarmTransferTask
result = await WarmTransferTask(
target_phone_number=<supervisor-phone-number>, # Supervisor's phone number
sip_trunk_id=<outbound-trunk-id>, # Outbound trunk ID
chat_ctx=self.chat_ctx, # Conversation history
)

You can set the outbound trunk ID as an environment variable LIVEKIT_SIP_OUTBOUND_TRUNK:

export LIVEKIT_SIP_OUTBOUND_TRUNK=<outbound-trunk-id>

Parameters

For a full list of parameters, see the WarmTransferTask reference.

You can customize the behavior of WarmTransferTask by passing additional parameters:

target_phone_numberstringRequired

The phone number to dial for the warm transfer.

hold_audioAudioSource | AudioConfig | list | NoneOptionalDefault: BuiltinAudioClip.HOLD_MUSIC

Audio to play while the caller is on hold. By default, plays BuiltinAudioClip.HOLD_MUSIC.

extra_instructionsstringOptional

Additional instructions for the transfer agent. These instructions are passed to the transfer (or supervisor) agent along with the conversation history and the default instructions.

toolslistOptional

Additional tools that can be used in the execution of the transfer task. These tools can be used in place of, or in addition to, the default tools.