You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to handle call transfers using LiveKit in a voice assistant. The assistant listens for user responses (yes or no) and initiates a transfer to the billing department when the response is affirmative. Despite following the documentation and implementing the SIP transfer process, the call transfer does not happen.
Previously, I was able to handle call transfers successfully using DTMF handling, where the assistant listens for keypad inputs (e.g., pressing a specific number) and responds accordingly. However, the same process does not seem to work with voice-triggered responses.
Expected Behavior
The call should be transferred to the billing department's phone number provided in the .env.local file as BILLING_PHONE_NUMBER.
Observed Behavior
The assistant verbally confirms the transfer, but the actual SIP transfer does not take place. The call remains in the current room, and no error logs indicate why the transfer failed.
Code Snippets
1. Handling Call Transfer
Below is the code snippet for initiating the SIP call transfer:
asyncdefhandle_transfer(room_name: str, participant_identity: str, assistant: VoiceAssistant) ->None:
try:
transfer_number=os.getenv('BILLING_PHONE_NUMBER')
ifnottransfer_number:
raiseValueError("Billing phone number not configured")
ifnottransfer_number.startswith('+'):
transfer_number=f"+{transfer_number}"awaitassistant.say("Transferring you to our billing department. Please hold.", allow_interruptions=False)
livekit_api=api.LiveKitAPI(
url=os.getenv('LIVEKIT_URL'),
api_key=os.getenv('LIVEKIT_API_KEY'),
api_secret=os.getenv('LIVEKIT_API_SECRET')
)
transfer_uri=f"tel:{transfer_number}"transfer_request=proto_sip.TransferSIPParticipantRequest(
room_name=room_name,
participant_identity=participant_identity,
transfer_to=transfer_uri,
play_dialtone=False
)
logger.info(f"Initiating transfer for participant {participant_identity} to {transfer_uri}")
awaitlivekit_api.sip.transfer_sip_participant(transfer_request)
awaitasyncio.sleep(2)
awaitassistant.cleanup()
logger.info("Transfer completed, exiting process")
os._exit(0)
exceptExceptionase:
logger.error(f"Transfer failed: {e}", exc_info=True)
awaitassistant.say("I apologize, but I couldn't transfer your call. Please try again later.", allow_interruptions=True)
2. Handling yes/no Responses
Below is the implementation for handling user responses and deciding whether to transfer the call:
@assistant.on_messageasyncdefhandle_message(message: str):
message=message.lower().strip()
ifmessagein ["yes", "yeah", "sure", "okay", "correct", "yep"]:
participants=list(ctx.room.participants.values())
ifnotparticipants:
logger.error("No participants found in room")
awaitassistant.say("I'm sorry, but I cannot process the transfer at this moment.", allow_interruptions=True)
returnparticipant=participants[0]
logger.info(f"Attempting transfer for participant: {participant.identity}")
awaithandle_transfer(ctx.room.name, participant.identity, assistant)
elifmessagein ["no", "nope", "not now", "nah"]:
awaitassistant.say("Alright, is there something else I can help you with?", allow_interruptions=True)
else:
awaitassistant.say("Would you like me to transfer you to our billing department? Please say 'yes' or 'no'.", allow_interruptions=True)
What I Tried
Attempted debugging the transfer_sip_participant call, but found no relevant error logs.
Questions
Is the SIP transfer feature supported for this use case in LiveKit?
Are there additional configurations or permissions required for SIP transfers to work?
Could there be a potential issue with the LiveKit SDK or API?
Why does the transfer work as expected when using DTMF handling (listening for keypad inputs) but fails when using yes/no voice responses? Are there additional steps or considerations required for voice-based triggers?
Environment
LiveKit SDK Version: (Please specify)
Python Version: (e.g., 3.10)
OS: (e.g., Ubuntu 22.04)
Any insights or guidance would be greatly appreciated! Let me know if you need additional logs or context.
The text was updated successfully, but these errors were encountered:
Hello,
I am attempting to handle call transfers using LiveKit in a voice assistant. The assistant listens for user responses (
yes
orno
) and initiates a transfer to the billing department when the response is affirmative. Despite following the documentation and implementing the SIP transfer process, the call transfer does not happen.Previously, I was able to handle call transfers successfully using DTMF handling, where the assistant listens for keypad inputs (e.g., pressing a specific number) and responds accordingly. However, the same process does not seem to work with voice-triggered responses.
Expected Behavior
The call should be transferred to the billing department's phone number provided in the
.env.local
file asBILLING_PHONE_NUMBER
.Observed Behavior
The assistant verbally confirms the transfer, but the actual SIP transfer does not take place. The call remains in the current room, and no error logs indicate why the transfer failed.
Code Snippets
1. Handling Call Transfer
Below is the code snippet for initiating the SIP call transfer:
2. Handling
yes/no
ResponsesBelow is the implementation for handling user responses and deciding whether to transfer the call:
What I Tried
transfer_sip_participant
call, but found no relevant error logs.Questions
yes/no
voice responses? Are there additional steps or considerations required for voice-based triggers?Environment
Any insights or guidance would be greatly appreciated! Let me know if you need additional logs or context.
The text was updated successfully, but these errors were encountered: