elevenlabs-agent-simulator

ElevenLabs Agent Simulator - Chrome Extension Implementation Plan

Project Overview

ElevenLabs Agent Simulator is a Chrome extension that brings SDK-level conversation testing capabilities directly into the ElevenLabs web interface. It enables developers to simulate realistic dialogues between their conversational AI agent and an automated user agent, allowing them to test prompts, refine settings, and identify edge cases before production deployment.

Architecture Overview

Extension Structure

Note: No background service worker or content scripts needed - the popup handles everything directly.

Implementation Phases

Phase 1: Project Setup & Foundation

1.1 Initialize Project Structure

1.2 Dependencies

Note: The ElevenLabs Node.js SDK (@elevenlabs/elevenlabs-js) cannot be used in browser environments. The browser SDK (@elevenlabs/client) is designed for real-time voice conversations via WebSocket/WebRTC, not for the simulateConversation API. We’ll make direct HTTPS REST API calls to https://api.elevenlabs.io/v1/convai/agents/{agent_id}/simulate-conversation using the Fetch API.

1.3 Create manifest.json

Phase 2: Popup UI Implementation

2.1 URL Parser Utility (src/utils/url-parser.ts)

2.2 Popup Interface (src/popup/popup.html)

2.3 Popup Styling (src/popup/popup.css)

2.4 Popup Logic (src/popup/popup.ts)

Phase 3: Simulation Logic

Key Architecture: The ElevenLabs REST API’s simulate-conversation endpoint is extremely simple:

3.1 Simulation Function (src/popup/popup.ts)

3.2 Response Display

Phase 4: Dynamic Variables Support ✅ COMPLETED

Problem: Some agents require dynamic variables (e.g., user_name, order_id) to be provided in the simulation. Without these, the API returns a 400 error:

{
  "detail": {
    "status": "missing_dynamic_variables",
    "message": "Missing required dynamic variables in first message: {'user_name'}"
  }
}

4.1 Dynamic Variables UI (src/popup/popup.html)

4.2 Dynamic Variables Styling (src/popup/popup.css)

4.3 Dynamic Variables Logic (src/popup/popup.ts)

4.4 Auto-Load Default Variables Feature NEW

User Flow:

  1. User opens extension on an ElevenLabs agent page (Agent ID auto-detected)
  2. User enters their API key
  3. User clicks “Load Defaults” button
  4. Extension fetches agent configuration from ElevenLabs API
  5. Default dynamic variable placeholders are automatically populated
  6. User can modify, add, or remove variables as needed
  7. User clicks “Start Simulation” with pre-filled variables

Benefits:

Phase 5: Persistent State Management ✅ COMPLETED

Problem: Currently, when the popup closes (user clicks outside or switches tabs), all input values are lost. When reopening the popup, users must re-enter their API key, simulated user prompt, and dynamic variables every time.

Goal: Preserve user inputs across popup sessions using Chrome’s storage API, so values persist even when the popup is closed and reopened.

5.1 Storage Strategy

5.2 Manifest Updates (manifest.json)

5.3 Save Logic (src/popup/popup.ts)

5.4 Load Logic (src/popup/popup.ts)

5.5 Clear State Feature

5.6 Storage Schema

interface StoredState {
  apiKey?: string;
  userPrompt?: string;
  dynamicVariables?: Array<{ key: string; value: string }>;
}

5.7 Edge Cases Handled

5.8 Security Considerations

User Flow After Phase 5:

  1. User opens extension → Sees previously entered values auto-filled
  2. User modifies inputs → Values auto-save in background (500ms debounce)
  3. User closes popup (clicks outside) → State persisted
  4. User reopens popup later → All values restored, ready to run simulation
  5. User can click “Clear All” to reset everything

Benefits:

Phase 6: Side Panel Migration ✅ COMPLETED

Problem: Popup closes automatically when users click outside or interact with the webpage.

Solution: Migrate to Chrome’s Side Panel API for persistent UI that stays open during page interactions.

6.1 Changes Required

Manifest (public/manifest.json):

Background Script (src/background/background.ts):

Webpack (webpack.config.js):

6.2 Testing

Phase 7: Conversation Display Enhancement ✅ COMPLETED

Problem: The current output displays the entire raw JSON response, which contains too much technical metadata that users don’t need for everyday testing. While the full JSON is useful for debugging, users primarily care about the actual conversation flow between the agent and the simulated user.

Goal: Add a user-friendly conversation display section that shows a clean, readable transcript of the dialogue, while keeping the full JSON output available below for those who need it.

7.1 UI Structure (src/popup/popup.html) ✅

7.2 Conversation Display Format ✅

Data Source: Extract from response.simulated_conversation array

Fields to Use:

Display Format:

Edge Cases Handled:

7.3 Styling (src/popup/popup.css) ✅

7.4 Display Logic (src/popup/popup.ts) ✅

User Flow After Phase 7:

  1. User runs a simulation with their agent
  2. Results section appears with two parts:
    • Conversation Transcript: Clean, readable dialogue between user and agent
    • Full Response (JSON): Complete API response for debugging
  3. User can quickly review the conversation flow without parsing JSON
  4. User can still access full technical details if needed

Benefits:

Technical Considerations

Security

Performance

Browser Compatibility

Rate Limiting

Dependencies & APIs

ElevenLabs REST API

Why Not Use the SDKs?

Chrome Extension APIs