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?")