Speak First
# ask-ai
m
Speak First
t
Thanks for reaching out, aigentzi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You’re asking me to speak first — happy to. What would you like help with today? A few examples to pick from: • Troubleshooting a room/connection issue • Starting or configuring a recording • SDK integration (Web, iOS, Android) • Authentication/token generation or permissions • Billing or account questions Or describe your problem in one sentence and I’ll take it from there.
m
hi how do we prompt agents to speak first , we have ' a start lesson button" which should prmpt agent to say it's opening greeting prompt , ' > also how willthis work when a user calls is usinga livekit number
t
Acknowledging: you want the agent to speak first when a user clicks your "Start Lesson" button, and you want to know how that works for inbound calls to a LiveKit phone number. Short answer: • Trigger the agent to speak explicitly—either from the frontend via RPC when the button is clicked, or from the agent code after the telephony session connects for inbound phone calls. Use
session.generate_reply()
(LLM-generated greeting) or
session.say()
(fixed greeting). What to implement 1) Start Lesson button (frontend → agent) • When the button is clicked, send an RPC from the frontend to the room/agent. • In the agent, listen for that RPC and call
session.generate_reply()
or
session.say()
with your greeting. Example flow: 1. Frontend: send RPC
Copy code
room.localParticipant.sendRpc('start_lesson', '', (response) => {
  console.log(response);
});
1. Agent: on RPC received, trigger speech
Copy code
@ctx.room.local_participant.on('rpc_received')
async def on_rpc(method, payload, response_channel):
    if method == 'start_lesson':
        await session.generate_reply(instructions="Give a warm opening greeting to start the lesson.")
        response_channel.send("Agent greeted user")
2) Incoming calls to a LiveKit phone number • Configure your LiveKit phone number to dispatch to your agent. • In the agent code, after
session.start()
and the room connects, immediately call
session.generate_reply()
or
session.say()
so the agent speaks first after answering. Example snippet:
Copy code
@server.rtc_session(agent_name='lesson-agent')
async def my_agent(ctx: JobContext):
    await session.start(room=ctx.room, agent=Assistant())
    await ctx.connect()
    await session.generate_reply(instructions="Greet the caller and say lesson is starting.")
Key notes • Use
generate_reply()
for dynamic, context-aware greetings; use
session.say("fixed text")
for a fixed message. • The agent will not speak automatically—you must call
generate_reply()
or
say()
in response to the button RPC or after connecting the telephony session. • LiveKit phone numbers can be assigned to dispatch rules so inbound calls will trigger your agent; after answer, trigger the greeting as shown. Would you like a tailored example using your existing agent code (language/SDK) or help wiring the RPC from your specific frontend framework? Sources: Agent Builder | LiveKit docs | Agents telephony integration | LiveKit docs | Agent speech and audio | LiveKit docs | LiveKit Phone Numbers | LiveKit docs | Turn detection and interruptions | LiveKit Docs