Overview
In conversational applications, it’s important to handle situations where users go silent or inactive. Pipecat provides built-in idle detection throughLLMUserAggregator and UserTurnProcessor, allowing your bot to respond appropriately when users haven’t spoken for a defined period.
How It Works
Idle detection monitors user activity and:- Starts tracking after the first interaction (user or bot speaking)
- Resets a timer whenever the user or bot speaks
- Pauses during function calls (which may take longer than the timeout)
- Emits an
on_user_turn_idleevent when the user is idle for longer than the timeout period - Allows you to implement escalating responses or gracefully end the conversation in your application code
Idle detection uses continuous activity frames (
UserSpeakingFrame,
BotSpeakingFrame) to track real-time conversation activity. It requires an
active speech-to-text service or a transport with built-in speech detection.Basic Implementation
Step 1: Enable Idle Detection
Enable idle detection by setting theuser_idle_timeout parameter when creating your aggregator:
Step 2: Handle Idle Events
Create an event handler to respond when the user becomes idle:Step 3: Implement Retry Logic (Optional)
For escalating responses, track retry count in your application:Best Practices
- Set appropriate timeouts: Shorter timeouts (5-10 seconds) work well for voice conversations
- Use escalating responses: Start with gentle reminders and gradually become more direct
- Limit retry attempts: After 2-3 unsuccessful attempts, consider ending the conversation gracefully by pushing an
EndTaskFrame - Reset on user activity: Use the
on_user_turn_startedevent to reset your retry counter when the user speaks - Let the LLM respond naturally: Use system messages to prompt the LLM rather than hardcoded TTS responses for more natural interactions
Next Steps
Try the User Idle Example
Explore a complete working example that demonstrates how to detect and
respond to user inactivity in Pipecat.
Turn Events
Learn about all available turn events and their parameters.