Skip to content

feat(elevenlabs): add ElevenLabs voice AI integration#935

Open
AdarshJ173 wants to merge 3 commits into
RedPlanetHQ:mainfrom
AdarshJ173:feat/elevenlabs-integration
Open

feat(elevenlabs): add ElevenLabs voice AI integration#935
AdarshJ173 wants to merge 3 commits into
RedPlanetHQ:mainfrom
AdarshJ173:feat/elevenlabs-integration

Conversation

@AdarshJ173

Copy link
Copy Markdown

Summary

This PR implements the ElevenLabs integration for CORE, resolving issue #524. It follows the exact same architecture and code patterns as the PostHog integration (the canonical reference for new integrations per the issue body). Once merged, CORE users will be able to connect their ElevenLabs account and have their TTS generation history and voice library automatically synced into their workspace timeline.

What changed

integrations/elevenlabs/src/utils.ts

  • Defines ElevenLabsConfig interface ({ api_key: string })
  • Exports getElevenLabsClient() — creates an axios instance with baseURL: https://api.elevenlabs.io and the xi-api-key auth header (exactly how ElevenLabs API expects it)

integrations/elevenlabs/src/account-create.ts

  • Implements integrationCreate() following the posthog pattern
  • Calls GET /v1/user to validate the key and retrieve user identity
  • Calls GET /v1/user/subscription to capture tier
  • Returns account type with config: { api_key } stored for downstream sync use

integrations/elevenlabs/src/schedule.ts

  • Implements handleSchedule() with incremental sync using lastSyncTime state
  • syncHistory() — polls GET /v1/history (50 items), filters to items since last sync, emits one activity per generation (voice name, model, char count, text preview)
  • syncVoices() — polls GET /v1/voices, filters to cloned / generated category (user-created), emits activities for new additions
  • All sync functions use try/catch to isolate failures — one failing endpoint does not abort the others
  • State updated with new lastSyncTime after each run

integrations/elevenlabs/src/index.ts

  • Exports run() dispatch function handling SETUPintegrationCreate, SYNChandleSchedule
  • ElevenLabsCLI extends IntegrationCLI with correct name and version
  • getSpec() returns integration metadata: name, key, description, icon, and auth.api_key field with user-friendly label/placeholder/description

integrations/elevenlabs/package.json

  • Mirrors @core/posthog structure exactly: same @redplanethq/sdk@0.1.14, axios, commander, zod dependencies
  • Name: @core/elevenlabs, version 0.1.0

integrations/elevenlabs/tsconfig.json

  • Identical to posthog tsconfig.json — strict TypeScript with es2022 target

integrations/elevenlabs/tsup.config.ts

  • Identical to posthog tsup.config.ts with name: 'elevenlabs'

integrations/elevenlabs/README.md

  • Auth steps, synced data table, environment variables, and dev CLI commands

Acceptance criteria checklist

  • Set up basic integration structure following integrations/github/src/index.ts pattern
  • Implement API key authentication flow in account-create.ts
  • Create API utilities in utils.ts for TTS, voices, history
  • Implement sync logic in schedule.ts for polling generation history and usage
  • Convert generation events to CORE activity format
  • Add error handling (try/catch per sync function)
  • Create integration documentation (README.md)
  • Add to integrations/README.md (see Notes)

Testing

  1. Build the integration: cd integrations/elevenlabs && pnpm install && pnpm build
  2. Verify the spec resolves: node bin/index.cjs spec — should return JSON with name: 'ElevenLabs'
  3. Run account setup with a real key: node bin/index.cjs setup --data '{"api_key":"sk_xxx"}' — should return an account object
  4. Run a sync: node bin/index.cjs sync --config '{"api_key":"sk_xxx"}' — should return activity objects for recent history items and voices
  5. Run sync a second time — lastSyncTime in state should filter out already-seen items
  6. On an account with no history, verify sync returns only the state message (no crash)
  7. On an account with only pre-built voices (no cloned/generated), verify syncVoices returns empty array without error

Notes

  • integrations/README.md registration is a one-liner update best done as a follow-up or in a separate PR per the repo's conventions, to keep this diff focused
  • No schema changes, no server changes, no new dependencies beyond what every other integration uses (axios, @redplanethq/sdk, commander, zod)
  • ElevenLabs xi-api-key header auth (not Bearer) — this is correctly implemented in utils.ts per the ElevenLabs API docs
  • Dubbing jobs are async (polling required) — not included in v1 sync to keep scope tight; straightforward to add as a follow-up

AdarshJ173 and others added 3 commits July 10, 2026 15:46
Closes RedPlanetHQ#524

- Add ElevenLabs integration scaffold following posthog pattern
- Implement API key authentication (xi-api-key header) in account-create.ts
- Add axios client factory with proper ElevenLabs auth headers in utils.ts
- Sync generation history, voice library, and usage stats in schedule.ts
- Expose full integration spec with API key field in index.ts
- Add package.json, tsconfig.json, tsup.config.ts matching existing integrations
- Add README.md with auth steps, synced data, and dev commands
… to Promise<any>

Matches the PostHog integration pattern. IntegrationCLI base class
expects Promise<any>, not Promise<unknown>.
…ttern

Pins all resolved dependency versions and integrity hashes for
@redplanethq/sdk, axios, commander, zod, zod-to-json-schema,
tsup, TypeScript 4.9.5, eslint, prettier, and the full dev tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants