how do I remove an agent from the sip call after i...
# ask-ai
d
how do I remove an agent from the sip call after it performs a transfer
t
Thanks for reaching out, Theo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To remove an agent from a SIP call after it performs a transfer, you can follow these steps: 1. Use the
transfer_sip_participant
API to transfer the call to another number. For example:
Copy code
@function_tool()
async def transfer_call(self, ctx: RunContext):
    transfer_to = "+15105550123";
    participant_identity = "+15105550123";

    await ctx.session.generate_reply(
        instructions="Inform the user that you're transferring them to a different agent."
    );
    job_ctx = get_job_context();
    try:
        await job_ctx.api.sip.transfer_sip_participant(
            api.TransferSIPParticipantRequest(
                room_name=job_ctx.room.name,
                participant_identity=participant_identity,
                transfer_to=f"tel:{transfer_to}",
            )
        );
    except Exception as e:
        print(f"error transferring call: {e}");
1. After the transfer is complete, delete the room to end the agent's session. For example:
Copy code
# Add a callback to handle the transfer completion
def on_sip_transfer_done(f: asyncio.Future):
    if f.exception():
        logger.error(f"Error transferring SIP participant: {f.exception()}");
    else:
        <http://logger.info|logger.info>("SIP participant transferred");
    ctx.delete_room();  # This removes the agent from the call

# Perform the transfer and add the callback
ctx.transfer_sip_participant(participant, "tel:+15551234567").add_done_callback(
    on_sip_transfer_done
);
This process ensures a "cold" transfer, where the agent hands off the call to another party and then ends its session after the transfer is complete. Sources: Agents telephony integration | LiveKit Docs | Tree View: | dse-workbench
d
what about for a warm transfer
t
Unfortunately, I couldn't find specific information about performing a warm transfer for a SIP call where the agent remains on the line during the transfer process. The available details primarily cover cold transfers using the
transfer_sip_participant
API. If you need further assistance or specific implementation details for warm transfers, I recommend reaching out to your technical team or consulting the API documentation for additional guidance.