a
hello
t
Thanks for reaching out, Aditya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you out! Could you please share a bit more about your question or the issue you're experiencing? That way, I can make sure to assist you in the best possible way.
a
so i deployed agent to livekit cloud using lk agent create and lk agen deploy.. now its running in the cloud.. i want to access that agentt for chat feature then how to do it ?
t
Thanks for reaching out! Just to make sure I understand you correctly, are you interested in setting up text-based chat interactions—like the agent sending and receiving messages in a chat room? Or were you thinking more along the lines of voice-based conversational agents? If it’s the text chat you’re after, could you share a bit more about your specific use case? For example, are you looking to embed the agent in a web interface, or perhaps use the LiveKit data channel for messaging? I’m here to help you every step of the way! Sources: Deploy and scale agents on LiveKit Cloud | Voice AI quickstart | LiveKit Docs | delay-handling/agent.py | examples/avatar_agents/anam/agent_worker.py | Deploying to production | LiveKit Docs
a
i am able to do outbound and incoming calls.. i also want that deployed agent to work as a chatbot .. like i can chat with agent rather than voice
t
I'm glad you're interested in setting up your deployed agent in LiveKit Cloud to work as a chatbot for text-based interactions! Let me walk you through how you can make this happen: • Enable Text Input: You can use the TextStream feature to let your agent receive text input from participants via the
lk.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:
Copy code
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.py
a
give me code where i can give input to agent as text and it should give me output.. also i want to access the deployed agent on livekit cloud
t
I’m happy to guide you through sending text input to your deployed agent in LiveKit Cloud and receiving text output. Here’s a simple way to do it: • Sending Text Input: You can use the
sendText
method to send text input to your agent via the
lk.chat
topic. It’s straightforward and effective: JavaScript Example:
Copy code
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:
Copy code
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:
Copy code
room.registerTextStreamHandler('lk.transcription', async (reader, participantInfo) => {
  const message = await reader.readAll();
  console.log(`New message from ${participantInfo.identity}: ${message}`);
});
Python Example:
Copy code
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:
Copy code
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