i having issue to ransfer the call class HolionixA...
# ask-ai
p
i having issue to ransfer the call class HolionixAgent(Agent): def __init__(self,room,llm,tts,stt,vad,tools): super().__init__( instructions=instruction, llm=llm, stt=stt, tts=tts, tools=tools, vad=vad ) self.room = room async def on_enter(self) -> None: await self.session.generate_reply(instructions="Greet the user warmly and offer your assistance in English.") @function_tool() async def transfer_to_hindi(self, context: RunContext): """Transfer the customer to a Hindi specialist for questions and answer.""" return HindiAgent(chat_ctx=self.chat_ctx,llm=self.llm,tts=self.tts,stt=self.stt,tools=self.tools,vad=self.vad), "Transferring to Hindi" @function_tool() async def transfer_to_dutch(self, context: RunContext): """Transfer the customer to a dutch specialist for questions and answer.""" return DutchAgent(chat_ctx=self.chat_ctx,llm=self.llm,tts=self.tts,stt=self.stt,tools=self.tools,vad=self.vad), "Transferring to dutch" @function_tool() async def transfer_to_bengali(self, context: RunContext): """Transfer the customer to a bengali specialist for questions and answer.""" return BengaliAgent(chat_ctx=self.chat_ctx,llm=self.llm,tts=self.tts,stt=self.stt,tools=self.tools,vad=self.vad), "Transferring to bengali" @function_tool() async def transfer_to_human_agent(self, context: RunContext) -> str: """Transfer the call to the Human Agent.""" room = self.room identity = self.room.local_participant.identity dept_name = "Human Agent" await self._handle_transfer(identity, dept_name, room.name) return f"Transferring to {dept_name} department." async def _handle_transfer(self, identity: str, department: str,room) -> None: """ Handle the transfer process with department-specific messaging. Args: identity (str): The participant's identity transfer_number (str): The number to transfer to department (str): The name of the department """ await self.session.generate_reply(user_input=f"Transferring you to our {department} department in a moment. Please hold.") await asyncio.sleep(2) await self.transfer_call(identity, room) async def transfer_call(self,participant_identity: str, room_name: str) -> None: try: async with api.LiveKitAPI() as livekit_api: transfer_to = 'tel:+916295716352' # Create transfer request transfer_request = TransferSIPParticipantRequest( participant_identity=participant_identity, room_name=room_name, transfer_to=transfer_to, play_dialtone=True ) # Transfer caller await livekit_api.sip.transfer_sip_participant(transfer_request) except Exception as e: logging.error(f"Failed to transfer call: {e}", exc_info=True) await self.session.generate_reply(user_input="I'm sorry, I couldn't transfer your call. Is there something else I can help with?")
t
Thanks for reaching out, arpan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm here to help you work through the call transfer issue in your implementation. Let's go through some important steps together to debug and hopefully resolve this: 1. Verify SIP URI Format: Please double-check that the SIP URI in the
transfer_to
field is formatted correctly (for example,
tel:+916295716352
) and that it’s accessible. 2. Check SIP Trunk Configuration: It’s a good idea to confirm your SIP trunk supports call transfers and that SIP REFER is enabled. Providers like Telnyx and Twilio often require specific settings for this to work smoothly. 3. Enable Caller ID Passthrough: If preserving the caller ID during the transfer is important, make sure this is enabled and that your SIP provider supports it. 4. Monitor for Timeout Issues: If you see a timeout error (like a 408 Request Timeout), it’s worth checking the availability and permissions of the destination endpoint. 5. Enable Debug Logging: Try logging the
TransferSIPParticipantRequest
payload along with any API responses. This can give you valuable clues about where things might be going wrong. These steps should guide you toward identifying and fixing the issue. If anything feels unclear or you’d like some more help, please don’t hesitate to reach out—I’m here for you! Sources: Preserving Caller ID During SIP Transfers in LiveKit Agents | sip-refer/agent.py | agent.py | SIP troubleshooting guide | LiveKit Docs | Transferring calls | LiveKit Docs