-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Transfer SIP Calls to Another Number in voice-pipeline-agent-python? #1139
Comments
I am also being faced same problem plz solve this as soon as possible |
Like in the cold transfer docs, you could do the following
|
Hello, I am attempting to handle call transfers using LiveKit in a voice assistant. The assistant listens for user responses ( 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 BehaviorThe call should be transferred to the billing department's phone number provided in the Observed BehaviorThe 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 Snippets1. Handling Call Transfer async def handle_transfer(room_name: str, participant_identity: str, assistant: VoiceAssistant) -> None:
try:
transfer_number = os.getenv('BILLING_PHONE_NUMBER')
if not transfer_number:
raise ValueError("Billing phone number not configured")
if not transfer_number.startswith('+'):
transfer_number = f"+{transfer_number}"
await assistant.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}")
await livekit_api.sip.transfer_sip_participant(transfer_request)
await asyncio.sleep(2)
await assistant.cleanup()
logger.info("Transfer completed, exiting process")
os._exit(0)
except Exception as e:
logger.error(f"Transfer failed: {e}", exc_info=True)
await assistant.say("I apologize, but I couldn't transfer your call. Please try again later.", allow_interruptions=True) 2. Handling @assistant.on_message
async def handle_message(message: str):
message = message.lower().strip()
if message in ["yes", "yeah", "sure", "okay", "correct", "yep"]:
participants = list(ctx.room.participants.values())
if not participants:
logger.error("No participants found in room")
await assistant.say("I'm sorry, but I cannot process the transfer at this moment.", allow_interruptions=True)
return
participant = participants[0]
logger.info(f"Attempting transfer for participant: {participant.identity}")
await handle_transfer(ctx.room.name, participant.identity, assistant)
elif message in ["no", "nope", "not now", "nah"]:
await assistant.say("Alright, is there something else I can help you with?", allow_interruptions=True)
else:
await assistant.say("Would you like me to transfer you to our billing department? Please say 'yes' or 'no'.", allow_interruptions=True) What I Tried
Questions
Environment
Any insights or guidance would be greatly appreciated! Let me know if you need additional logs or context. |
Hello,
I am currently working on a simple demo using voice-pipeline-agent-python and have successfully configured the SIP settings as required.
However, I am looking to implement a feature where, after a user dials a number and enters the logic of the VoicePipelineAgent, they can trigger a signal that redirects the call to another number for manual response.
Here's what I have so far, and I'm wondering how I can proceed to achieve the call transfer functionality:
The user dials a number and is connected to the VoicePipelineAgent.
At some point during the interaction, the user triggers a specific signal.
Upon receiving this signal, I want the call to be transferred to another predefined number for human manual handling.
I have reviewed the documentation, but I'm not sure how to implement this feature within the voice-pipeline-agent-python framework. Could someone please guide me on the steps or provide an example of how to achieve this?
Thank you in advance for your help!
The text was updated successfully, but these errors were encountered: