@cemscale-voip/voip-sdk 1.55.2 → 1.55.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 +56 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1208,9 +1208,65 @@ phone.on('error', (err) => console.error('Phone error:', err));
|
|
|
1208
1208
|
### Presence
|
|
1209
1209
|
| Method | Description |
|
|
1210
1210
|
|--------|-------------|
|
|
1211
|
+
| `setPresence(extensionId, status)` | Set manual status (`'busy'` / `'available'`) |
|
|
1211
1212
|
| `getPresence()` | Simple map |
|
|
1212
1213
|
| `getPresenceDetailed()` | Detailed with call info |
|
|
1213
1214
|
|
|
1215
|
+
### Presence Status Management
|
|
1216
|
+
|
|
1217
|
+
Control extension availability from the CRM. When an agent sets themselves
|
|
1218
|
+
as `busy`, the phone still rings but the call is rejected with SIP 486
|
|
1219
|
+
and routed to voicemail. Setting back to `available` restores normal behavior.
|
|
1220
|
+
|
|
1221
|
+
```typescript
|
|
1222
|
+
// Get current presence for all extensions
|
|
1223
|
+
const { presence } = await client.getPresence();
|
|
1224
|
+
// { '1001': 'available', '1002': 'busy', '1003': 'offline' }
|
|
1225
|
+
|
|
1226
|
+
// Set an extension to busy (next call → voicemail)
|
|
1227
|
+
await client.setPresence('ext-uuid-here', 'busy');
|
|
1228
|
+
|
|
1229
|
+
// Set back to available (calls ring normally)
|
|
1230
|
+
await client.setPresence('ext-uuid-here', 'available');
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
**WebSocket (real-time):** When any extension changes presence, all connected
|
|
1234
|
+
CRM clients receive `presence_change` instantly.
|
|
1235
|
+
|
|
1236
|
+
```typescript
|
|
1237
|
+
client.connectWebSocket();
|
|
1238
|
+
|
|
1239
|
+
client.onWsEvent('presence_change', (event) => {
|
|
1240
|
+
// event.data.extension → '1001'
|
|
1241
|
+
// event.data.status → 'busy'
|
|
1242
|
+
updateAgentBadge(event.data.extension, event.data.status);
|
|
1243
|
+
});
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
**React with `usePresence` hook:**
|
|
1247
|
+
|
|
1248
|
+
```tsx
|
|
1249
|
+
import { usePresence } from '@cemscale-voip/voip-sdk/hooks';
|
|
1250
|
+
|
|
1251
|
+
function AgentPanel({ client, extensionId }) {
|
|
1252
|
+
const { presence, getStatus } = usePresence(client);
|
|
1253
|
+
const myStatus = getStatus('1001');
|
|
1254
|
+
// 'available' | 'busy' | 'on_call' | 'offline' | 'dnd' | 'ringing'
|
|
1255
|
+
|
|
1256
|
+
return (
|
|
1257
|
+
<div>
|
|
1258
|
+
<span className={`badge ${myStatus}`}>{myStatus}</span>
|
|
1259
|
+
<button onClick={() => client.setPresence(extensionId, 'busy')}>
|
|
1260
|
+
Set Busy
|
|
1261
|
+
</button>
|
|
1262
|
+
<button onClick={() => client.setPresence(extensionId, 'available')}>
|
|
1263
|
+
Set Available
|
|
1264
|
+
</button>
|
|
1265
|
+
</div>
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
```
|
|
1269
|
+
|
|
1214
1270
|
### Reports
|
|
1215
1271
|
| Method | Description |
|
|
1216
1272
|
|--------|-------------|
|