webrtc-clients/javascript/SKILL.md
Build browser-based VoIP calling apps using Telnyx WebRTC JavaScript SDK. Covers authentication, voice calls, events, debugging, call quality metrics, and AI Agent integration. Use for web-based real-time communication.
npx skillsauth add team-telnyx/telnyx-toolkit telnyx-webrtc-client-jsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Build real-time voice communication into browser applications.
Prerequisites: Create WebRTC credentials and generate a login token using the Telnyx server-side SDK. See the
telnyx-webrtc-*skill in your server language plugin (e.g.,telnyx-python,telnyx-javascript).
npm install @telnyx/webrtc --save
Import the client:
import { TelnyxRTC } from '@telnyx/webrtc';
const client = new TelnyxRTC({
login_token: 'your_jwt_token',
});
client.connect();
const client = new TelnyxRTC({
login: 'sip_username',
password: 'sip_password',
});
client.connect();
Important: Never hardcode credentials in frontend code. Use environment variables or prompt users.
// When done, disconnect and remove listeners
client.disconnect();
client.off('telnyx.ready');
client.off('telnyx.notification');
Specify an HTML element to play remote audio:
client.remoteElement = 'remoteMedia';
HTML:
<audio id="remoteMedia" autoplay="true" />
let activeCall;
client
.on('telnyx.ready', () => {
console.log('Ready to make calls');
})
.on('telnyx.error', (error) => {
console.error('Error:', error);
})
.on('telnyx.notification', (notification) => {
if (notification.type === 'callUpdate') {
activeCall = notification.call;
// Handle incoming call
if (activeCall.state === 'ringing') {
// Show incoming call UI
// Call activeCall.answer() to accept
}
}
});
| Event | Description |
|-------|-------------|
| telnyx.ready | Client connected and ready |
| telnyx.error | Error occurred |
| telnyx.notification | Call updates, incoming calls |
| telnyx.stats.frame | In-call quality metrics (when debug enabled) |
const call = client.newCall({
destinationNumber: '+18004377950',
callerNumber: '+15551234567',
});
client.on('telnyx.notification', (notification) => {
const call = notification.call;
if (notification.type === 'callUpdate' && call.state === 'ringing') {
// Incoming call - show UI and answer
call.answer();
}
});
// End call
call.hangup();
// Send DTMF tones
call.dtmf('1234');
// Mute audio
call.muteAudio();
call.unmuteAudio();
// Hold
call.hold();
call.unhold();
const call = client.newCall({
destinationNumber: '+18004377950',
debug: true,
debugOutput: 'socket', // 'socket' (send to Telnyx) or 'file' (save locally)
});
const call = client.newCall({
destinationNumber: '+18004377950',
debug: true, // Required for metrics
});
client.on('telnyx.stats.frame', (stats) => {
console.log('Quality stats:', stats);
// Contains jitter, RTT, packet loss, etc.
});
Test connectivity before making calls:
import { PreCallDiagnosis } from '@telnyx/webrtc';
PreCallDiagnosis.run({
credentials: {
login: 'sip_username',
password: 'sip_password',
// or: loginToken: 'jwt_token'
},
texMLApplicationNumber: '+12407758982',
})
.then((report) => {
console.log('Diagnosis report:', report);
})
.catch((error) => {
console.error('Diagnosis failed:', error);
});
Set codec preference for calls:
const allCodecs = RTCRtpReceiver.getCapabilities('audio').codecs;
// Prefer Opus for AI/high quality
const opusCodec = allCodecs.find(c =>
c.mimeType.toLowerCase().includes('opus')
);
// Or PCMA for telephony compatibility
const pcmaCodec = allCodecs.find(c =>
c.mimeType.toLowerCase().includes('pcma')
);
client.newCall({
destinationNumber: '+18004377950',
preferred_codecs: [opusCodec],
});
Check if client is registered:
const isRegistered = await client.getIsRegistered();
console.log('Registered:', isRegistered);
Connect to an AI assistant without SIP credentials:
const client = new TelnyxRTC({
anonymous_login: {
target_id: 'your-ai-assistant-id',
target_type: 'ai_assistant',
},
});
client.connect();
Note: The AI assistant must have
telephony_settings.supports_unauthenticated_web_callsset totrue.
// After anonymous login, destinationNumber is ignored
const call = client.newCall({
destinationNumber: '', // Can be empty
remoteElement: 'remoteMedia',
});
const allCodecs = RTCRtpReceiver.getCapabilities('audio').codecs;
const opusCodec = allCodecs.find(c =>
c.mimeType.toLowerCase().includes('opus')
);
client.newCall({
destinationNumber: '',
preferred_codecs: [opusCodec], // Opus recommended for AI
});
| Platform | Chrome | Firefox | Safari | Edge | |----------|--------|---------|--------|------| | Android | ✓ | ✓ | - | - | | iOS | - | - | ✓ | - | | Linux | ✓ | ✓ | - | - | | macOS | ✓ | ✓ | ✓ | ✓ | | Windows | ✓ | ✓ | - | ✓ |
const webRTCInfo = TelnyxRTC.webRTCInfo;
console.log('WebRTC supported:', webRTCInfo.supportWebRTC);
| Issue | Solution |
|-------|----------|
| No audio | Check microphone permissions in browser |
| Echo/feedback | Use headphones or enable echo cancellation |
| Connection fails | Check network, firewall, or use TURN relay |
| Quality issues | Enable debug: true and check telnyx.stats.frame events |
tools
Build cross-platform VoIP calling apps with React Native using Telnyx Voice SDK. High-level reactive API with automatic lifecycle management, CallKit/ConnectionService integration, and push notifications. Use for mobile VoIP apps with minimal setup.
tools
Build VoIP calling apps on iOS using Telnyx WebRTC SDK. Covers authentication, making/receiving calls, CallKit integration, PushKit/APNS push notifications, call quality metrics, and AI Agent integration. Use when implementing real-time voice communication on iOS.
tools
Build cross-platform VoIP calling apps with Flutter using Telnyx WebRTC SDK. Covers authentication, making/receiving calls, push notifications (FCM + APNS), call quality metrics, and AI Agent integration. Works on Android, iOS, and Web.
tools
Build VoIP calling apps on Android using Telnyx WebRTC SDK. Covers authentication, making/receiving calls, push notifications (FCM), call quality metrics, and AI Agent integration. Use when implementing real-time voice communication on Android.