This message was deleted.
# ask-ai
s
This message was deleted.
g
To send custom data from the client to the AI agent on the server, you can use LiveKit's data channels. According to the LiveKit documentation, you can publish arbitrary data messages to other participants in the same room using the
publishData
method. This method allows you to send data packets with a specified topic, which can be used to categorize the data being sent. Here's a basic example in JavaScript:
Copy code
const data = new TextEncoder().encode('your custom data');
room.localParticipant.publishData(data, { reliable: true, topic: 'custom-data' });
On the server side, you can listen for these data packets and handle them accordingly. For example, in Python:
Copy code
@ctx.room.on("data_received")
def on_data_received(data: rtc.DataPacket):
    if data.topic == "custom-data":
        message = data.data.decode("utf-8")
        # Process the message
Would you like more details on this process? Sources: - LiveKit Data Messages 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.