alert-continent-21953
09/23/2025, 11:19 AMtall-airline-16756
09/23/2025, 11:19 AMtall-airline-16756
09/23/2025, 11:19 AMalert-continent-21953
09/23/2025, 11:28 AMtall-airline-16756
09/23/2025, 11:29 AMalert-continent-21953
09/23/2025, 11:32 AMtall-airline-16756
09/23/2025, 11:33 AMlk.chat topic. This way, your agent can engage in real-time chat by processing incoming messages and responding thoughtfully.
• Configure Text-Only Sessions: If you'd like the agent to focus solely on text interactions, you can disable audio input and output. Here's an example configuration to guide you:
room_input_options=RoomInputOptions(text_enabled=True, audio_enabled=False),
room_output_options=RoomOutputOptions(transcription_enabled=True, audio_enabled=False),
• Manual Text Input: Another handy option is to send text input directly to the agent using generate_reply(user_input="user's message"). This is great if you want to connect your agent with external chat systems or user interfaces.
• Frontend Integration: To make things easier, LiveKit offers pre-built React components like the useChat hook and Chat component. These help you smoothly integrate chat features into your app.
If you'd like to dive deeper, feel free to check out the Text and Transcriptions Guide. And of course, if you have any questions or need a hand with anything else, just let me know—I’m here to help!
Sources: Text and transcriptions | LiveKit Docs | livekit-agents/livekit/agents/voice/room_io/room_io.py | Sending text | LiveKit Docs | server/agent.pyalert-continent-21953
09/23/2025, 1:50 PMtall-airline-16756
09/23/2025, 1:51 PMsendText method to send text input to your agent via the lk.chat topic. It’s straightforward and effective:
JavaScript Example:
const text = 'Hello, how are you today?';
const info = await room.localParticipant.sendText(text, {
topic: 'lk.chat',
});
console.log(`Sent text with stream ID: ${info.id}`);
Python Example:
text = 'Hello, how are you today?';
info = await room.local_participant.send_text(text, topic='lk.chat');
print(f"Sent text with stream ID: {info.stream_id}");
• Receiving Text Output: To get the agent’s text output, you’ll want to register a handler for the lk.transcription topic. This will let you capture and work with the messages as they come in:
JavaScript Example:
room.registerTextStreamHandler('lk.transcription', async (reader, participantInfo) => {
const message = await reader.readAll();
console.log(`New message from ${participantInfo.identity}: ${message}`);
});
Python Example:
room.register_text_stream_handler('lk.transcription', async (reader, participant_info) => {
message = await reader.read_all()
print(f"New message from {participant_info.identity}: {message}")
})
• Agent Configuration: It’s important to make sure your agent is set up to accept text input. If you’re focusing on text-only sessions, you can also disable audio to keep things clean and simple:
from livekit.agents import AgentSession, RoomInputOptions, RoomOutputOptions
session = AgentSession()
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(text_enabled=True, audio_enabled=False),
room_output_options=RoomOutputOptions(transcription_enabled=True, audio_enabled=False),
)
If you have any questions or need more examples, please don’t hesitate to ask—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/room_io/room_io.py | Agents v0.x migration guide - Node.js | LiveKit Docs | Text and transcriptions | LiveKit Docs | Docs::Agents | Sending text | LiveKit Docs