How to save transcript of the telephoney call sess...
# ask-ai
b
How to save transcript of the telephoney call session?
t
Thanks for reaching out, Dhruvil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To save the transcript of a telephony call session in LiveKit, you can modify the Voice AI quickstart to save the conversation history to a JSON file. This involves adding a shutdown callback function to your agent's entrypoint. Here's a brief overview: • Access the conversation history using the
session.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:
Copy code
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 Docs
b
How to get full json of dispatch rule id using CLI Command
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!