#how do i get the conversation for a webrtc session via api?
1 messages · Page 1 of 1 (latest)
AI-generated Answer for lmelzer
Short answer:
- Start your WebRTC session and capture its conversation_id, then fetch the conversation by ID.
How to do it:
- Get a WebRTC conversation token on your server
- Call GET /v1/convai/conversation/token with agent_id (optional: participant_name, branch_id). Returns { "token": "..." }. Do not expose your API key to the client. (elevenlabs.io)
- Start the WebRTC session on the client and read the conversation_id
- With the ElevenAgents JS SDK, pass the token to startSession and then call getId():
- const conversation = await Conversation.startSession({ conversationToken, connectionType: 'webrtc' });
- const conversationId = conversation.getId();
- For public agents you can also start with just agentId; for private agents you must use the token. (elevenlabs.io)
- The official WebRTC launch note also shows startSession returning a conversationId. (elevenlabs.io)
- Retrieve the conversation via REST
- Get details (including transcript, metadata, status, and audio presence flags):
- GET /v1/convai/conversations/{conversation_id} (header: xi-api-key). (elevenlabs.io)
- Optionally download the call recording:
- GET /v1/convai/conversations/{conversation_id}/audio. (elevenlabs.io)
If you didn’t capture the conversation_id:
- List and filter recent conversations, then select the one you need:
- GET /v1/convai/conversations with query filters like agent_id and call_start_after_unix. (elevenlabs.io)
Live (during-call) access:
- Enterprise-only real-time monitoring WebSocket: wss://api.elevenlabs.io/v1/convai/conversations/{conversation_id}/monitor streams events/transcripts for active calls. (elevenlabs.io)
Notes:
- For WebRTC, use a conversation token; the “signed URL” flow is for WebSocket connections. (elevenlabs.io)
Sources:
Get conversation token | ElevenLabs Documentation
JavaScript SDK | ElevenLabs Documentation
ElevenLabs Conversational AI now supports WebRTC
Get conversation details | ElevenLabs Documentation
Get conversation audio | ElevenLabs Documentation
List conversations | ElevenLabs Documentation
Real-time monitoring | ElevenLabs Documentation
JavaScript SDK | ElevenLabs Documentation
is there no other way to get the conversation_id for a webrtc session than by starting the session via js?