Skip to main content

Overview

Pipecat provides an event system that lets you hook into lifecycle changes across the framework — pipeline state transitions, service connections, transport activity, conversation turns, errors, and more. Events are available on most Pipecat objects (anything that inherits from BaseObject). You register handlers using the @event_handler decorator, and Pipecat calls them automatically when things happen.
@task.event_handler("on_pipeline_started")
async def on_pipeline_started(task, frame):
    print("Pipeline is running!")

@tts.event_handler("on_connected")
async def on_tts_connected(service):
    print(f"TTS service connected: {service}")

Registering Event Handlers

Use the @event_handler decorator on the object that emits the event:
@object.event_handler("event_name")
async def handler(object, ...):
    # Handle the event
    ...
The first parameter is always the object that emitted the event. Additional parameters depend on the specific event. You can also register handlers without the decorator:
async def my_handler(object, ...):
    ...

object.add_event_handler("event_name", my_handler)
Handlers can be either async or synchronous functions — Pipecat detects which and calls them appropriately.

Multiple Handlers

You can register multiple handlers for the same event. They execute in the order they were registered:
@task.event_handler("on_pipeline_finished")
async def log_finished(task, frame):
    print("Pipeline finished (handler 1)")

@task.event_handler("on_pipeline_finished")
async def cleanup(task, frame):
    print("Cleaning up (handler 2)")

Synchronous vs Asynchronous Events

Events are either synchronous or asynchronous, depending on how the component registered them internally:
  • Synchronous events (sync=True) run the handler inline — the caller waits for the handler to complete before continuing. These are used for events that must complete immediately, such as frame processing hooks and error handling. Synchronous event handlers should execute fast to avoid blocking the pipeline.
  • Asynchronous events (default) run the handler in a background asyncio.Task. The caller continues immediately. These are used for events where you might do I/O, logging, or other work that shouldn’t block the pipeline.
You don’t need to choose — the sync/async behavior is determined by the component, not by your handler. Your handler can be an async def or a regular def regardless.

Events Reference

The table below lists all events available in Pipecat, grouped by component. Click through to the linked documentation for full details including handler signatures and usage examples.

Pipeline

Events on PipelineTask.
EventDescription
on_pipeline_startedPipeline has started processing
on_pipeline_finishedPipeline reached a terminal state (stopped, ended, or cancelled)
on_pipeline_errorAn error frame reached the pipeline task
on_frame_reached_upstreamA filtered frame type reached the pipeline source
on_frame_reached_downstreamA filtered frame type reached the pipeline sink
on_idle_timeoutNo activity detected within the idle timeout period

Frame Processor

Events on every FrameProcessor. Since all services, transports, and processors inherit from FrameProcessor, these events are available on any processor in your pipeline.
EventDescription
on_errorAn error occurred in this processor
on_before_process_frameA frame is about to be processed
on_after_process_frameA frame has just been processed
on_before_push_frameA frame is about to be pushed to the next processor
on_after_push_frameA frame has just been pushed to the next processor

Turn Management

Events on context aggregators from LLMContextAggregatorPair.
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_user_turn_idleuser_aggregatorUser has been idle for configured timeout
on_user_mute_starteduser_aggregatorUser input was muted
on_user_mute_stoppeduser_aggregatorUser input was unmuted
on_assistant_turn_startedassistant_aggregatorAssistant begins responding
on_assistant_turn_stoppedassistant_aggregatorAssistant finishes responding (includes transcript)
on_assistant_thoughtassistant_aggregatorAssistant produced a thought (reasoning models)

STT Services

Events on STT service instances. Available on all WebSocket-based STT services. See Service Events for details.
EventDescription
on_connectedWebSocket connection established
on_disconnectedWebSocket connection closed
on_connection_errorWebSocket connection error occurred
Some STT services have additional events: Deepgram STT:
EventDescription
on_speech_startedSpeech detected in audio stream
on_utterance_endEnd of utterance detected
Deepgram Flux STT:
EventDescription
on_start_of_turnStart of a new turn detected
on_turn_resumedA previously paused turn has resumed
on_end_of_turnEnd of turn detected
on_eager_end_of_turnEarly end-of-turn prediction
on_updateTranscript updated
Speechmatics STT:
EventDescription
on_speakers_resultSpeaker identification result received
Sarvam STT:
EventDescription
on_speech_startedSpeech detected
on_speech_stoppedSpeech stopped
on_utterance_endEnd of utterance detected

TTS Services

Events on TTS service instances. Available on all WebSocket-based TTS services. See Service Events for details.
EventDescription
on_connectedWebSocket connection established
on_disconnectedWebSocket connection closed
on_connection_errorWebSocket connection error occurred
on_tts_requestA TTS synthesis request is being sent

LLM Services

Events on LLM service instances. See Service Events for details.
EventDescription
on_function_calls_startedLLM has started making function/tool calls
on_completion_timeoutLLM response timed out
OpenAI Realtime / Grok Realtime:
EventDescription
on_conversation_item_createdA new conversation item was created
on_conversation_item_updatedA conversation item was updated

Daily Transport

Events on DailyTransport instances.
EventDescription
on_joinedBot joined the room
on_leftBot left the room
on_errorTransport error occurred
on_call_state_updatedCall state changed
on_client_connectedA participant connected
on_client_disconnectedA participant disconnected
on_first_participant_joinedFirst participant joined the room
on_participant_joinedA participant joined
on_participant_leftA participant left
on_participant_updatedA participant’s state was updated
on_active_speaker_changedActive speaker changed
on_app_messageApp message received
on_transcription_messageTranscription message received
on_recording_startedRecording started
on_recording_stoppedRecording stopped
on_recording_errorRecording error occurred
on_dialin_connectedDial-in call connected
on_dialin_readyDial-in SIP endpoint ready
on_dialin_stoppedDial-in call stopped
on_dialin_errorDial-in error occurred
on_dialin_warningDial-in warning
on_dialout_answeredDial-out call answered
on_dialout_connectedDial-out call connected
on_dialout_stoppedDial-out call stopped
on_dialout_errorDial-out error occurred
on_dialout_warningDial-out warning
on_before_leaveAbout to leave the room (sync)

LiveKit Transport

Events on LiveKitTransport instances.
EventDescription
on_connectedConnected to the room
on_disconnectedDisconnected from the room
on_participant_connectedA participant connected
on_participant_disconnectedA participant disconnected
on_first_participant_joinedFirst participant joined
on_audio_track_subscribedAudio track subscribed
on_audio_track_unsubscribedAudio track unsubscribed
on_video_track_subscribedVideo track subscribed
on_video_track_unsubscribedVideo track unsubscribed
on_data_receivedData message received
on_call_state_updatedCall state changed
on_before_disconnectAbout to disconnect (sync)

WebSocket Transports

Events on WebSocket transport instances. WebSocketServerTransport:
EventDescription
on_client_connectedClient connected
on_client_disconnectedClient disconnected
on_session_timeoutSession timed out
on_websocket_readyWebSocket server is ready
FastAPIWebsocketTransport:
EventDescription
on_client_connectedClient connected
on_client_disconnectedClient disconnected
on_session_timeoutSession timed out
WebSocketClientTransport:
EventDescription
on_connectedConnected to server
on_disconnectedDisconnected from server

Other Transports

SmallWebRTCTransport:
EventDescription
on_client_connectedClient connected
on_client_disconnectedClient disconnected
on_app_messageApp message received
HeyGenTransport / TavusTransport:
EventDescription
on_client_connectedClient connected
on_client_disconnectedClient disconnected

Utilities

ServiceSwitcher:
EventDescription
on_service_switchedActive service was switched
TranscriptProcessor:
EventDescription
on_transcript_updateTranscript was updated
AudioBufferProcessor:
EventDescription
on_audio_dataAudio data available
on_track_audio_dataPer-track audio data available
on_user_turn_audio_dataUser turn audio data available
on_bot_turn_audio_dataBot turn audio data available
RTVIProcessor:
EventDescription
on_bot_startedBot started
on_client_readyClient is ready
on_client_messageClient message received

Observers

TurnTrackingObserver:
EventDescription
on_turn_startedA conversation turn started
on_turn_endedA conversation turn ended
UserBotLatencyObserver:
EventDescription
on_latency_measuredLatency measurement available

Extensions

VoicemailDetector:
EventDescription
on_conversation_detectedLive conversation detected (not voicemail)
on_voicemail_detectedVoicemail detected
IVRNavigator:
EventDescription
on_conversation_detectedLive conversation detected
on_ivr_status_changedIVR navigation status changed