Skip to content

WIP - Add Telnyx voice provider#1461

Draft
whoiskatrin wants to merge 9 commits into
mainfrom
feat/telnyx-voice-provider
Draft

WIP - Add Telnyx voice provider#1461
whoiskatrin wants to merge 9 commits into
mainfrom
feat/telnyx-voice-provider

Conversation

@whoiskatrin
Copy link
Copy Markdown
Contributor

@whoiskatrin whoiskatrin commented May 4, 2026

Summary

Adds first-class Telnyx support for the Cloudflare voice pipeline, addressing #1367.

This PR introduces a new @cloudflare/voice-telnyx provider package under voice-providers/telnyx and a phone/PSTN-focused examples/telnyx-voice-agent app that demonstrates the browser-side Telnyx WebRTC bridge model.

What changed

@cloudflare/voice-telnyx

  • Adds a Telnyx provider package following the existing voice-providers/* conventions.
  • Supports subpath imports so users can import only what they need:
    • @cloudflare/voice-telnyx
    • @cloudflare/voice-telnyx/stt
    • @cloudflare/voice-telnyx/tts
    • @cloudflare/voice-telnyx/telephony
  • Ports Telnyx STT support implementing Transcriber / TranscriberSession:
    • Workers fetch-upgrade WebSocket connection
    • 16 kHz mono PCM16 streaming
    • WAV header emission for Telnyx's streaming API
    • interim and final transcript callbacks
  • Ports Telnyx TTS support implementing TTSProvider and StreamingTTSProvider:
    • REST backend by default
    • Workers-only WebSocket streaming backend
  • Adds Telnyx telephony helpers:
    • TelnyxCallBridge
    • TelnyxPhoneTransport
    • TelnyxPhoneClient
    • TelnyxJWTEndpoint
    • createTelnyxVoiceConfig
  • Keeps STT/TTS subpaths independent from telephony imports.
  • Adds README docs covering environment variables, subpath imports, browser voice usage, and PSTN/telephony setup.

Example app

  • Adds examples/telnyx-voice-agent, focused on the phone/PSTN path:
    • phone call → Telnyx WebRTC bridge in the browser
    • browser bridge → Cloudflare Agent WebSocket
    • Telnyx STT → Workers AI LLM → Telnyx TTS
    • response audio injected back into the same phone call
  • Uses createTelnyxVoiceConfig and TelnyxPhoneClient from @cloudflare/voice-telnyx/telephony.
  • Uses the browser as a control panel/WebRTC bridge, not as a microphone/speaker voice demo.
  • Includes .env.example with:
    • TELNYX_API_KEY
    • TELNYX_CREDENTIAL_CONNECTION_ID
  • Documents the local-demo JWT endpoint and calls out replacing allowUnauthenticated: true with an authorize() callback in production.

Attribution / dependency metadata

  • Adds @telnyx/webrtc for telephony support.
  • Updates NOTICE to document that parts of this provider are adapted from Telnyx's @telnyx/voice-cloudflare package, whose npm metadata declares MIT licensing.

Validation

Passed:

npm run build -w @cloudflare/voice-telnyx
npm run build -w @cloudflare/agents-telnyx-voice-agent
npm run check

npm run check reports existing sherif warnings for unrelated workspace paths without package.json, then completes successfully: export checks, formatting, oxlint, and all 82 TypeScript projects pass.

Notes for reviewers

  • The example now intentionally demonstrates the provider's distinctive phone/PSTN bridge value instead of a browser microphone/speaker STT/TTS flow.
  • The phone example leaves the voice agent's default declared audio format in place because TelnyxTTS currently returns MP3 by default and TelnyxPhoneClient can decode non-PCM server audio before playing into the phone bridge.
  • For production, the JWT endpoint should use an authorize() callback instead of allowUnauthenticated: true.

Refs #1367

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: 96ff3b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

Comment thread voice-providers/telnyx/src/transport/phone-transport.ts Outdated
whoiskatrin and others added 2 commits May 4, 2026 22:09
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 4, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1461

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1461

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1461

hono-agents

npm i https://pkg.pr.new/hono-agents@1461

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1461

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1461

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1461

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1461

commit: 96ff3b3

@whoiskatrin whoiskatrin changed the title Add Telnyx voice provider WIP - Add Telnyx voice provider May 6, 2026
Copy link
Copy Markdown

@Oliver-Zimmerman Oliver-Zimmerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice port overall — I think you’ve preserved the core architecture well, especially the split between STT/TTS/telephony and the browser-side PSTN bridge model. My main ask would be to swap the example for one that better shows the real value of the provider: the current example reads mostly like a browser STT/TTS demo, while the distinctive bit here is the phone/PSTN path. I’d suggest porting one of the original phone/hybrid examples instead, e.g. examples/phone-voice-agent: https://github.com/team-telnyx/voice-cloudflare/tree/main/examples/phone-voice-agent”

@Oliver-Zimmerman
Copy link
Copy Markdown

Hey @whoiskatrin any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants