workano-js-sdk
v0.1.7
Published
Workano Communications SDK
Downloads
189
Maintainers
Readme
Workano JS SDK
Workano JavaScript SDK is a simplified solution for communication
Installation
npm i workano-js-sdk
Auth module
Login
import workano from "workano-js-sdk";
...
const session = await workano.Auth.login({
server:"",
username:"",
password:"",
appId:"",
tokenExpiration:1000,
isMobile: false,
onTokenRefreshed:()=>{
}
});
...
Validate Token
import workano from "workano-js-sdk";
...
const session = await workano.Auth.validateToken({
server,
token,
refreshToken,
appId,
onTokenRefreshed(newSession) {
setSession(newSession);
},
tokenExpiration,
isMobile: false,
});
...
Logout:
import workano from "workano-js-sdk";
...
const session = await workano.Auth.logout();
...
Phone:
import workano from "workano-js-sdk";
...
//in page load:
await workano.Phone.connect({
onIncomingCall,
onCallAccepted,
onCallAnswered,
onCallCanceled,
onCallCreated,
onCallEnded,
onCallFailed,
onCallUpdated,
...
});
...
workano.Phone.call("your number", withVideo);
...
User
Get Extensions
import workano from "workano-js-sdk";
...
const availableNumbers = await workano.User.getExtensions();
// [
// {
// "context": "default",
// "contextLabel": "Default Context",
// "numbers": ["1001", "1002", "1003"]
// },
// {
// "context": "webrtc",
// "contextLabel": "WebRTC Context",
// "numbers": ["2001", "2002"]
// }
// ]
...
Add User
import workano from "workano-js-sdk";
const user = {
subscription_type: 1, // 0: Normal, 1: Integrated Phone System, 2: Meeting, 3: Call Center
firstname: "Jane",
lastname: "Smith",
firstname_english: "Jane",
lastname_english: "Smith",
language: "en_US",
mobile_phone_number: "0987654321",
email: "[email protected]",
password: "securepassword",
lines: [
{
extensions: [
{
context: "default",
exten: "1004",
},
],
},
],
};
...
const newUser = await workano.User.addUser(user);
...
List Call Logs
import workano from "workano-js-sdk";
...
const offset = 0;
const limit = 20; // Number of call logs to retrieve
const callLogs = await workano.Logs.listCallLogs(offset, limit);
...