UserIdleProcessor
- class pipecat.processors.user_idle_processor.UserIdleProcessor(*, callback, timeout, **kwargs)[source]
Bases:
FrameProcessor
Monitors user inactivity and triggers callbacks after timeout periods.
Starts monitoring only after the first conversation activity (UserStartedSpeaking or BotSpeaking).
- Parameters:
callback (Callable[[UserIdleProcessor], Awaitable[None]] | Callable[[UserIdleProcessor, int], Awaitable[bool]]) –
Function to call when user is idle. Can be either: - Basic callback(processor) -> None - Retry callback(processor, retry_count) -> bool
Return True to continue monitoring for idle events, Return False to stop the idle monitoring task
timeout (float) – Seconds to wait before considering user idle
**kwargs – Additional arguments passed to FrameProcessor
Example
# Retry callback: async def handle_idle(processor: “UserIdleProcessor”, retry_count: int) -> bool:
- if retry_count < 3:
await send_reminder(“Are you still there?”) return True
return False
# Basic callback: async def handle_idle(processor: “UserIdleProcessor”) -> None:
await send_reminder(“Are you still there?”)
- processor = UserIdleProcessor(
callback=handle_idle, timeout=5.0
)
- property retry_count: int
Returns the current retry count.
- async process_frame(frame, direction)[source]
Processes incoming frames and manages idle monitoring state.
- Parameters:
frame (Frame) – The frame to process
direction (FrameDirection) – Direction of the frame flow
- Return type:
None
- async cleanup()[source]
Cleans up resources when processor is shutting down.
- Return type:
None