When transferring between Workflows in LiveKit Age...
# ask-ai
f
When transferring between Workflows in LiveKit Agents in Python, how do I make the transfer "silent" i.e. how do I ensure that while transferring, the bot should NOT say "I'm transferring you to a different workflow"
t
Thanks for reaching out, Amitrajit. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you make a transfer silent between workflows in LiveKit Agents using Python, you can simply disable the bot's audio output during the transfer process. Here’s a friendly step-by-step guide to do just that: 1. First, disable the bot's audio output so no messages are played during the transfer:
Copy code
# Disable audio output during transfer
bot_session.output.set_audio_enabled(False)
1. Next, perform the transfer to the desired workflow. 2. Finally, re-enable the bot's audio output once the transfer is complete:
Copy code
# Re-enable audio output after transfer
bot_session.output.set_audio_enabled(True)
This way, your bot stays silent during the transfer, creating a smoother experience. If you have any questions or want me to walk you through it further, just let me know—I’m here to help! Sources: Agent-assisted warm transfer | LiveKit docs | examples/warm-transfer/warm_transfer.py | Call forwarding | LiveKit docs | Agents telephony integration | LiveKit docs
f
Disabling the audio output might make sure that the customer doesn't hear about the transfer being called out, but if the bot is still calling out the transfer then that would become a part of the chat history and would muddy the context. How can I avoid that?
t
To help keep your chat history free of transfer messages, a good approach is to avoid using the
session.say()
method for transfer announcements. Instead, you can carry out the transfer directly without creating any verbal or textual messages. If you'd like to have even more control over the chat history, you might find the
conversation_item_added
event useful. It lets you watch for new messages and filter out certain ones—like transfer announcements—so they don’t get stored or shown. I'm here to help if you'd like some step-by-step guidance on how to set this up! Sources: complex-agents/personal_shopper/personal_shopper.py | examples/voice_agents/restaurant_agent.py | Agent-assisted warm transfer | LiveKit docs | Session recording and transcripts | LiveKit docs
f
You just gave me two methods to do silent transfers between workflows: 1. Disable bot's audio output using bot_session.output.set_audio_enabled(False) 2. Avoid using session.say() and carry the transfer out without any verbal or textual messages Which one should I use? I've tried versions of the second one and they have not been reliably useful
t
Thank you for sharing your scenario! I’d recommend going with the first method—disabling the bot's audio output using
bot_session.output.set_audio_enabled(False)
. It’s a more reliable and straightforward way to make sure no audible messages play during the transfer, while still letting everything proceed smoothly. The second method, where you avoid using
session.say()
, might be a bit trickier since it relies on making sure no other messages pop up unexpectedly in the workflow. Turning off the audio output directly gives you a bit more control and predictability. If you’d like, I’m here to help you set this up or answer any other questions you might have—just let me know!
f
Can you give me a small code example of two workflows, the code to transfer between them, ensuring that the bot stays silent during transferring
t
I'd love to share a small example that gently walks you through two workflows and how to smoothly transfer between them while keeping the bot silent during the transfer:
Copy code
# Workflow 1: Initial Workflow
async def workflow_one(bot_session):
    # Disable bot's audio output to ensure silence during transfer
    bot_session.output.set_audio_enabled(False)

    # Perform the transfer to Workflow 2
    await transfer_to_workflow_two(bot_session)

    # Re-enable bot's audio output after the transfer is complete
    bot_session.output.set_audio_enabled(True)

# Function to handle the transfer
async def transfer_to_workflow_two(bot_session):
    # Logic to transfer to Workflow 2
    await bot_session.transfer_to_workflow("workflow_two")

# Workflow 2: Target Workflow
async def workflow_two(bot_session):
    # Logic for the second workflow
    await bot_session.say("You have been transferred to Workflow 2.")
Here’s what’s happening in this example: • We start by disabling the bot’s audio output with
bot_session.output.set_audio_enabled(False)
to make sure it stays silent during the transfer. • The transfer itself is done using
bot_session.transfer_to_workflow()
, which moves the session over to the second workflow. • Once the transfer is all set, we turn the bot’s audio back on with
bot_session.output.set_audio_enabled(True)
. This way, the bot stays quiet throughout the transfer, creating a smooth experience. If you’d like me to clarify anything or provide more examples, just let me know—I’m here to help!