TheDocumentation Index
Fetch the complete documentation index at: https://daily-docs-pr-4424.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
TurnTrackingObserver monitors and tracks conversational turns in your Pipecat pipeline, providing events when turns start and end. It intelligently identifies when a user-bot interaction cycle begins and completes.
Turn Lifecycle
A turn represents a complete user-bot interaction cycle:- Start: When the user starts speaking (or pipeline starts for first turn)
- Processing: User speaks, bot processes and responds
- End: After the bot finishes speaking and either:
- The user starts speaking again
- A timeout period elapses with no further activity
Events
The observer emits two main events:on_turn_started: When a new turn begins- Parameters:
turn_number(int)
- Parameters:
on_turn_ended: When a turn completes- Parameters:
turn_number(int),duration(float, in seconds),was_interrupted(bool)
- Parameters:
Usage
The observer is automatically created when you initialize aPipelineTask with enable_turn_tracking=True (which is the default):
Configuration
You can configure the observer’s behavior when creating aPipelineTask:
Interruptions
The observer automatically detects interruptions when the user starts speaking while the bot is still speaking. In this case:- The current turn is marked as interrupted (
was_interrupted=True) - A new turn begins immediately
How It Works
The observer monitors specific frame types to track conversation flow:- StartFrame: Initiates the first turn
- UserStartedSpeakingFrame: Starts user speech or triggers a new turn
- BotStartedSpeakingFrame: Marks bot speech beginning
- BotStoppedSpeakingFrame: Starts the turn end timeout
Use Cases
- Analytics: Measure turn durations, interruption rates, and conversation flow
- Logging: Record turn-based logs for diagnostics and analysis
- Visualization: Show turn-based conversation timelines in UIs
- Tracing: Group spans and metrics by conversation turns