in agent 0.x, how would i make sure the inbound SI...
# ask-ai
m
in agent 0.x, how would i make sure the inbound SIP participant has joined the room prior to starting or creating the agent?
t
Thanks for reaching out, Kush. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Could you provide more details about your setup or requirements? For example, are you using a specific API or SDK to manage the SIP participant and agent? Additionally, are there any particular constraints or conditions you are working with?
m
I have a dispatch rule for inbound calling. I want make sure the SIP participant has joined the call prior to the agent starting. From my understanding, the SIP participant could have joined the room before the agent job/process was even created. So how would I capture if the SIP participant has joined from the agent's perspective?
t
Hey there! Let me break down how you can track SIP participants joining a room in LiveKit agent 0.x in a super friendly way. • You'll get a notification when someone new joins the room. • The system will peek at the participant's identity to see if they're coming in via SIP. • If it's a SIP participant, it'll grab the specific task associated with them. • Then it sets up everything needed to welcome and interact with that participant. Here's the code that makes the magic happen:
Copy code
@ctx.room.on("participant_connected")
def on_participant_connected(participant: rtc.RemoteParticipant):
    <http://logger.info|logger.info>(f"new participant joined {participant.identity}")
    if not "sip_" in participant.identity:
        return

    # Get the task from attributes
    task = participant._info.attributes.get("task")
    <http://logger.info|logger.info>(f"task: {task}")

    # Initialize user data
    userdata = UserData(task=task)

    # Create and start the agent session
    session = AgentSession(
        userdata=userdata,
        stt=deepgram.STT(),
        llm=openai.LLM(base_url="<https://api.deepseek.com/v1>",
                      model="deepseek-chat",
                      api_key=os.getenv("DEEPSEEK_API_KEY")),
        tts=cartesia.TTS(),
        vad=silero.VAD.load(),
        min_endpointing_delay=0.75
    )

    # Start the navigator agent
    asyncio.create_task(
        session.start(
            room=ctx.room,
            agent=NavigatorAgent()
        )
    )
This approach helps you smoothly welcome and handle SIP participants in your room. Pretty cool, right? 😊 Sources: Building an Automated IVR Menu Caller | LiveKit Docs
m
what if the SIP participants has already joined the room prior to the creation of the agent? then would this still capture it?
t
Hey there! I totally understand you might need some clarity about querying room participants. I'm here to help! Could you tell me a bit more about the specific SDK or API you're using to manage your room? The more details you can share, the better I can tailor a solution that works perfectly for your situation. I'm all ears and ready to dig into this with you! 😊
m
In simple terms, I want to check to see if a SIP participant exist in my room in the agent 0.x. How would I do that?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!