victorious-monitor-50234
10/08/2025, 9:40 AMupdate_instructions(), you can easily adjust how the LLM behaves on the fly, tailoring responses whether it’s voicemail or a human on the call
how do i use this . for a minimal prompt at first and main prompt after.tall-airline-16756
10/08/2025, 9:40 AMtall-airline-16756
10/08/2025, 9:40 AMupdate_instructions(). Are you perhaps looking to switch from a minimal prompt to a main prompt depending on certain conditions or events during a call? Feel free to share more details so I can assist you more effectively!victorious-monitor-50234
10/08/2025, 9:41 AMtall-airline-16756
10/08/2025, 9:41 AMupdate_instructions() for switching from a minimal prompt to a full prompt based on voicemail detection or user pickup, here’s a friendly step-by-step guide to help you along:
1. Start with a Minimal Prompt: Begin by setting up the agent with instructions that help it detect voicemail or respond briefly when a live user answers. For example: instructions="You are an outbound calling agent. If you hear a voicemail greeting, use the 'detected_answering_machine' tool. Otherwise, introduce yourself briefly and wait for a response."
2. Detect Voicemail: You can create a function tool to recognize voicemail and either leave a message or update the instructions specifically for voicemail scenarios: @function_tool()
async def detected_answering_machine(self, ctx: RunContext):
await ctx.session.say("Hi, this is Jayden from the dental office. Please call us back to confirm your appointment. Thank you.")
await self.hangup()
3. Switch to Full Prompt for Live User: When you detect a live person (for instance, if they respond or silence is broken), you can smoothly transition to a richer, more engaging prompt using `update_instructions()`: await self.update_instructions(
"You are a helpful scheduling assistant. Engage in a natural, conversational tone. Offer to confirm the appointment or provide alternatives.")
4. Optional Silence Detection: If you’d like, you can add a timer to catch prolonged silence, which might suggest voicemail: SILENCE_THRESHOLD = 5 # seconds
async def monitor_silence():
if time.time() - user_last_spoke_time > SILENCE_THRESHOLD:
await ctx.session.update_instructions("Leave a concise message and prepare to hang up.")
This method helps your system adapt dynamically based on what’s happening in the call. If you’d like, I’m happy to provide a full working example or assist you further—just let me know!
Sources: basics/change_agent_instructions.py | Community & Support | livekit/livekit_composite | DeepWiki | plugins/openai/src/realtime/realtime_model.ts | livekit-agents/livekit/agents/voice/generation.py | SIP & Telephony Applications | livekit/livekit_composite | DeepWiki