call-control-sdk 5.3.0 → 5.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,265 +1,266 @@
1
- ### Call Control SDK [![npm version](https://img.shields.io/npm/v/call-control-sdk.svg?color=blue)](https://www.npmjs.com/package/call-control-sdk) [![npm downloads](https://img.shields.io/npm/dm/call-control-sdk.svg?color=green)](https://www.npmjs.com/package/call-control-sdk)
2
-
3
- A lightweight SDK that provides a **draggable call control panel** and utility hooks for managing calls in real-time. Built with **TypeScript**, **Material-UI**, and designed for **agent productivity**.
4
-
5
- ### ✨ Features
6
-
7
- - 🎯 **Complete Call Control** – Hold, Mute, Status management, and End Call
8
- - 🖱️ **Draggable Interface** – Movable panel with persisted position
9
- - 💾 **State Persistence** – Saves control states in `localStorage`
10
- - ⏱️ **Live Call Timer** – Real-time call duration tracking
11
- - 🎨 **Material-UI Design** – Responsive and accessible UI
12
- - 📱 **Touch Support** – Works seamlessly on desktop and mobile
13
- - 🔧 **TypeScript Support** – Full type safety and IntelliSense
14
- - 🎪 **Singleton State** – Consistent shared state across components
15
-
16
-
17
-
18
- ### 📦 Installation [![bundle size](https://img.shields.io/bundlephobia/minzip/call-control-sdk?color=orange&fontSize=12px)](https://bundlephobia.com/package/call-control-sdk)
19
-
20
- ```bash
21
- npm install call-control-sdk
22
- ```
23
-
24
- ### 🔑 Peer Dependencies
25
-
26
- ```bash
27
- npm install react react-dom axios @mui/material @mui/icons-material @emotion/react @emotion/styled
28
- ```
29
-
30
- ### 📚 Table of Contents
31
-
32
- 1. [Getting Started](#-getting-started)
33
- 2. [Core API](#-core-api)
34
- - [initSDK](#initsdk)
35
- - [CallControlPanel](#callcontrolpanel)
36
- - [updateCallData](#updatecalldata)
37
- 3. [Hooks](#-hooks)
38
- - [useLogout](#uselogout)
39
- - [useClickToCall](#useClickToCall)
40
- - [useEndCall](#useendcall)
41
- 4. [Payloads](#-payloads)
42
- 5. [Control Features](#-control-features)
43
- 6. [Browser Support](#-browser-support)
44
- 7. [License](#-license)
45
-
46
- ### 🚀 Getting Started
47
-
48
- #### 1. Initialize the SDK
49
-
50
- ```tsx
51
- import { useEffect } from "react";
52
- import { initSDK } from "call-control-sdk";
53
-
54
- // Initialize at the top level of your app
55
- function App() {
56
- useEffect(() => {
57
- // Initialize the SDK.
58
- try {
59
- initSDK({
60
- apiKey: "your-api-key",
61
- tenantId: "your-tenant-id",
62
- agentId: "your-agent-id",
63
- });
64
- console.log("SDK initialized successfully");
65
- } catch (error) {
66
- console.error("SDK initialization failed:", error);
67
- }
68
- }, []);
69
-
70
- return <h1>My App</h1>;
71
- }
72
- ```
73
-
74
- #### 2. Add the Call Control Panel
75
-
76
- ```tsx
77
- import { CallControlPanel } from "call-control-sdk";
78
-
79
- export default function App() {
80
- const handleDataChange = (data) => {
81
- console.log("Call data updated:", data);
82
- };
83
-
84
- return (
85
- <div>
86
- <h1>Agent Dashboard</h1>
87
- <CallControlPanel onDataChange={handleDataChange} />
88
- </div>
89
- );
90
- }
91
- ```
92
-
93
- #### 3. Logout Agent
94
-
95
- ```tsx
96
- import { useLogout } from "call-control-sdk";
97
-
98
- export default function LogoutButton() {
99
- const { logout, isLoading, isSuccess, isError, error } = useLogout();
100
- return <button onClick={logout}>Logout</button>;
101
- }
102
- ```
103
-
104
- #### 4. Start Call
105
-
106
- ```tsx
107
- import { useClickToCall } from "call-control-sdk";
108
-
109
- export default function CallButton() {
110
- const { handleStartCall, isLoading, isSuccess, isError, error } = useClickToCall();
111
-
112
- const onStartCall = () => {
113
- handleStartCall({ mobileNumber: "1111111111" });
114
- };
115
-
116
- return (
117
- <div>
118
- <button onClick={onStartCall} disabled={isLoading}>
119
- { "Call"}
120
- </button>
121
- {isSuccess && <p>✅ Call ended successfully</p>}
122
- {isError && <p>❌ Error: {error?.message}</p>}
123
- </div>
124
- );
125
- }
126
- ```
127
- #### 5. End Call
128
-
129
- ```tsx
130
- import { useEndCall } from "call-control-sdk";
131
-
132
- export default function EndCallButton() {
133
- const { handleEndCall, isLoading, isSuccess, isError, error } = useEndCall();
134
-
135
- const onEndCall = () => {
136
- handleEndCall({
137
- disposition: "RES", // Call disposition
138
- });
139
- };
140
-
141
- return (
142
- <div>
143
- <button onClick={onEndCall} disabled={isLoading}>
144
- {isLoading ? "Ending Call..." : "End Call"}
145
- </button>
146
- {isSuccess && <p>✅ Call ended successfully</p>}
147
- {isError && <p>❌ Error: {error?.message}</p>}
148
- </div>
149
- );
150
- }
151
- ```
152
-
153
- ### 🛠 Core API
154
-
155
- #### `initSDK(config)`
156
-
157
- Initializes the SDK. Must be called **before using any components or hooks**.
158
-
159
- **Parameters**:
160
-
161
- | Name | Type | Required | Description |
162
- | ---------- | ------ | -------- | ----------------------------------- |
163
- | `apiKey` | string | ✅ | API key for authentication |
164
- | `tenantId` | string | ✅ | Tenant ID for events/authentication |
165
- | `agentId` | string | ✅ | Agent ID for call controls |
166
-
167
- #### `CallControlPanel`
168
-
169
- Draggable control panel for call management.
170
-
171
- **Props**:
172
-
173
- | Prop | Type | Required | Description |
174
- | --------------- | -------- | -------- | -------------------------------------------------------------------------------------------------- |
175
- | `onDataChange?` | function | ❌ | Callback fired when call data changes. Receives `{ mobileNumber, callReferenceId, agentLoginId }`. |
176
-
177
- #### `updateCallData(data: Partial<CallData>)`
178
-
179
- Update call data programmatically.
180
-
181
- **Parameters**:
182
-
183
- | Field | Type | Description |
184
- | ------------------ | ------ | ---------------------- |
185
- | `mobileNumber?` | string | Mobile phone number |
186
- | `callReferenceId?` | string | Unique call reference |
187
- | `agentLoginId?` | string | Agent login identifier |
188
-
189
- ### 🪝 Hooks
190
-
191
- #### `useLogout()`
192
-
193
- Logs out the current agent.
194
-
195
- ```tsx
196
- const { logOut } = useLogout();
197
- <button onClick={logOut}>Logout</button>;
198
- ```
199
-
200
- #### `useStartCall()`
201
-
202
- Hook for call to mobile number.
203
-
204
- **Returns**:
205
-
206
- | Key | Type | Description |
207
- | --------------- | -------- | --------------------------------------------------------------- |
208
- | `handleStartCall` | function | `(payload: StartCallPayload) => void` – triggers end-call request |
209
- | `isLoading` | boolean | True while request is pending |
210
- | `isSuccess` | boolean | True if request succeeded |
211
- | `isError` | boolean | True if request failed |
212
- | `error` | any | Error object if failed |
213
- | `data` | any | API response on success |
214
-
215
- #### `useEndCall()`
216
-
217
- Hook for ending an active call.
218
-
219
- **Returns**:
220
-
221
- | Key | Type | Description |
222
- | --------------- | -------- | --------------------------------------------------------------- |
223
- | `handleEndCall` | function | `(payload: EndCallPayload) => void` – triggers end-call request |
224
- | `isLoading` | boolean | True while request is pending |
225
- | `isSuccess` | boolean | True if request succeeded |
226
- | `isError` | boolean | True if request failed |
227
- | `error` | any | Error object if failed |
228
- | `data` | any | API response on success |
229
-
230
- ### 📦 Payloads
231
-
232
- #### `StartCallPayload`
233
-
234
- ```ts
235
- interface EndCallPayload {
236
- mobileNumber?: string; // Mobile number
237
- }
238
- ```
239
-
240
- #### `EndCallPayload`
241
-
242
- ```ts
243
- interface EndCallPayload {
244
- disposition?: string; // Call disposition (default: "RES")
245
- }
246
- ```
247
-
248
- ### 🎛 Control Features
249
-
250
- **Status Management**: Idle / Break
251
- **Call Controls**: Hold / Resume, Mute / Unmute, End Call, Agent Status
252
- **Persistent State**: Hold, mute, agent status, panel position, call timer
253
-
254
- ### 🌍 Browser Support
255
-
256
- ✅ Chrome 60+
257
- ✅ Firefox 60+
258
- ✅ Safari 12+
259
- ✅ Edge 79+
260
-
261
- ---
262
-
263
- ### 📄 License
264
-
265
- MIT © 2025 [![license](https://img.shields.io/npm/l/call-control-sdk.svg)](#-license)
1
+ ### Call Control SDK [![npm version](https://img.shields.io/npm/v/call-control-sdk.svg?color=blue)](https://www.npmjs.com/package/call-control-sdk) [![npm downloads](https://img.shields.io/npm/dm/call-control-sdk.svg?color=green)](https://www.npmjs.com/package/call-control-sdk)
2
+
3
+ A lightweight SDK that provides a **draggable call control panel** and utility hooks for managing calls in real-time. Built with **TypeScript**, **Material-UI**, and designed for **agent productivity**.
4
+
5
+ ### ✨ Features
6
+
7
+ - 🎯 **Complete Call Control** – Hold, Mute, Status management, and End Call
8
+ - 🖱️ **Draggable Interface** – Movable panel with persisted position
9
+ - 💾 **State Persistence** – Saves control states in `localStorage`
10
+ - ⏱️ **Live Call Timer** – Real-time call duration tracking
11
+ - 🎨 **Material-UI Design** – Responsive and accessible UI
12
+ - 📱 **Touch Support** – Works seamlessly on desktop and mobile
13
+ - 🔧 **TypeScript Support** – Full type safety and IntelliSense
14
+ - 🎪 **Singleton State** – Consistent shared state across components
15
+
16
+
17
+
18
+ ### 📦 Installation [![bundle size](https://img.shields.io/bundlephobia/minzip/call-control-sdk?color=orange&fontSize=12px)](https://bundlephobia.com/package/call-control-sdk)
19
+
20
+ ```bash
21
+ npm install call-control-sdk
22
+ ```
23
+
24
+ ### 🔑 Peer Dependencies
25
+
26
+ ```bash
27
+ npm install react react-dom axios @mui/material @mui/icons-material @emotion/react @emotion/styled
28
+ ```
29
+
30
+ ### 📚 Table of Contents
31
+
32
+ 1. [Getting Started](#-getting-started)
33
+ 2. [Core API](#-core-api)
34
+ - [initSDK](#initsdk)
35
+ - [CallControlPanel](#callcontrolpanel)
36
+ - [updateCallData](#updatecalldata)
37
+ 3. [Hooks](#-hooks)
38
+ - [useLogout](#uselogout)
39
+ - [useClickToCall](#useClickToCall)
40
+ - [useEndCall](#useendcall)
41
+ 4. [Payloads](#-payloads)
42
+ 5. [Control Features](#-control-features)
43
+ 6. [Browser Support](#-browser-support)
44
+ 7. [License](#-license)
45
+
46
+ ### 🚀 Getting Started
47
+
48
+ #### 1. Initialize the SDK
49
+
50
+ ```tsx
51
+ import { useEffect } from "react";
52
+ import { initSDK } from "call-control-sdk";
53
+
54
+ // Initialize at the top level of your app
55
+ function App() {
56
+ useEffect(() => {
57
+ // Initialize the SDK.
58
+ try {
59
+ initSDK({
60
+ apiKey: "your-api-key",
61
+ tenantId: "your-tenant-id",
62
+ agentId: "your-agent-id",
63
+ });
64
+ console.log("SDK initialized successfully");
65
+ } catch (error) {
66
+ console.error("SDK initialization failed:", error);
67
+ }
68
+ }, []);
69
+
70
+ return <h1>My App</h1>;
71
+ }
72
+ ```
73
+
74
+ #### 2. Add the Call Control Panel
75
+
76
+ ```tsx
77
+ import { CallControlPanel } from "call-control-sdk";
78
+
79
+ export default function App() {
80
+ const handleDataChange = (data) => {
81
+ console.log("Call data updated:", data);
82
+ };
83
+
84
+ return (
85
+ <div>
86
+ <h1>Agent Dashboard</h1>
87
+ <CallControlPanel onDataChange={handleDataChange} />
88
+ </div>
89
+ );
90
+ }
91
+ ```
92
+
93
+ #### 3. Logout Agent
94
+
95
+ ```tsx
96
+ import { useLogout } from "call-control-sdk";
97
+
98
+ export default function LogoutButton() {
99
+ const { logout, isLoading, isSuccess, isError, error } = useLogout();
100
+ return <button onClick={logout}>Logout</button>;
101
+ }
102
+ ```
103
+
104
+ #### 4. Start Call
105
+
106
+ ```tsx
107
+ import { useClickToCall } from "call-control-sdk";
108
+
109
+ export default function CallButton() {
110
+ const { handleStartCall, isLoading, isSuccess, isError, error } = useClickToCall();
111
+
112
+ const onStartCall = () => {
113
+ handleStartCall({ mobileNumber: "1111111111" });
114
+ };
115
+
116
+ return (
117
+ <div>
118
+ <button onClick={onStartCall} disabled={isLoading}>
119
+ { "Call"}
120
+ </button>
121
+ {isSuccess && <p>✅ Call ended successfully</p>}
122
+ {isError && <p>❌ Error: {error?.message}</p>}
123
+ </div>
124
+ );
125
+ }
126
+ ```
127
+ #### 5. End Call
128
+
129
+ ```tsx
130
+ import { useEndCall } from "call-control-sdk";
131
+
132
+ export default function EndCallButton() {
133
+ const { handleEndCall, isLoading, isSuccess, isError, error } = useEndCall();
134
+
135
+ const onEndCall = () => {
136
+ handleEndCall({
137
+ disposition: "RES", // Call disposition
138
+ });
139
+ };
140
+
141
+ return (
142
+ <div>
143
+ <button onClick={onEndCall} disabled={isLoading}>
144
+ {isLoading ? "Ending Call..." : "End Call"}
145
+ </button>
146
+ {isSuccess && <p>✅ Call ended successfully</p>}
147
+ {isError && <p>❌ Error: {error?.message}</p>}
148
+ </div>
149
+ );
150
+ }
151
+ ```
152
+
153
+ ### 🛠 Core API
154
+
155
+ #### `initSDK(config)`
156
+
157
+ Initializes the SDK. Must be called **before using any components or hooks**.
158
+
159
+ **Parameters**:
160
+
161
+ | Name | Type | Required | Description |
162
+ | ---------- | ------ | -------- | ----------------------------------- |
163
+ | `apiKey` | string | ✅ | API key for authentication |
164
+ | `tenantId` | string | ✅ | Tenant ID for events/authentication |
165
+ | `agentId` | string | ✅ | Agent ID for call controls |
166
+
167
+ #### `CallControlPanel`
168
+
169
+ Draggable control panel for call management.
170
+
171
+ **Props**:
172
+
173
+ | Prop | Type | Required | Description |
174
+ | --------------- | -------- | -------- | -------------------------------------------------------------------------------------------------- |
175
+ | `onDataChange?` | function | ❌ | Callback fired when call data changes. Receives `{ mobileNumber, callReferenceId, agentLoginId }`. |
176
+
177
+ #### `updateCallData(data: Partial<CallData>)`
178
+
179
+ Update call data programmatically.
180
+
181
+ **Parameters**:
182
+
183
+ | Field | Type | Description |
184
+ | ------------------ | ------ | ---------------------- |
185
+ | `mobileNumber?` | string | Mobile phone number |
186
+ | `callReferenceId?` | string | Unique call reference |
187
+ | `agentLoginId?` | string | Agent login identifier |
188
+
189
+ ### 🪝 Hooks
190
+
191
+ #### `useLogout()`
192
+
193
+ Logs out the current agent.
194
+
195
+ ```tsx
196
+ const { logOut } = useLogout();
197
+ <button onClick={logOut}>Logout</button>;
198
+ ```
199
+
200
+ #### `useStartCall()`
201
+
202
+ Hook for call to mobile number.
203
+
204
+ **Returns**:
205
+
206
+ | Key | Type | Description |
207
+ | --------------- | -------- | --------------------------------------------------------------- |
208
+ | `handleStartCall` | function | `(payload: StartCallPayload) => void` – triggers end-call request |
209
+ | `isLoading` | boolean | True while request is pending |
210
+ | `isSuccess` | boolean | True if request succeeded |
211
+ | `isError` | boolean | True if request failed |
212
+ | `error` | any | Error object if failed |
213
+ | `data` | any | API response on success |
214
+
215
+ #### `useEndCall()`
216
+
217
+ Hook for ending an active call.
218
+
219
+ **Returns**:
220
+
221
+ | Key | Type | Description |
222
+ | --------------- | -------- | --------------------------------------------------------------- |
223
+ | `handleEndCall` | function | `(payload: EndCallPayload) => void` – triggers end-call request |
224
+ | `isLoading` | boolean | True while request is pending |
225
+ | `isSuccess` | boolean | True if request succeeded |
226
+ | `isError` | boolean | True if request failed |
227
+ | `error` | any | Error object if failed |
228
+ | `data` | any | API response on success |
229
+
230
+ ### 📦 Payloads
231
+
232
+ #### `StartCallPayload`
233
+
234
+ ```ts
235
+ interface EndCallPayload {
236
+ mobileNumber?: string; // Mobile number
237
+ }
238
+ ```
239
+
240
+ #### `EndCallPayload`
241
+
242
+ ```ts
243
+ interface EndCallPayload {
244
+ disposition?: string; // Call disposition (default: "RES")
245
+ }
246
+ ```
247
+
248
+ ### 🎛 Control Features
249
+
250
+ **Status Management**: Idle / Break
251
+ **Call Controls**: Hold / Resume, Mute / Unmute, End Call, Agent Status
252
+ **Persistent State**: Hold, mute, agent status, panel position, call timer
253
+
254
+ ### 🌍 Browser Support
255
+
256
+ . ✅ Chrome 60+
257
+ . ✅ Firefox 60+
258
+ . ✅ Safari 12+
259
+ . ✅ Edge 79+
260
+
261
+
262
+ ---
263
+
264
+ ### 📄 License
265
+
266
+ MIT © 2025 [![license](https://img.shields.io/npm/l/call-control-sdk.svg)](#-license)
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SxProps } from '@mui/material';
1
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
 
3
4
  /**
@@ -34,25 +35,6 @@ declare const useEndCall: () => {
34
35
  data: null;
35
36
  };
36
37
 
37
- interface StartCallPayload {
38
- mobileNumber: string;
39
- }
40
- /**
41
- * Custom hook for handling end call functionality
42
- * @param options - Optional callbacks for success, error, and completion
43
- * @returns Object containing logout function and loading state
44
- * @example
45
- * handleStartCall({ mobileNumber: "1111111111" });
46
- */
47
- declare const useClickToCall: () => {
48
- handleStartCall: (data: StartCallPayload) => Promise<any>;
49
- isLoading: boolean;
50
- isSuccess: boolean;
51
- isError: boolean;
52
- error: null;
53
- data: null;
54
- };
55
-
56
38
  interface CallData {
57
39
  mobileNumber?: string;
58
40
  callReferenceId?: string;
@@ -70,6 +52,14 @@ interface CallControlPanelProps {
70
52
  onDataChange?: (data: any) => void;
71
53
  }
72
54
  type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
55
+ interface SDKConfig {
56
+ showEndCallButton?: boolean;
57
+ showTransferButton?: boolean;
58
+ showConferenceButton?: boolean;
59
+ disabled?: SxProps;
60
+ enabled?: SxProps;
61
+ outlined?: SxProps;
62
+ }
73
63
 
74
64
  declare function CallControlPanel({ onDataChange }: CallControlPanelProps): react_jsx_runtime.JSX.Element;
75
65
 
@@ -82,7 +72,8 @@ type intiSDKParams = {
82
72
  apiKey: string;
83
73
  tenantId: string;
84
74
  agentId: string;
75
+ sdkConfig?: SDKConfig;
85
76
  };
86
- declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
77
+ declare function initSDK({ apiKey, tenantId, agentId, sdkConfig, }: intiSDKParams): void;
87
78
 
88
- export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useClickToCall, useEndCall, useLogout };
79
+ export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useEndCall, useLogout };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SxProps } from '@mui/material';
1
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
 
3
4
  /**
@@ -34,25 +35,6 @@ declare const useEndCall: () => {
34
35
  data: null;
35
36
  };
36
37
 
37
- interface StartCallPayload {
38
- mobileNumber: string;
39
- }
40
- /**
41
- * Custom hook for handling end call functionality
42
- * @param options - Optional callbacks for success, error, and completion
43
- * @returns Object containing logout function and loading state
44
- * @example
45
- * handleStartCall({ mobileNumber: "1111111111" });
46
- */
47
- declare const useClickToCall: () => {
48
- handleStartCall: (data: StartCallPayload) => Promise<any>;
49
- isLoading: boolean;
50
- isSuccess: boolean;
51
- isError: boolean;
52
- error: null;
53
- data: null;
54
- };
55
-
56
38
  interface CallData {
57
39
  mobileNumber?: string;
58
40
  callReferenceId?: string;
@@ -70,6 +52,14 @@ interface CallControlPanelProps {
70
52
  onDataChange?: (data: any) => void;
71
53
  }
72
54
  type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
55
+ interface SDKConfig {
56
+ showEndCallButton?: boolean;
57
+ showTransferButton?: boolean;
58
+ showConferenceButton?: boolean;
59
+ disabled?: SxProps;
60
+ enabled?: SxProps;
61
+ outlined?: SxProps;
62
+ }
73
63
 
74
64
  declare function CallControlPanel({ onDataChange }: CallControlPanelProps): react_jsx_runtime.JSX.Element;
75
65
 
@@ -82,7 +72,8 @@ type intiSDKParams = {
82
72
  apiKey: string;
83
73
  tenantId: string;
84
74
  agentId: string;
75
+ sdkConfig?: SDKConfig;
85
76
  };
86
- declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
77
+ declare function initSDK({ apiKey, tenantId, agentId, sdkConfig, }: intiSDKParams): void;
87
78
 
88
- export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useClickToCall, useEndCall, useLogout };
79
+ export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useEndCall, useLogout };