Conversation Callbacks
If acallback_url
is provided in the POST /conversations
, callbacks will provide insight into the conversation’s state. These can be system-related (e.g. replica joins and room shutdowns) or application-related (e.g. final transcription parsing and recording-ready webhooks). Additional webhooks coming soon.
Structure
All Conversation callbacks share the following basic structure. Differences will occur in theproperties
object.
Types
Our callbacks are split into two main categories:System Callbacks
These callbacks are to provide insight into system-related events in a conversation. They are:- system.replica_joined: This is fired when the replica becomes ready for a conversation.
- system.shutdown: This is fired when the room shuts down, for any of the following reasons:
max_call_duration reached
participant_left_timeout reached
participant_absent_timeout reached
bot_could_not_join_meeting_it_was_probably_ended
daily_room_has_been_deleted
exception_encountered_during_conversation_startup
end_conversation_endpoint_hit
internal error occurred at step x
Application Callbacks
These callbacks are to inform developers about logical events that take place. They are:- application.transcription_ready: This is fired after ending a conversation, where the chat history is saved and returned.
- application.recording_ready: This is fired if you had enabled recording on, set up a custom S3 bucket for recording and started a recording inside the room at any point. This will point to the key at which your new recording lies, useful for serving recordings through a CDN.
- application.perception_analysis: This is fired after ending a conversation, when the replica has finished summarizing the visual artifacts that were detected throughout the call. This is a feature that is only available when the persona has
raven-0
specified in the Perception Layer.
Replica Training Callbacks
If acallback_url
is provided in the POST /replicas
call, you will receive a callback on replica training completion or on replica training error.
Video Generation Callbacks
If acallback_url
is providing in the POST /videos
call, you will receive callbacks on video generation completed and on video error.
Sample Webhook Setup
Create a sample webhook endpoint using Python Flask, and expose it publicly with ngrok.Prerequisites
1
Step 1: Install Python Dependencies
Install the Python dependencies needed to create the server.
2
Step 2: Make a Webhook Server
Set up a webhook server and save it as The server will receive and process webhook callbacks from Tavus, handle different event types, store transcripts in memory, and analyze conversation data for each session.
server.py
.3
Step 3: Run the Server
Run the app using the following command in the terminal:The server should run on port
5000
.4
Step 4: Forward the Port Using Ngrok
Open a terminal in the folder containing The command will generate a forwarding link (e.g., https://1234567890.ngrok-free.app), which can be used as the callback URL.
ngrok.exe
, then use Ngrok to forward the port.5
Step 5: Use the Callback URL
Include the callback URL in your request to Tavus by appending
/webhook
to the forwarding link and setting it in the callback_url
field.Create conversation with callback_url
- Replace
<api_key>
with your actual API key. You can generate one in the Developer Portal. - Replace
<replica_id>
with the Replica ID you want to use. - Replace
<persona_id>
with the Persona ID you want to use.