Skip to main content

Overview

Turn events provide hooks into the conversation turn lifecycle, allowing you to know when users and assistants start or stop speaking. These events are emitted by the context aggregators (LLMUserAggregator and LLMAssistantAggregator) and are particularly useful for:
  • Collecting transcriptions - Get complete user and assistant transcripts when turns end
  • Turn tracking - Monitor conversation flow and timing
  • Analytics - Measure turn durations, detect timeouts, and track conversation patterns

Events Summary

EventEmitterDescription
on_user_turn_starteduser_aggregatorUser begins speaking
on_user_turn_stoppeduser_aggregatorUser finishes speaking (includes transcript)
on_user_turn_stop_timeoutuser_aggregatorUser turn ended due to timeout
on_assistant_turn_startedassistant_aggregatorAssistant begins responding
on_assistant_turn_stoppedassistant_aggregatorAssistant finishes responding (includes transcript)

User Turn Events

User turn events are registered on the user_aggregator from an LLMContextAggregatorPair.

on_user_turn_started

Fired when a user turn is detected to have started, based on the configured start strategies.
@user_aggregator.event_handler("on_user_turn_started")
async def on_user_turn_started(aggregator, strategy):
    print(f"User started speaking (detected by {strategy})")
Parameters:
ParameterTypeDescription
aggregatorLLMUserAggregatorThe user aggregator instance
strategyBaseUserTurnStartStrategyThe strategy that triggered the turn start

on_user_turn_stopped

Fired when a user turn is detected to have ended, based on the configured stop strategies. This event includes the complete user transcript for the turn.
@user_aggregator.event_handler("on_user_turn_stopped")
async def on_user_turn_stopped(aggregator, strategy, message: UserTurnStoppedMessage):
    print(f"User said: {message.content}")
    print(f"Turn started at: {message.timestamp}")
    if message.user_id:
        print(f"User ID: {message.user_id}")
Parameters:
ParameterTypeDescription
aggregatorLLMUserAggregatorThe user aggregator instance
strategyBaseUserTurnStopStrategyThe strategy that triggered the turn stop
messageUserTurnStoppedMessageContains the user’s transcript and metadata

on_user_turn_stop_timeout

Fired when a user turn times out without any stop strategy triggering. This is a fallback mechanism that ends the turn after a configurable timeout period (default: 5.0 seconds) when the user has stopped speaking according to VAD but no transcription-based stop has occurred.
@user_aggregator.event_handler("on_user_turn_stop_timeout")
async def on_user_turn_stop_timeout(aggregator):
    print("User turn ended due to timeout")
Parameters:
ParameterTypeDescription
aggregatorLLMUserAggregatorThe user aggregator instance
After on_user_turn_stop_timeout fires, on_user_turn_stopped will also be called with the accumulated transcript.

Assistant Turn Events

Assistant turn events are registered on the assistant_aggregator from an LLMContextAggregatorPair.

on_assistant_turn_started

Fired when the assistant begins generating a response.
@assistant_aggregator.event_handler("on_assistant_turn_started")
async def on_assistant_turn_started(aggregator):
    print("Assistant started responding")
Parameters:
ParameterTypeDescription
aggregatorLLMAssistantAggregatorThe assistant aggregator instance

on_assistant_turn_stopped

Fired when the assistant finishes responding or is interrupted. This event includes the complete assistant transcript for the turn.
@assistant_aggregator.event_handler("on_assistant_turn_stopped")
async def on_assistant_turn_stopped(aggregator, message: AssistantTurnStoppedMessage):
    print(f"Assistant said: {message.content}")
    print(f"Turn started at: {message.timestamp}")
Parameters:
ParameterTypeDescription
aggregatorLLMAssistantAggregatorThe assistant aggregator instance
messageAssistantTurnStoppedMessageContains the assistant’s transcript and metadata
This event fires when the LLM response completes, when the user interrupts, or when a user image is appended to context.

Message Types

UserTurnStoppedMessage

Contains the user’s complete transcript when their turn ends.
from pipecat.processors.aggregators.llm_response_universal import UserTurnStoppedMessage
content
str
The complete transcribed text from the user’s turn.
timestamp
str
ISO 8601 timestamp indicating when the user turn started.
user_id
Optional[str]
Optional identifier for the user, if available from the transport.

AssistantTurnStoppedMessage

Contains the assistant’s complete transcript when their turn ends.
from pipecat.processors.aggregators.llm_response_universal import AssistantTurnStoppedMessage
content
str
The complete text content from the assistant’s turn.
timestamp
str
ISO 8601 timestamp indicating when the assistant turn started.