dry-branch-55698
08/22/2025, 4:33 AMtall-airline-16756
08/22/2025, 4:33 AMtall-airline-16756
08/22/2025, 4:33 AMsession.conversation.item.create() method to pop messages right into the conversation. Here’s a quick example:
session.conversation.item.create(
llm.ChatMessage.create({
role: llm.ChatRole.USER,
text: 'Say "How can I help you today?"',
}),
);
• For VoicePipelineAgent: You’ll want to use the addExtraChatMessage() method inside AgentCallContext to add a message to the LLM stream. Check this out:
const context = new AgentCallContext(agent, llmStream);
context.addExtraChatMessage(
llm.ChatMessage.create({
role: llm.ChatRole.USER,
text: 'This is a mid-call injected message.',
})
);
Also, if you want to have real-time control from a client, you can use Remote Procedure Calls (RPC). This lets you call a method in the agent to inject messages on the fly. If you'd like, I’m happy to share more details or examples—just let me know!
Sources: agents/src/multimodal/multimodal_agent.ts | AgentCallContext | LiveKit Agents | ChatMessage | LiveKit Agents | README.mddry-branch-55698
08/22/2025, 4:38 AMtall-airline-16756
08/22/2025, 4:38 AMfrom livekit import api
lk_api = api.LiveKitAPI(
url="your-livekit-url",
api_key="your-key",
api_secret="your-secret"
)
# Send a text message to everyone in the room
await lk_api.room.send_data(
room="your-room-name",
data="Hello Agent!",
topic="lk.chat", # Optional: pick a topic the agent listens to
reliable=True # Or False if you want faster, but less guaranteed delivery
)
await lk_api.aclose()
When you send messages through the API, you can specify a topic like "lk.chat" that the agent is tuned into. Plus, you get to choose between reliable delivery (messages arrive in order) or lossy delivery (faster but no guarantees).
If you want me to walk you through it or have any questions, just let me know—I’m here to help!
Sources: Data messages | LiveKit Docs | VoiceAgent/Chat/Send/LocalMessageSender.swift | AgentCallContext | LiveKit Agents