Voice Feed SDK
Connly Voice Feed is a JavaScript SDK that provides real-time call feed data from the Connly platform. It is compatible with both Browser and Node.js environments, enabling seamless integration of live call events, agent status updates, and callback functionalities into your applications. To use this SDK, you will need an access token, which can be generated using the User Access API.
Package Installation
Using NPM
npm install connly-voice-feed
Using YARN
yarn add connly-voice-feed
Browser (UMD)
To use Connly Voice Feed directly in the browser without a bundler, include the UMD build along with socket.io-client:
<script src="https://cdn.jsdelivr.net/npm/socket.io-client@4.8.1/dist/socket.io.js"></script>
<script src="path/to/dist/connly-voice-feed.umd.js"></script>
Import the SDK
In Node.js (ES Modules)
import Connly from 'connly-voice-feed';
In Browser (Using ES6 Modules)
If you are using a framework like ReactJS or VueJS:
import Connly from 'connly-voice-feed';
Class: Connly
The Connly class is the core of the SDK, providing methods to connect to the Connly platform, subscribe to various events, and handle real-time call data.
Constructor
new Connly()
Creates a new instance of the Connly SDK.
Methods
start(token)
Connects to the Connly platform using the provided access token.
You can generate the access token using the User Access API.
const connly = new Connly();
connly.start('your-access-token');
barge(payload)
Performs an action (barge, whisper, or monitor) on an ongoing call.
const payload = {
app_id: 1111112,
call_id: 'leg-uuid',
to: 'supervisor-id',
action: 'barge' // 'barge', 'whisper', or 'monitor'
};
connly.barge(payload);
To handle the barge/monitor request, the supervisor must be logged into the Monipy SDK using the supervisor-id (specified as to in the payload) and their corresponding password.
subscribeCalls()
Subscribes to live call feed events.
connly.subscribeCalls();
monitorCalls()
Subscribes to ongoing call events.
connly.monitorCalls();
subscribeAgents()
Subscribes to agent status and list updates.
connly.subscribeAgents();
removeAllListeners()
Removes all socket event listeners.
connly.removeAllListeners();
Event Callbacks
These are callback functions that can be overridden to handle specific events emitted by the SDK.
onConnect(data)
Triggered when the socket connection is successfully established.
connly.onConnect = (data) => {
console.log('Connected to Connly platform:', data);
connly.subscribeCalls(); // Example: Subscribe to live calls once connected
};
onDisconnect(data)
Triggered when the socket connection is disconnected.
connly.onDisconnect = (data) => {
console.log('Disconnected from Connly platform:', data);
};
onCalls(data)
Triggered when a new call event occurs.
connly.onCalls = (data) => {
console.log('New Call Event:', data);
};
onAgents(data)
Triggered when agent statuses or the agent list is updated.
connly.onAgents = (data) => {
console.log('Agent Updates:', data);
};
onStatus(data)
Triggered on status updates or errors (e.g., invalid token).
connly.onStatus = (data) => {
console.log('Status Update:', data);
};
Response Fields
| Field | Description |
|---|---|
| action | Defines channel property: "ch-c" = channel created, "ch-s" = channel state change, "ch-d" = deleted |
| agent | Agent ID receiving the call |
| group | Team/Group ID handling the call |
| from | Customer's phone number |
| id | Record ID |
| inetno | Your App ID |
| leguid | Customer channel UUID |
| name | Customer name if previously saved |
| uuid | Agent call UUID for call barging |
| state | Current call state: 'early' = ringing, 'answer' = answered, 'bridged' = call established, 'hangup' = call disconnected |