Skip to main content
telnyx-webrtc-client-js 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.
الانتقال إلى التثبيت سوق المهارات اكتشف واستكشف مهارات الذكاء الاصطناعي التي بناها المجتمع.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
نسخ Promptعرض تفاصيل Prompt يتجاوز الأمر المباشر Prompt المخصّص للمراجعة. افحص المصدر قبل تشغيله.
npx skills add https://github.com/team-telnyx/telnyx-toolkit --skill telnyx-webrtc-client-jsيبقى الأمر في سطر واحد. مرّر أفقيًا لمراجعته كاملًا قبل النسخ.
تفضّل نسخة محلية؟ نزّل الملفات المتاحة حاليًا لدى SkillsMP.
تحميل Zip جاري التحميل... المزيد من هذا المستودع Complete Telnyx toolkit — ready-to-use tools (STT, TTS, RAG, Networking, 10DLC) plus SDK documentation for JavaScript, Python, Go, Java, and Ruby.
Automated Telnyx bot account signup via challenge-response
Track agent activities using the Telnyx AI Missions API. Use this skill when executing multi-step tasks that should be logged and tracked. Supports creating voice/SMS agents, scheduling calls, and retrieving conversation insights. Use when tasks involve calling people, sending SMS, or any substantial tracked work.
المهن ذات الصلة SOC
استنادا إلى تصنيف SOC المهني
name telnyx-webrtc-client-js description 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. metadata {"author":"telnyx","product":"webrtc","language":"javascript","platform":"browser"}
Telnyx WebRTC - JavaScript SDK
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).
Installation
npm install @telnyx/webrtc --save
Import the client:
import { TelnyxRTC } from '@telnyx/webrtc' ;
Authentication
Option 1: Token-Based (Recommended)
const client = new TelnyxRTC ({
login_token : 'your_jwt_token' ,
});
client.connect ();
Option 2: Credential-Based
const client = ({
: ,
: ,
});
client. ();
new
TelnyxRTC
login
'sip_username'
password
'sip_password'
connect
Important : Never hardcode credentials in frontend code. Use environment variables or prompt users.
Disconnect
client.disconnect ();
client.off ('telnyx.ready' );
client.off ('telnyx.notification' );
Media Elements Specify an HTML element to play remote audio:
client.remoteElement = 'remoteMedia' ;
<audio id ="remoteMedia" autoplay ="true" />
Events 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 ;
if (activeCall.state === 'ringing' ) {
}
}
});
Event Types Event Description telnyx.readyClient connected and ready telnyx.errorError occurred telnyx.notificationCall updates, incoming calls telnyx.stats.frameIn-call quality metrics (when debug enabled)
Making Calls const call = client.newCall ({
destinationNumber : '+18004377950' ,
callerNumber : '+15551234567' ,
});
Receiving Calls client.on ('telnyx.notification' , (notification ) => {
const call = notification.call ;
if (notification.type === 'callUpdate' && call.state === 'ringing' ) {
call.answer ();
}
});
Call Controls
call.hangup ();
call.dtmf ('1234' );
call.muteAudio ();
call.unmuteAudio ();
call.hold ();
call.unhold ();
Debugging & Call Quality
Enable Debug Logging const call = client.newCall ({
destinationNumber : '+18004377950' ,
debug : true ,
debugOutput : 'socket' ,
});
In-Call Quality Metrics const call = client.newCall ({
destinationNumber : '+18004377950' ,
debug : true ,
});
client.on ('telnyx.stats.frame' , (stats ) => {
console .log ('Quality stats:' , stats);
});
Pre-Call Diagnosis Test connectivity before making calls:
import { PreCallDiagnosis } from '@telnyx/webrtc' ;
PreCallDiagnosis .run ({
credentials : {
login : 'sip_username' ,
password : 'sip_password' ,
},
texMLApplicationNumber : '+12407758982' ,
})
.then ((report ) => {
console .log ('Diagnosis report:' , report);
})
.catch ((error ) => {
console .error ('Diagnosis failed:' , error);
});
Preferred Codecs Set codec preference for calls:
const allCodecs = RTCRtpReceiver .getCapabilities ('audio' ).codecs ;
const opusCodec = allCodecs.find (c =>
c.mimeType .toLowerCase ().includes ('opus' )
);
const pcmaCodec = allCodecs.find (c =>
c.mimeType .toLowerCase ().includes ('pcma' )
);
client.newCall ({
destinationNumber : '+18004377950' ,
preferred_codecs : [opusCodec],
});
Registration State Check if client is registered:
const isRegistered = await client.getIsRegistered ();
console .log ('Registered:' , isRegistered);
AI Agent Integration
Anonymous Login 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_calls set to true.
Make Call to AI Assistant
const call = client.newCall ({
destinationNumber : '' ,
remoteElement : 'remoteMedia' ,
});
Recommended Codec for AI const allCodecs = RTCRtpReceiver .getCapabilities ('audio' ).codecs ;
const opusCodec = allCodecs.find (c =>
c.mimeType .toLowerCase ().includes ('opus' )
);
client.newCall ({
destinationNumber : '' ,
preferred_codecs : [opusCodec],
});
Browser Support Platform Chrome Firefox Safari Edge Android ✓ ✓ - - iOS - - ✓ - Linux ✓ ✓ - - macOS ✓ ✓ ✓ ✓ Windows ✓ ✓ - ✓
Check Browser Support const webRTCInfo = TelnyxRTC .webRTCInfo ;
console .log ('WebRTC supported:' , webRTCInfo.supportWebRTC );
Troubleshooting 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
Resources