call-control-sdk 5.2.0 → 5.2.2
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 -127
- 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,210 +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
|
-
{isLoading
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
}
|
|
113
150
|
```
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
It manages the API request, state (`loading`, `success`, `error`), and automatically resets the call
|
|
117
|
-
state when a call ends.
|
|
152
|
+
---
|
|
118
153
|
|
|
119
|
-
##
|
|
154
|
+
## 🛠 Core API
|
|
120
155
|
|
|
121
|
-
### `
|
|
156
|
+
### `initSDK(config)`
|
|
122
157
|
|
|
123
|
-
|
|
158
|
+
Initializes the SDK. Must be called **before using any components or hooks**.
|
|
124
159
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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 |
|
|
131
167
|
|
|
132
168
|
---
|
|
133
169
|
|
|
134
|
-
|
|
170
|
+
### `CallControlPanel`
|
|
135
171
|
|
|
136
|
-
|
|
172
|
+
Draggable control panel for call management.
|
|
137
173
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
174
|
+
**Props**:
|
|
175
|
+
|
|
176
|
+
| Prop | Type | Required | Description |
|
|
177
|
+
| --------------- | -------- | -------- | -------------------------------------------------------------------------------------------------- |
|
|
178
|
+
| `onDataChange?` | function | ❌ | Callback fired when call data changes. Receives `{ mobileNumber, callReferenceId, agentLoginId }`. |
|
|
179
|
+
|
|
180
|
+
---
|
|
144
181
|
|
|
145
|
-
|
|
182
|
+
### `updateCallData(data: Partial<CallData>)`
|
|
146
183
|
|
|
147
|
-
|
|
184
|
+
Update call data programmatically.
|
|
148
185
|
|
|
149
|
-
|
|
186
|
+
**Parameters**:
|
|
150
187
|
|
|
151
|
-
|
|
188
|
+
| Field | Type | Description |
|
|
189
|
+
| ------------------ | ------ | ---------------------- |
|
|
190
|
+
| `mobileNumber?` | string | Mobile phone number |
|
|
191
|
+
| `callReferenceId?` | string | Unique call reference |
|
|
192
|
+
| `agentLoginId?` | string | Agent login identifier |
|
|
152
193
|
|
|
153
|
-
|
|
154
|
-
- `tenantId` (string): Your Tenant Id key for Events authentication
|
|
155
|
-
- `agentId` (string): Agent Id for access call controls
|
|
194
|
+
---
|
|
156
195
|
|
|
157
|
-
|
|
196
|
+
## 🪝 Hooks
|
|
158
197
|
|
|
159
|
-
### `
|
|
198
|
+
### `useLogout()`
|
|
160
199
|
|
|
161
|
-
|
|
200
|
+
Logs out the current agent.
|
|
162
201
|
|
|
163
|
-
|
|
202
|
+
```tsx
|
|
203
|
+
const { logOut } = useLogout();
|
|
204
|
+
<button onClick={logOut}>Logout</button>;
|
|
205
|
+
```
|
|
164
206
|
|
|
165
|
-
|
|
166
|
-
- Parameters: `{ mobileNumber: string, callReferenceId: string, agentLoginId: string }`
|
|
207
|
+
---
|
|
167
208
|
|
|
168
|
-
### `
|
|
209
|
+
### `useEndCall()`
|
|
169
210
|
|
|
170
|
-
|
|
211
|
+
Hook for ending an active call.
|
|
171
212
|
|
|
172
|
-
**
|
|
213
|
+
**Returns**:
|
|
173
214
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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 |
|
|
177
223
|
|
|
178
|
-
|
|
224
|
+
---
|
|
179
225
|
|
|
180
|
-
|
|
226
|
+
## 📦 Payloads
|
|
181
227
|
|
|
182
|
-
|
|
183
|
-
- **Break**: Agent is on break
|
|
228
|
+
### `EndCallPayload`
|
|
184
229
|
|
|
185
|
-
|
|
230
|
+
```ts
|
|
231
|
+
interface EndCallPayload {
|
|
232
|
+
disposition?: string; // Call disposition (default: "RES")
|
|
233
|
+
}
|
|
234
|
+
```
|
|
186
235
|
|
|
187
|
-
|
|
188
|
-
- **Mute/Unmute**: Toggle microphone
|
|
189
|
-
- **End Call**: Terminate active call
|
|
190
|
-
- **More Menu**: Access status change options
|
|
236
|
+
---
|
|
191
237
|
|
|
192
|
-
|
|
238
|
+
## 🎛 Control Features
|
|
193
239
|
|
|
194
|
-
|
|
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
|
|
195
243
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
- Call timer state
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 🌍 Browser Support
|
|
200
247
|
|
|
201
|
-
|
|
248
|
+
- ✅ Chrome 60+
|
|
249
|
+
- ✅ Firefox 60+
|
|
250
|
+
- ✅ Safari 12+
|
|
251
|
+
- ✅ Edge 79+
|
|
202
252
|
|
|
203
|
-
|
|
204
|
-
- Firefox 60+
|
|
205
|
-
- Safari 12+
|
|
206
|
-
- Edge 79+
|
|
253
|
+
---
|
|
207
254
|
|
|
208
|
-
## License
|
|
255
|
+
## 📄 License
|
|
209
256
|
|
|
210
257
|
MIT © 2025
|