what's the best way to integrate livekit with mast...
# agents
c
what's the best way to integrate livekit with mastra ai? I have a voice project (livekit) and an AI orchestration layer (mastra ai), they are 2 different projects, but I feel that I can merge them into one, maybe there is a way to add my mastra agent as a participant using realtime text/data: https://docs.livekit.io/home/client/data/. Initially the way I designed this was to have two different independent projects. The voice agent would call the mastra ai agent via http/SSE for whatever tool it wants to call. However, this became unreliable, because both agents (voice + mastra) were in different context, also there is latency because they communicate via http stream.
c
I don't think it's possible, but you can use Mastra inside a LiveKit agent, not the other way around. A LiveKit session is different; it requires a two-way connection via a WebSocket channel to the LiveKit server and providers.
c
how to use mastra inside livekit though? Not sure this is possible.
c
You can start Mastra workflow (deep research or whatever you wanna run) as a result of a tool call from LiveKit session
c
got it. I was a planning to keep mastra and livekit as independent projects and let mastra join the room for this two-way data communication with ws.
c
Oh, that sounds interesting! I hope it works!
c
Do you think that's feasible following livekit best practices? Like leveraging realtime text & data or data packets.
c
We don't have examples that cover this, but I think you can easily connect to any room using the LiveKit SDK (not the Agents SDK). An LiveKit agent can send some JSONs, and the Mastra agent can listen and respond to them via Data Channels.
c
do you have examples, link for the docs, etc?
c
c
ok thanks!