call-control-sdk 5.2.1 → 5.2.3
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 +174 -125
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,208 +1,257 @@
|
|
|
1
|
-
# Call Control SDK
|
|
1
|
+
# 📞 Call Control SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/call-control-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/call-control-sdk)
|
|
5
|
+
[](https://bundlephobia.com/package/call-control-sdk)
|
|
6
|
+
[](#-license)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
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**.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🎥 Demo Preview
|
|
13
|
+
|
|
14
|
+
<img src="https://raw.githubusercontent.com/your-repo/demo.gif" alt="Call Control SDK Demo" width="600" />
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ✨ Features
|
|
19
|
+
|
|
20
|
+
- 🎯 **Complete Call Control** – Hold, Mute, Status management, and End Call
|
|
21
|
+
- 🖱️ **Draggable Interface** – Movable panel with persisted position
|
|
22
|
+
- 💾 **State Persistence** – Saves control states in `localStorage`
|
|
23
|
+
- ⏱️ **Live Call Timer** – Real-time call duration tracking
|
|
24
|
+
- 🎨 **Material-UI Design** – Responsive and accessible UI
|
|
25
|
+
- 📱 **Touch Support** – Works seamlessly on desktop and mobile
|
|
26
|
+
- 🔧 **TypeScript Support** – Full type safety and IntelliSense
|
|
27
|
+
- 🎪 **Singleton State** – Consistent shared state across components
|
|
28
|
+
|
|
29
|
+
---
|
|
15
30
|
|
|
16
|
-
## Installation
|
|
31
|
+
## 📦 Installation
|
|
17
32
|
|
|
18
33
|
```bash
|
|
19
34
|
npm install call-control-sdk
|
|
20
35
|
```
|
|
21
36
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Make sure you have these installed in your application:
|
|
37
|
+
### 🔑 Peer Dependencies
|
|
25
38
|
|
|
26
39
|
```bash
|
|
27
40
|
npm install react react-dom axios @mui/material @mui/icons-material @emotion/react @emotion/styled
|
|
28
41
|
```
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 📚 Table of Contents
|
|
46
|
+
|
|
47
|
+
1. [Getting Started](#-getting-started)
|
|
48
|
+
2. [Core API](#-core-api)
|
|
49
|
+
- [initSDK](#initsdk)
|
|
50
|
+
- [CallControlPanel](#callcontrolpanel)
|
|
51
|
+
- [updateCallData](#updatecalldata)
|
|
52
|
+
3. [Hooks](#-hooks)
|
|
53
|
+
- [useLogout](#uselogout)
|
|
54
|
+
- [useEndCall](#useendcall)
|
|
55
|
+
4. [Payloads](#-payloads)
|
|
56
|
+
5. [Control Features](#-control-features)
|
|
57
|
+
6. [Browser Support](#-browser-support)
|
|
58
|
+
7. [License](#-license)
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🚀 Getting Started
|
|
31
63
|
|
|
32
64
|
### 1. Initialize the SDK
|
|
33
65
|
|
|
34
|
-
```
|
|
66
|
+
```tsx
|
|
67
|
+
import { useEffect } from "react";
|
|
35
68
|
import { initSDK } from "call-control-sdk";
|
|
36
69
|
|
|
37
70
|
// Initialize at the top level of your app
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
71
|
+
function App() {
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
// Initialize the SDK.
|
|
74
|
+
try {
|
|
75
|
+
initSDK({
|
|
76
|
+
apiKey: "your-api-key",
|
|
77
|
+
tenantId: "your-tenant-id",
|
|
78
|
+
agentId: "your-agent-id",
|
|
79
|
+
});
|
|
80
|
+
console.log("SDK initialized successfully");
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("SDK initialization failed:", error);
|
|
83
|
+
}
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
return <h1>My App</h1>;
|
|
87
|
+
}
|
|
51
88
|
```
|
|
52
89
|
|
|
53
|
-
|
|
90
|
+
---
|
|
54
91
|
|
|
55
|
-
|
|
56
|
-
import React from 'react';
|
|
57
|
-
import { CallControlPanel } from 'call-control-sdk';
|
|
92
|
+
### 2. Add the Call Control Panel
|
|
58
93
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
94
|
+
```tsx
|
|
95
|
+
import { CallControlPanel } from "call-control-sdk";
|
|
96
|
+
|
|
97
|
+
export default function App() {
|
|
98
|
+
const handleDataChange = (data) => {
|
|
99
|
+
console.log("Call data updated:", data);
|
|
62
100
|
};
|
|
63
101
|
|
|
64
102
|
return (
|
|
65
103
|
<div>
|
|
66
|
-
<h1>
|
|
104
|
+
<h1>Agent Dashboard</h1>
|
|
67
105
|
<CallControlPanel onDataChange={handleDataChange} />
|
|
68
106
|
</div>
|
|
69
107
|
);
|
|
70
108
|
}
|
|
71
109
|
```
|
|
72
110
|
|
|
73
|
-
|
|
111
|
+
---
|
|
74
112
|
|
|
75
|
-
|
|
76
|
-
import React from 'react';
|
|
77
|
-
import { useLogout } from 'call-control-sdk';
|
|
113
|
+
### 3. Logout Agent
|
|
78
114
|
|
|
79
|
-
|
|
115
|
+
```tsx
|
|
116
|
+
import { useLogout } from "call-control-sdk";
|
|
80
117
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
118
|
+
export default function LogoutButton() {
|
|
119
|
+
const { logout, isLoading, isSuccess, isError, error } = useLogout();
|
|
120
|
+
return <button onClick={logout}>Logout</button>;
|
|
86
121
|
}
|
|
87
122
|
```
|
|
88
123
|
|
|
89
|
-
|
|
124
|
+
---
|
|
90
125
|
|
|
91
|
-
### 4.
|
|
126
|
+
### 4. End Call
|
|
92
127
|
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
import { useEndCall } from "call-control-sdk";
|
|
128
|
+
```tsx
|
|
129
|
+
import { useEndCall } from "call-control-sdk";
|
|
96
130
|
|
|
97
|
-
|
|
98
|
-
|
|
131
|
+
export default function EndCallButton() {
|
|
132
|
+
const { handleEndCall, isLoading, isSuccess, isError, error } = useEndCall();
|
|
99
133
|
|
|
100
|
-
|
|
101
|
-
|
|
134
|
+
const onEndCall = () => {
|
|
135
|
+
handleEndCall({
|
|
102
136
|
disposition: "RES", // Call disposition
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<div>
|
|
142
|
+
<button onClick={onEndCall} disabled={isLoading}>
|
|
143
|
+
{isLoading ? "Ending Call..." : "End Call"}
|
|
144
|
+
</button>
|
|
145
|
+
{isSuccess && <p>✅ Call ended successfully</p>}
|
|
146
|
+
{isError && <p>❌ Error: {error?.message}</p>}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
112
150
|
```
|
|
113
151
|
|
|
114
|
-
|
|
115
|
-
It manages the API request, state (`loading`, `success`, `error`), and automatically resets the call
|
|
116
|
-
state when a call ends.
|
|
152
|
+
---
|
|
117
153
|
|
|
118
|
-
##
|
|
154
|
+
## 🛠 Core API
|
|
119
155
|
|
|
120
|
-
### `
|
|
156
|
+
### `initSDK(config)`
|
|
121
157
|
|
|
122
|
-
|
|
158
|
+
Initializes the SDK. Must be called **before using any components or hooks**.
|
|
123
159
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
**Parameters**:
|
|
161
|
+
|
|
162
|
+
| Name | Type | Required | Description |
|
|
163
|
+
| ---------- | ------ | -------- | ----------------------------------- |
|
|
164
|
+
| `apiKey` | string | ✅ | API key for authentication |
|
|
165
|
+
| `tenantId` | string | ✅ | Tenant ID for events/authentication |
|
|
166
|
+
| `agentId` | string | ✅ | Agent ID for call controls |
|
|
130
167
|
|
|
131
168
|
---
|
|
132
169
|
|
|
133
|
-
|
|
170
|
+
### `CallControlPanel`
|
|
134
171
|
|
|
135
|
-
|
|
172
|
+
Draggable control panel for call management.
|
|
136
173
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
174
|
+
**Props**:
|
|
175
|
+
|
|
176
|
+
| Prop | Type | Required | Description |
|
|
177
|
+
| --------------- | -------- | -------- | -------------------------------------------------------------------------------------------------- |
|
|
178
|
+
| `onDataChange?` | function | ❌ | Callback fired when call data changes. Receives `{ mobileNumber, callReferenceId, agentLoginId }`. |
|
|
179
|
+
|
|
180
|
+
---
|
|
142
181
|
|
|
143
|
-
|
|
182
|
+
### `updateCallData(data: Partial<CallData>)`
|
|
144
183
|
|
|
145
|
-
|
|
184
|
+
Update call data programmatically.
|
|
146
185
|
|
|
147
|
-
|
|
186
|
+
**Parameters**:
|
|
148
187
|
|
|
149
|
-
|
|
188
|
+
| Field | Type | Description |
|
|
189
|
+
| ------------------ | ------ | ---------------------- |
|
|
190
|
+
| `mobileNumber?` | string | Mobile phone number |
|
|
191
|
+
| `callReferenceId?` | string | Unique call reference |
|
|
192
|
+
| `agentLoginId?` | string | Agent login identifier |
|
|
150
193
|
|
|
151
|
-
|
|
152
|
-
- `tenantId` (string): Your Tenant Id key for Events authentication
|
|
153
|
-
- `agentId` (string): Agent Id for access call controls
|
|
194
|
+
---
|
|
154
195
|
|
|
155
|
-
|
|
196
|
+
## 🪝 Hooks
|
|
156
197
|
|
|
157
|
-
### `
|
|
198
|
+
### `useLogout()`
|
|
158
199
|
|
|
159
|
-
|
|
200
|
+
Logs out the current agent.
|
|
160
201
|
|
|
161
|
-
|
|
202
|
+
```tsx
|
|
203
|
+
const { logOut } = useLogout();
|
|
204
|
+
<button onClick={logOut}>Logout</button>;
|
|
205
|
+
```
|
|
162
206
|
|
|
163
|
-
|
|
164
|
-
- Parameters: `{ mobileNumber: string, callReferenceId: string, agentLoginId: string }`
|
|
207
|
+
---
|
|
165
208
|
|
|
166
|
-
### `
|
|
209
|
+
### `useEndCall()`
|
|
167
210
|
|
|
168
|
-
|
|
211
|
+
Hook for ending an active call.
|
|
169
212
|
|
|
170
|
-
**
|
|
213
|
+
**Returns**:
|
|
171
214
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
215
|
+
| Key | Type | Description |
|
|
216
|
+
| --------------- | -------- | --------------------------------------------------------------- |
|
|
217
|
+
| `handleEndCall` | function | `(payload: EndCallPayload) => void` – triggers end-call request |
|
|
218
|
+
| `isLoading` | boolean | True while request is pending |
|
|
219
|
+
| `isSuccess` | boolean | True if request succeeded |
|
|
220
|
+
| `isError` | boolean | True if request failed |
|
|
221
|
+
| `error` | any | Error object if failed |
|
|
222
|
+
| `data` | any | API response on success |
|
|
175
223
|
|
|
176
|
-
|
|
224
|
+
---
|
|
177
225
|
|
|
178
|
-
|
|
226
|
+
## 📦 Payloads
|
|
179
227
|
|
|
180
|
-
|
|
181
|
-
- **Break**: Agent is on break
|
|
228
|
+
### `EndCallPayload`
|
|
182
229
|
|
|
183
|
-
|
|
230
|
+
```ts
|
|
231
|
+
interface EndCallPayload {
|
|
232
|
+
disposition?: string; // Call disposition (default: "RES")
|
|
233
|
+
}
|
|
234
|
+
```
|
|
184
235
|
|
|
185
|
-
|
|
186
|
-
- **Mute/Unmute**: Toggle microphone
|
|
187
|
-
- **End Call**: Terminate active call
|
|
188
|
-
- **More Menu**: Access status change options
|
|
236
|
+
---
|
|
189
237
|
|
|
190
|
-
|
|
238
|
+
## 🎛 Control Features
|
|
191
239
|
|
|
192
|
-
|
|
240
|
+
- **Status Management**: Idle / Break
|
|
241
|
+
- **Call Controls**: Hold / Resume, Mute / Unmute, End Call, Agent Status
|
|
242
|
+
- **Persistent State**: Hold, mute, agent status, panel position, call timer
|
|
193
243
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- Call timer state
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 🌍 Browser Support
|
|
198
247
|
|
|
199
|
-
|
|
248
|
+
- ✅ Chrome 60+
|
|
249
|
+
- ✅ Firefox 60+
|
|
250
|
+
- ✅ Safari 12+
|
|
251
|
+
- ✅ Edge 79+
|
|
200
252
|
|
|
201
|
-
|
|
202
|
-
- Firefox 60+
|
|
203
|
-
- Safari 12+
|
|
204
|
-
- Edge 79+
|
|
253
|
+
---
|
|
205
254
|
|
|
206
|
-
## License
|
|
255
|
+
## 📄 License
|
|
207
256
|
|
|
208
257
|
MIT © 2025
|