Skip to main content

Overview

Replay’s AI agents support Remote Procedure Call (RPC) methods through LiveKit’s RPC framework. These methods allow you to request data from the agent during an active conversation, such as retrieving the conversation transcript.
Want to learn more about LiveKit RPC? Check out the official LiveKit RPC documentation for in-depth information about the underlying technology.

Available RPC Methods

get_agent_transcript

Retrieves the full conversation transcript from the AI agent, including all messages exchanged between the user and the agent.

Use Cases

  • Retrieving a full transcript at any point during the call
  • Saving conversation records when a user ends the call

How to Invoke

Use LiveKit’s native performRpc method on the local participant:
// Get the agent's identity from the room participants
// The agent is typically identified by a participant with isAgent = true
const agent = room.remoteParticipants.values().next().value;

if (!agent) {
  throw new Error('Agent not found in room');
}

// Perform the RPC call
const response = await room.localParticipant.performRpc({
  destinationIdentity: agent.identity,
  method: 'get_agent_transcript',
  payload: '', // Empty payload for this method
});

// Parse the response
const parsedResponse = JSON.parse(response);

if (parsedResponse.error) {
  throw new Error(parsedResponse.error);
}

console.log('Transcript:', parsedResponse);
// Handle the transcript data
Method Name: The RPC method name is get_agent_transcript (all lowercase with underscores).

Return Signature

The method returns a TranscriptResponse object with the following structure:
interface TranscriptResponse {
  snippets: TranscriptSnippet[];
  createdAt: number;
}

interface TranscriptSnippet {
  speakerName: string;  // Display name of speaker (e.g., "John Doe", "Karen - Investor @ Qualtrics")
  text: string;          // The transcribed text content
  createdAt: number;     // Unix timestamp in milliseconds when message was created
  isUser: boolean;       // true if speaker is user, false if assistant
}

Response Fields

FieldTypeDescription
snippetsTranscriptSnippet[]Array of conversation messages in chronological order
createdAtnumberUnix timestamp (milliseconds) when the conversation was started

TranscriptSnippet Fields

FieldTypeDescription
speakerNamestringDisplay name of the speaker
textstringThe actual transcribed message content
createdAtnumberUnix timestamp (milliseconds) when the completed message was added to the transcript array. Typically corresponds to the time a user or agent finished speaking their snippet.
isUserbooleantrue if the message is from the user, false if from the agent

Example Response

{
  "snippets": [
    {
      "speakerName": "Bobby the Buyer (PM @ Google)",
      "text": "Hello, I'd like to learn more about your product.",
      "createdAt": 1730304000000,
      "isUser": false
    },
    {
      "speakerName": "Sarah the Seller",
      "text": "Of course! I'd be happy to help. What specific features are you interested in?",
      "createdAt": 1730304003000,
      "isUser": true
    },
    {
      "speakerName": "Bobby the Buyer (PM @ Google)",
      "text": "I'm particularly interested in the analytics capabilities.",
      "createdAt": 1730304008000,
      "isUser": false
    }
  ],
  "createdAt": 1730304010000
}

Error Handling

RPC calls may fail for several reasons. Always implement proper error handling:
try {
  const agent = Array.from(room.remoteParticipants.values())[0];
  
  if (!agent) {
    throw new Error('Agent not found in room');
  }

  const response = await room.localParticipant.performRpc({
    destinationIdentity: agent.identity,
    method: 'get_agent_transcript',
    payload: '',
  });

  const parsedResponse = JSON.parse(response);
  
  if (parsedResponse.error) {
    throw new Error(parsedResponse.error);
  }

  // Handle success
  console.log('Transcript:', parsedResponse);
} catch (error) {
  // Common error scenarios:
  // - "Agent not found in room" - No agent connected
  // - "Room or local participant not found" - User not in a room
  // - Network or timeout errors
  // - JSON parsing errors
  console.error('RPC Error:', error.message);
}
Important Considerations:
  • Ensure the user is connected to a LiveKit room before calling RPC methods
  • The AI agent must be active and connected to the room
  • RPC calls are asynchronous and may take time depending on transcript length
  • Always implement timeout handling for production applications

Need Help? Contact our support team ([email protected]) for assistance with implementing RPC methods in your application.