salmon-belgium-62133
12/24/2025, 7:39 AMtall-airline-16756
12/24/2025, 7:39 AMtall-airline-16756
12/24/2025, 7:39 AMsession.generate_reply to send the greeting. For example:
async def on_enter(self):
await self.session.generate_reply(
instructions="Greet the user with a warm welcome",
)
This works for both the STT‑LLM‑TTS pipeline and Realtime model agents. Do you want the greeting to be spoken (TTS), shown as text, or both? If spoken, tell me which voice/language you want and I can show the exact TTS parameters.
Sources: Pipeline nodes and hooks | LiveKit docssalmon-belgium-62133
12/24/2025, 7:40 AMtall-airline-16756
12/24/2025, 7:40 AMon_enter is the lifecycle hook you use for an initial greeting when the agent becomes active. It runs once when the agent enters the ready/active state, so it’s ideal for sending a welcome message.
If you want an example:
async def on_enter(self):
await self.session.generate_reply(instructions="Greet the user with a warm welcome")
Do you want the greeting as text, TTS (spoken), or both? If TTS, tell me desired voice/language and I’ll give the exact parameters.stocky-sundown-99393
12/24/2025, 8:48 AMtall-airline-16756
12/24/2025, 8:48 AMon_enter works for a Gemini Realtime agent. It runs when the agent becomes active, so use it to send your initial greeting (text, TTS, or both).
Example for Gemini RealtimeAgent:
async def on_enter(self):
await self.session.generate_reply(
instructions="Greet the user with a warm welcome"
)
Do you want the greeting spoken with TTS (and if so, which voice/language) or only text? I can provide the exact TTS parameters and a fuller example for your setup.salmon-belgium-62133
12/24/2025, 8:54 AMtall-airline-16756
12/24/2025, 8:54 AMon_enter lifecycle hook to automatically greet the user when the agent becomes ready. This example shows a minimal agent class and uses session.generate_reply to send a greeting (works for text, or TTS if your pipeline supports it).
# Simple Gemini Realtime agent with automatic greeting on enter
class WelcomeAgent(RealtimeAgent):
async def on_enter(self):
# Send a warm welcome when the agent becomes active
await self.session.generate_reply(
instructions="Greet the user with a warm welcome",
)
async def on_message(self, message):
# Handle incoming user messages (simple echo example)
user_text = message.get("text", "")
if user_text:
await self.session.generate_reply(
instructions=f"You said: {user_text}"
)
Notes:
• Replace RealtimeAgent with your actual base class if it has a different import path in your environment.
• If you want a spoken greeting (TTS), add TTS parameters inside generate_reply (voice/language). Tell me the desired voice/language and I’ll show the exact parameters.salmon-belgium-62133
12/24/2025, 8:55 AMon_enter??tall-airline-16756
12/24/2025, 8:55 AMon_enter is an optional lifecycle method you must add (override) on your agent class. If you don't see it in example code, that code simply didn't include the optional hook or it uses a different place to trigger greetings.
Quick explanation and minimal example for a Gemini Realtime agent:
from livekit.agents import Agent, AgentSession
from livekit.plugins import google
class MyGeminiAgent(Agent):
def __init__(self) -> None:
super().__init__(
llm=google.realtime.RealtimeModel(
model="gemini-2.0-flash-exp",
voice="Puck",
instructions="You are a helpful assistant."
)
)
async def on_enter(self):
# runs once when agent becomes active — use this for the initial greeting
await self.session.generate_reply(
instructions="Hello! I'm ready. How can I help you today?"
)
# entrypoint example
async def entrypoint(ctx):
session = AgentSession()
await session.start(agent=MyGeminiAgent(), room=ctx.room)
If you want the greeting to be spoken, tell me the voice/language and I’ll add the exact TTS parameters.
Sources: Pipeline nodes and hooks | LiveKit docs