@voctiv/agent-sdk 0.2.5 → 0.2.6
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 +57 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ export default defineScript(async ({ channel, logger, context }) => {
|
|
|
79
79
|
- `channel` is the media channel for SIP, WS, ASR, TTS, audio playback, LLM, and structured data messages.
|
|
80
80
|
- `logger` writes structured script logs and can stream logs to a debug endpoint.
|
|
81
81
|
- `context` contains dialog identity, caller/called numbers, language, flags, params, entry point, persisted env, and runtime budget.
|
|
82
|
-
- `platform` exposes
|
|
82
|
+
- `platform` exposes platform operations: NLU, dialog state, outbound call scheduling, messaging, and phrase records.
|
|
83
83
|
|
|
84
84
|
`MediaChannel` is the main real-time API:
|
|
85
85
|
|
|
@@ -371,7 +371,7 @@ await channel.audio.say(
|
|
|
371
371
|
|
|
372
372
|
## Platform API
|
|
373
373
|
|
|
374
|
-
`platform` exposes Voctiv
|
|
374
|
+
`platform` exposes Voctiv platform operations.
|
|
375
375
|
|
|
376
376
|
`platform.nlu.extract(utterance, options?)` calls NLU v3 `/infer`. The runtime sends `phrase`, `context`, and `agent_id`. If `options.context` is omitted, current dialog params are serialized and used as NLU context.
|
|
377
377
|
|
|
@@ -383,7 +383,7 @@ const result = await platform.nlu.extract('I want to reschedule', {
|
|
|
383
383
|
});
|
|
384
384
|
```
|
|
385
385
|
|
|
386
|
-
|
|
386
|
+
Platform APIs require `context.legacyV3Compat === true`. This includes NLU, outbound calls, dialog writes, messaging sends, and phrase records.
|
|
387
387
|
|
|
388
388
|
### Dialog State
|
|
389
389
|
|
|
@@ -394,19 +394,68 @@ platform.dialog.result = 'done';
|
|
|
394
394
|
|
|
395
395
|
Setters update the local value immediately and ask the platform DB to persist asynchronously. They are not awaitable and should not be used as transactional writes.
|
|
396
396
|
|
|
397
|
-
###
|
|
397
|
+
### Platform-Scheduled Calls
|
|
398
|
+
|
|
399
|
+
Use `platform.call(msisdn, options?)` when the script needs to ask the platform to place an outbound SIP call. This is different from `channel.sip.makeCall()`: `makeCall()` creates a B-leg immediately inside the current live SIP session, while `platform.call()` schedules a separate platform-managed call that may happen now or later.
|
|
400
|
+
|
|
401
|
+
The destination number should be E.164 formatted.
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
await platform.call('+12025551234');
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
By default, the platform schedules the call for immediate processing. Use `date` to schedule it for the future:
|
|
398
408
|
|
|
399
409
|
```ts
|
|
400
410
|
await platform.call('+12025551234', {
|
|
401
|
-
date: new Date(Date.now() + 60_000),
|
|
411
|
+
date: new Date(Date.now() + 15 * 60_000),
|
|
402
412
|
entryPoint: 'on_callback',
|
|
403
|
-
|
|
413
|
+
});
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
`entryPoint` is passed to the script when the scheduled call starts. Use it to route the callback into a specific branch:
|
|
417
|
+
|
|
418
|
+
```ts
|
|
419
|
+
export default defineScript(async ({ context, channel }) => {
|
|
420
|
+
if (context.entryPoint === 'on_callback') {
|
|
421
|
+
channel.sip.answer();
|
|
422
|
+
await channel.audio.say('Hello, this is your scheduled callback.');
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
await channel.audio.say('I will call you back in fifteen minutes.');
|
|
427
|
+
});
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Use `dateEnd` to define the latest time when the call is still useful. If the platform cannot place the call before that deadline, it can skip the attempt.
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
await platform.call('+12025551234', {
|
|
434
|
+
date: new Date('2026-04-29T10:00:00Z'),
|
|
435
|
+
dateEnd: new Date('2026-04-29T10:30:00Z'),
|
|
436
|
+
entryPoint: 'on_reminder',
|
|
437
|
+
});
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Retries are controlled with `recallCount` and `recallDelay`:
|
|
441
|
+
|
|
442
|
+
```ts
|
|
443
|
+
await platform.call('+12025551234', {
|
|
444
|
+
entryPoint: 'on_follow_up',
|
|
445
|
+
recallCount: 3,
|
|
404
446
|
recallDelay: 300,
|
|
405
|
-
priority: 10,
|
|
406
447
|
});
|
|
407
448
|
```
|
|
408
449
|
|
|
409
|
-
This
|
|
450
|
+
This means the platform may retry up to three times, waiting about five minutes between attempts.
|
|
451
|
+
|
|
452
|
+
Other scheduling options:
|
|
453
|
+
|
|
454
|
+
- `priority`: higher-priority calls can be processed earlier by the dialer.
|
|
455
|
+
- `timezone`: timezone offset used by the platform when interpreting scheduled dates.
|
|
456
|
+
- `onSuccessCall`: entry point to use after a successful call.
|
|
457
|
+
- `onFailedCall`: entry point to use after failed attempts.
|
|
458
|
+
- `protoAdditional`: extra protocol-level parameters, such as SIP headers expected by your telephony setup.
|
|
410
459
|
|
|
411
460
|
### Messaging
|
|
412
461
|
|
package/package.json
CHANGED