blue-account-81612
07/07/2025, 5:27 PMtall-airline-16756
07/07/2025, 5:27 PMtall-airline-16756
07/07/2025, 5:27 PMsession.history
property.
• Use the add_shutdown_callback
method to save the history after the session ends.
• The transcript will be saved when the user leaves and the room closes.
Here is an example code snippet to include in your agent's entrypoint:
from datetime import datetime
import json
def entrypoint(ctx: JobContext):
# Add this code before calling ctx.connect()
async def write_transcript():
current_date = datetime.now().strftime("%Y%m%d_%H%M%S")
# This saves to the temp directory, but you can use any location
filename = f"/tmp/transcript_{ctx.room.name}_{current_date}.json"
with open(filename, 'w') as f:
json.dump(session.history.to_dict(), f, indent=2)
print(f"Transcript for {ctx.room.name} saved to {filename}")
ctx.add_shutdown_callback(write_transcript)
# Rest of your entrypoint code follows...
For real-time access to conversation data, you can also listen for events like conversation_item_added
or user_input_transcribed
.
Sources: Session recording and transcripts | LiveKit Docsblue-account-81612
07/08/2025, 2:18 PMtall-airline-16756
07/08/2025, 2:18 PM