In Livekit v1.0 - how do I send text message from ...
# ask-ai
j
In Livekit v1.0 - how do I send text message from python livekit agent to all other participants without adding it to chat history?
t
Thanks for reaching out, meetakshay99. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To send a text message from a Python LiveKit agent to all participants without adding it to chat history, you can use the
publish_data
method on the local participant. Here's an example:
Copy code
# When connected to the room
await room.local_participant.publish_data(
    payload="Your message here",  # Can be a string or serialized JSON
    topic="your.custom.topic",    # Use a custom topic, not the chat topic
)
Key points: • Use
local_participant.publish_data()
to send data messages to all participants. • Specify a custom topic that's different from the chat topic (
lk.chat
). • You can leave
destinationIdentities
blank to send to all participants. • Messages can be up to 15KiB in size for reliable delivery. This approach ensures the message is sent to all participants without being added to the chat history. Sources: Job lifecycle | LiveKit Docs | Data messages | LiveKit Docs
j
how do I get room object in agent ?
t
Unfortunately, I couldn't find specific information on how to get the room object in a Python LiveKit agent. If you have additional details about your setup or context, feel free to share, and I can assist further. Alternatively, I can escalate this to a human specialist for more in-depth support. Sources: JobContext | LiveKit Agents