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 nativeperformRpc method on the local participant:
Method Name: The RPC method name is
get_agent_transcript (all lowercase with underscores).Return Signature
The method returns aTranscriptResponse object with the following structure:
Response Fields
| Field | Type | Description |
|---|---|---|
snippets | TranscriptSnippet[] | Array of conversation messages in chronological order |
createdAt | number | Unix timestamp (milliseconds) when the conversation was started |
TranscriptSnippet Fields
| Field | Type | Description |
|---|---|---|
speakerName | string | Display name of the speaker |
text | string | The actual transcribed message content |
createdAt | number | Unix 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. |
isUser | boolean | true if the message is from the user, false if from the agent |
Example Response
end_room
Ends the current LiveKit room session, stopping all active egresses (audio/video recordings) before deleting the room.Use Cases
- Programmatically ending a roleplay session when a user clicks an end call button
- Gracefully shutting down a session with proper cleanup
- Stopping recordings and freeing up resources
How to Invoke
Use LiveKit’s nativeperformRpc method on the local participant:
Payload
The payload is optional and can be either:- With reason (recommended):
JSON.stringify({ reason: "User clicked end call button" }) - Empty string:
""(if no reason is needed)
Return Signature
The method returns anEndRoomResponse object with the following structure:
Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | true if the end room request was successfully acknowledged |
message | string | Confirmation message indicating the request was received (e.g., “End room request acknowledged”) |
Important Note on Response Timing
Why an immediate acknowledgment? The
end_room RPC method returns an immediate acknowledgment response rather than waiting for the room to actually end. This is because once the room is ended, no RPC methods can be sent through the room connection (since the room no longer exists). The actual room termination process happens asynchronously after the acknowledgment is returned, including stopping all active egresses (audio/video recordings) and deleting the room.Example Response
Success Response:Example Usage
Method Name: The RPC method name is
end_room (all lowercase with underscores).Agent Identity: The agent identity follows the pattern: {display_name}::{roleplay_id}::{timestamp}. You can find the agent’s identity from room.remoteParticipants by looking for the participant that matches your agent’s display name or has isAgent set to true.Important Considerations:
- This method returns an immediate acknowledgment; the actual room termination happens asynchronously
- The method stops all active egresses (audio/video recordings) before deleting the room (asynchronously)
- Ensure the user is connected to a LiveKit room before calling this method
- The AI agent must be active and connected to the room
- After receiving the acknowledgment, you should handle cleanup and navigation in your application
- Always implement proper error handling for production applications
Error Handling
RPC calls may fail for several reasons. Always implement proper error handling: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.

