You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
The Wazo JavaScript Software Development Kit is an API wrapper making it easy for you to communicate with your Wazo server. It allows you to add Wazo functionalities to any JavaScript application you are developing.
Usage
Install / Add
You may install the Wazo JavaScript Software Development Kit to your project one of the following ways:
npm install @wazo/sdk
yarn add @wazo/sdk
Content Delivery Networks
Alternatively, you may load the Wazo SDK from a CDN. Use one of the following Content Delivery Networks:
client.auth.logIn({ expiration,// optional integer. Session life in number of seconds. If omitted, defaults to 3600 (an hour). username,// required string password,// required string backend,// optional string. If omitted, defaults to wazo_user}).then(/* undefined if login failed, or : */{metadata:{ username, uuid_tenant_uuid, xivo_user_uuid, groups, xivo_uuid,tenants:[{ uuid}], auth_id}, token,// should be used for other request acls, utc_expires_at, xivo_uuid, issued_at, utc_issued_at, auth_id, expires_at, xivo_user_uuid});// orconstresult=awaitclient.auth.login(/* ... */);
client.application.calls(token,applicationUuid);// list callsclient.application.hangupCall(token,applicationUuid,callId);// hangup a callclient.application.answerCall(token,applicationUuid,callId,context,exten,autoanswer);// answer a callclient.application.listNodes(token,applicationUuid);// list nodesclient.application.listCallsNodes(token,applicationUuid,nodeUuid);// list calls in a nodeclient.application.removeCallNodes(token,applicationUuid,nodeUuid,callId);// remove call from node (no hangup)client.application.addCallNodes(token,applicationUuid,nodeUuid,callId);// add call in a nodeclient.application.playCall(token,applicationUuid,callId,language,uri);// play a sound into a call
import{WazoWebRTCClient}from'@wazo/sdk';constconfig={wsServer:'wss://path.to/asterisk/ws',displayName:'My Display Name',authorizationUser:'line username',password:'line password',uri:'user@server.com',media:{audio:document.getElementById('audio'),// Pointing to a `<audio />` elementvideo:document.getElementById('video'),// optional, pointing to a `<video />` elementlocalVideo:document.getElementById('local-video')// optional, pointing to a `<video />` element}};constphone=newWazoWebRTCClient({displayName:'From WEB',host:'quintana.wazo.community',authorizationUser:lineData.username,password:lineData.secret,media:{audio:boolean|document.getElementById('audio'),// Pointing to a `<audio />` elementvideo:boolean|document.getElementById('video'),// pointing to a `<video />` elementlocalVideo:boolean|document.getElementById('video'),// pointing to a `<video />` element}});// eventName can be on the of events : `connected`, `disconnected`, `registered`, `unregistered`, `registrationFailed`, `invite`, `inviteSent`, `transportCreated`, `newTransaction`, `transactionDestroyed`, `notify`, `outOfDialogReferRequested`, `message`.phone.on('invite',(session:SIP.sessionDescriptionHandler)=>{this.currentSession=session;// ...});// or a wildcard : `*`phone.on('*',(data:mixed,eventName:string)=>{});phone.call('1234');
import{WazoWebSocketClient}from'@wazo/sdk';constws=newWazoWebSocket({ host,// wazo websocket host token,// valid Wazo token});// eventName can be on the of events here: http://documentation.wazo.community/en/stable/api_sdk/websocket.htmlws.on('eventName',(data:mixed)=>{});// You can also use a wildcard to catch all eventsws.on('*',(data:mixed,eventName:string)=>{});ws.connect();