1.4.1 • Published 7 months ago

connly-voice-feed v1.4.1

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

Connly Voice Feed

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.

📦 Installation

You can install Connly Voice Feed using npm or yarn.

npm

npm install connly-voice-feed

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>

🔧 Importing 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';

🛠 API Reference with Examples

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.

const connly = new Connly();
connly.start('your-access-token');

barge(uuid, to)

Barges into an ongoing call using the call's UUID and the supervisor's ID.

const CALL_UUID = 'example-uuid';
const SUPERVISOR_ID = 'supervisor-id';
connly.barge(CALL_UUID, SUPERVISOR_ID);

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 Handlers (With Examples)

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);
    console.log(`Caller: ${data.from}, Agent: ${data.agent}, UUID: ${data.uuid}`);
};

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);
};

onCount(data)

Triggered on incoming call count updates.

connly.onCount = (data) => {
    console.log('Incoming Call Count:', data);
};

onagentAnswer(data)

Triggered when an agent answers a call.

connly.onagentAnswer = (data) => {
    console.log('Agent Answered Call:', data);
};

onAnswer(data)

Triggered when a customer answers a call.

connly.onAnswer = (data) => {
    console.log('Customer Answered Call:', data);
};

onCallback(data)

Triggered when a callback event occurs.

connly.onCallback = (data) => {
    console.log('Callback Event:', data);
};

📄 Response Fields

FieldDescription
actionDefines channel property: "ch-c" = channel created, "ch-s" = channel state change (e.g., early, answer), "ch-d" = deleted
agentAgent ID receiving the call
groupTeam/Group ID handling the call
fromCustomer's phone number
idRecord ID
inetnoYour App ID
leguidCustomer channel UUID
nameCustomer name if previously saved
uuidAgent call UUID for call barging
stateCurrent call state: 'early' = ringing, 'answer' = answered, 'bridged' = call established, 'hangup' = call disconnected

🔗 Repository

🐛 Issues

If you encounter any issues or have suggestions, please open an issue on our GitHub Issues.

1.4.1

7 months ago

1.4.0

7 months ago