Hi there, good to join to the community. I am a new to this world but willing to progress. So far I suceded to integrate my Lab using Asterisk+ Sip Bridge + redis + LiveKit for learning purposes. Then I borrow code from livekit-voice-agent to test inbound flow ..so far all OK. However now I am trying to implement a more realistic flow: Customer calling to request to know balance and being able to be transferred to fake Technical Support. The inbound is OK but function tool to retrieve customer profile and transfering not OK. During troubleshoot I came across participant_identification not available after room setup , then I figure it out that perhaps I needed to wait for Event. I reviewed documentation and added code for events but seems to be NOT triggered.
Any idea where to look for Events triggers within Agent Code ??
This is Code fragment
async def entrypoint(ctx: agents.JobContext):
await ctx.connect()
agent = Assistant()
session = AgentSession(llm=openai.realtime.RealtimeModel(voice="coral"))
await session.start(
room=ctx.room,
agent=agent,
room_input_options=RoomInputOptions()
)
# Handler SIN async, dispara la lógica asíncrona:
def on_participant_connected(p):
participant_identity = getattr(p, "participant", None)
logger.debug(f"ON_PARTICIPANT_JOINED: participant_identity= {participant_identity}")
print(f"ON_PARTICIPANT_JOINED: participant_identity= {participant_identity}")
asyncio.create_task(handle_real_join(participant_identity, p))
ctx.room.on("participant_connected", on_participant_connected)
logger.debug(f"AFTER participant_connected| CTX.room attributes: {dir(ctx.room)}") # This I can see in Logs but there is no participant_identity shown, Also the previous Loggers not there
async def handle_real_join(participant_identity, participant_obj):
# 1. Perfil y update
profile = get_customer_profile(participant_identity)
logger.debug(f"HANDLE_REAL_JOIN: participant_identity= {participant_identity} | profile= {profile}")
print(f"HANDLE_REAL_JOIN: participant_identity= {participant_identity} | profile= {profile}")
agent.update_profile(profile)
# 2. Saludo
bienvenida = (
f"¡Hola, {profile.get('apellido')}! "
f"Su saldo actual es de {profile.get('saldo')}. "
f"Tipo de cliente: {get_priority_label(profile.get('priority'))}. "
"¿En qué puedo ayudarle hoy?"
)
#await session.generate_reply(instructions=bienvenida)
# 3. SOLO aquí o en la conversión, tras pedir transferencia, ejecuta la tool:
# Si quieres prueba, manda la transferencia aquí:
#profile = get_customer_profile('participant_identity')
participant = next(iter(ctx.room.remote_participants.values()))
identity = participant.identity if participant else "unknown"
msg = await agent.transfer_call(identity, ctx.room.name)
# await session.generate_reply(instructions=msg)
# Ejemplo de uso: si se ejecuta la transferencia, publica el mensaje usando el resultado devuelto
#msg = await agent.transfer_call(ctx.room)
await session.generate_reply(instructions=msg)