can i send using the LiveKit api a message or rpc ...
# ask-ai
a
can i send using the LiveKit api a message or rpc call to an agent in a room without being connected to the room?
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! I understand it can be a bit tricky, but to send a message or RPC call to an agent in a LiveKit room, you’ll need to be connected to that room first. Both you and the person you want to communicate with need to be participants in the same room for the messages to go through. If you have any questions about connecting or anything else, I’m here to help! Sources: complex-agents/shopify-voice-shopper/shopify.py | Dispatching agents | LiveKit Docs | Agents Overview | LiveKit Docs | Docs::Home | packages/livekit-rtc/README.md
a
i want to trigger from a server an action of an agent in a room
t
I'd be happy to help you trigger an action of an agent in a LiveKit room from your server! Here are a few approaches you can try: • Dispatch the agent with metadata: When you dispatch the agent to the room, include the intended action in the metadata. The agent can then read this metadata and respond accordingly as soon as it joins. • Use room metadata updates: You can update the room metadata from your server, and the agent can keep an eye out for these changes to trigger specific actions. • External event polling: Another option is to set up an external API or event system (like WebSocket or Redis) that your agent can poll or listen to for commands. Just a quick note: LiveKit doesn’t currently offer a direct server-side API to invoke arbitrary actions on an agent that’s already joined. So, actions need to be set up in advance or triggered through the agent’s own logic, room events, or metadata changes. If you’d like, I can share some examples to help you get started with any of these methods—just let me know! Sources: src/main/kotlin/io/livekit/server/AgentDispatchServiceClient.kt | Agent dispatch | LiveKit Docs | Dispatching agents | LiveKit Docs | Function calling with Voice Agents | LiveKit Docs | avatars/hedra/education_avatar/agent.py