@cemscale-voip/voip-sdk 1.34.0 → 1.35.0

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.
Files changed (2) hide show
  1. package/README.md +136 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -280,6 +280,132 @@ await voip.blockNumber({ number: '+15559999999', reason: 'Spam', direction: 'inb
280
280
  const { blocked } = await voip.checkBlocked('+15559999999'); // true
281
281
  ```
282
282
 
283
+ ### AI Agents (Voice AI)
284
+
285
+ Create and manage AI phone agents powered by Gemini. Agents answer calls, speak to callers in real-time, and can transfer to humans.
286
+
287
+ **No extra configuration needed.** AI Agents work through the same `voip` client — no separate `BRIDGE_URL` or `BRIDGE_API_KEY` required.
288
+
289
+ ```typescript
290
+ // List all AI agents
291
+ const { agents } = await voip.listAiAgents();
292
+ console.log(agents);
293
+ // [{ agent_id: 'acme-sales', display_name: 'Sofia', voice: 'Kore', ... }]
294
+
295
+ // Create a new AI agent
296
+ const { agent } = await voip.createAiAgent({
297
+ agent_id: 'acme-sales', // unique slug (used as route target)
298
+ display_name: 'Sofia', // name shown in dashboard/logs
299
+ company: 'Acme Corp', // company context for the AI
300
+ role: 'Sales Representative', // role context
301
+ language: 'en', // 'en', 'es', 'fr', etc.
302
+ voice: 'Kore', // Gemini voice: Kore, Aoede, Charon, Fenrir, Puck
303
+ speak_first: true, // agent greets the caller first
304
+ thinking_level: 'minimal', // minimal, low, medium, high
305
+ temperature: 0.7, // 0.0 (precise) to 1.0 (creative)
306
+ system_prompt: `You are Sofia, a professional sales representative for Acme Corp.
307
+ You speak English and Spanish fluently. Respond in whichever language the caller uses.
308
+ Be conversational, warm, and helpful. Keep responses SHORT (1-2 sentences).
309
+ If the caller asks to speak with a human, transfer them.
310
+ Start with: "Thank you for calling Acme Corp, how can I help you today?"`,
311
+ });
312
+
313
+ // Update an existing agent
314
+ await voip.updateAiAgent('acme-sales', {
315
+ display_name: 'Sofia v2',
316
+ system_prompt: 'Updated instructions...',
317
+ voice: 'Aoede',
318
+ temperature: 0.5,
319
+ });
320
+
321
+ // Get a single agent
322
+ const { agent: detail } = await voip.getAiAgent('acme-sales');
323
+ console.log(detail.system_prompt);
324
+
325
+ // Delete an agent
326
+ await voip.deleteAiAgent('acme-sales');
327
+
328
+ // Health check (verify AI Bridge is connected)
329
+ const health = await voip.aiAgentsHealth();
330
+ console.log(health.status); // 'connected'
331
+ ```
332
+
333
+ #### Assigning an AI Agent to a Phone Number
334
+
335
+ After creating an agent, link it to a DID so inbound calls are answered by the AI:
336
+
337
+ ```typescript
338
+ // Assign agent to DID — calls to this number now go to the AI
339
+ await voip.updateDid('did-uuid', {
340
+ inboundRoute: 'ai_agent',
341
+ routeTarget: 'acme-sales', // must match agent_id
342
+ aiTransferType: 'queue', // where AI transfers when caller asks for human
343
+ aiTransferTarget: 'support-queue-uuid',
344
+ });
345
+
346
+ // Transfer types: 'extension', 'queue', 'ringgroup', 'ivr', 'external', 'voicemail'
347
+ // Transfer target: the UUID/number of the destination
348
+ ```
349
+
350
+ #### Complete Example: Full Agent Setup
351
+
352
+ ```typescript
353
+ import { VoIPClient } from '@cemscale-voip/voip-sdk';
354
+
355
+ const voip = new VoIPClient({
356
+ apiUrl: process.env.VOIP_API_URL, // https://voip-api.cemscale.com
357
+ apiKey: process.env.VOIP_API_KEY, // your API key
358
+ });
359
+
360
+ // 1. Create the agent
361
+ const { agent } = await voip.createAiAgent({
362
+ agent_id: 'support-bot',
363
+ display_name: 'Alex',
364
+ company: 'My Company',
365
+ language: 'en',
366
+ voice: 'Kore',
367
+ speak_first: true,
368
+ thinking_level: 'minimal',
369
+ system_prompt: 'You are Alex, a support agent for My Company. Help callers with their issues. Transfer to a human only if the caller explicitly asks.',
370
+ });
371
+
372
+ // 2. Link agent to a phone number
373
+ await voip.updateDid('did-uuid-here', {
374
+ inboundRoute: 'ai_agent',
375
+ routeTarget: 'support-bot',
376
+ aiTransferType: 'extension',
377
+ aiTransferTarget: '1001',
378
+ });
379
+
380
+ // Now when someone calls that number, Alex (the AI) answers.
381
+ // If the caller says "let me talk to a person", Alex transfers to extension 1001.
382
+ ```
383
+
384
+ #### Available Voices
385
+
386
+ | Voice | Style |
387
+ |-------|-------|
388
+ | `Kore` | Professional, warm (default) |
389
+ | `Aoede` | Friendly, energetic |
390
+ | `Charon` | Deep, authoritative |
391
+ | `Fenrir` | Calm, measured |
392
+ | `Puck` | Upbeat, playful |
393
+
394
+ #### Agent Fields Reference
395
+
396
+ | Field | Type | Required | Default | Description |
397
+ |-------|------|----------|---------|-------------|
398
+ | `agent_id` | string | Yes | — | Unique slug identifier (e.g. `acme-sales`) |
399
+ | `display_name` | string | Yes | — | Display name in dashboard and logs |
400
+ | `company` | string | No | `display_name` | Company name for AI context |
401
+ | `role` | string | No | `AI Assistant` | Role context for the AI |
402
+ | `language` | string | No | `en` | Language code: `en`, `es`, `fr`, etc. |
403
+ | `voice` | string | No | `Kore` | Gemini voice name |
404
+ | `system_prompt` | string | No | `''` | Instructions for the AI agent |
405
+ | `speak_first` | boolean | No | `true` | Agent greets caller first |
406
+ | `thinking_level` | string | No | `minimal` | Reasoning depth: `minimal`, `low`, `medium`, `high` |
407
+ | `temperature` | number | No | `0.7` | Creativity: 0.0 (precise) to 1.0 (creative) |
408
+
283
409
  ### CDR Export
284
410
 
285
411
  ```typescript
@@ -573,6 +699,16 @@ phone.on('error', (err) => console.error('Phone error:', err));
573
699
  | `updateDid(id, params)` | Update routing |
574
700
  | `deleteDid(id)` | Remove |
575
701
 
702
+ ### AI Agents
703
+ | Method | Description |
704
+ |--------|-------------|
705
+ | `listAiAgents(tenantId?)` | List all AI agents |
706
+ | `getAiAgent(agentId)` | Get agent details (includes `system_prompt`) |
707
+ | `createAiAgent(params)` | Create new AI agent |
708
+ | `updateAiAgent(agentId, params)` | Update agent config |
709
+ | `deleteAiAgent(agentId)` | Delete agent |
710
+ | `aiAgentsHealth()` | Check AI Bridge connectivity |
711
+
576
712
  ### Tenants (superadmin)
577
713
  | Method | Description |
578
714
  |--------|-------------|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cemscale-voip/voip-sdk",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "description": "VoIP SDK for CemScale multi-tenant platform — API client, WebRTC, React hooks",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",