This message was deleted.
# ask-ai
s
This message was deleted.
t
Thanks for reaching out, Ju. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error "cannot access local participant before connecting" occurs when you attempt to access the
local_participant
property of a Room before successfully connecting to LiveKit. To resolve this, ensure the following steps: 1. Call
room.connect()
before accessing
room.local_participant
. 2. Await the connection before proceeding. 3. Only access the local participant after the connection is successfully established. Here is an example of how to do this correctly:
Copy code
async def entrypoint(ctx: JobContext):
    # Connect to the room first
    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)

    # Now you can safely access the local participant
    local_participant = ctx.room.local_participant
    await local_participant.publish_data("hello world")

    # You can also iterate through remote participants
    for rp in ctx.room.remote_participants.values():
        print(rp.identity)
Ensure that you call and await
room.connect()
before interacting with the room's participants. Let me know if you need further assistance! Sources: livekit-rtc/livekit/rtc/room.py
Hey there! To get you connected to the LiveKit playground and start using the realtime agent, just follow these simple steps: 1. Access the Hosted Playground: Head over to the hosted playground here: https://agents-playground.livekit.io. 2. Set Up Your Environment Variables: In your project, create a
.env.local
file with this content:`LIVEKIT_API_KEY=YOUR_API_KEY LIVEKIT_API_SECRET=YOUR_API_SECRET NEXT_PUBLIC_LIVEKIT_URL=wss://YOUR_LIVEKIT_URL`Just swap out the placeholders with your actual LiveKit API key, secret, and server URL. 3. Run Your Agent: Start your agent in development mode like this:This will connect your agent right to the LiveKit server. ◦ If you’re using Python, run:`python agent.py dev` ◦ If you’re on Node.js, run:`node my_agent.js dev` 1. Open the Playground: Launch the playground in your browser, and if it asks, just enter your LiveKit server URL and access token. 2. Join a Room: Use the playground interface to hop into a LiveKit room. Your agent will join automatically and be ready to chat! If you hit any bumps or want a hand with anything, just let me know—I’m here to help! Sources: Agents Playground | LiveKit Docs | Voice AI quickstart | LiveKit Docs | README.md | web/.env.sample
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!