@voctiv/agent-runtime 0.2.2 → 0.4.1
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 +53 -20
- package/bin/voctiv-agent-check.js +98 -0
- package/dist/barge-in/barge-in-module.d.ts +0 -1
- package/dist/barge-in/barge-in-module.js +0 -1
- package/dist/barge-in/barge-in-service.d.ts +1 -1
- package/dist/barge-in/barge-in-service.js +33 -2
- package/dist/barge-in/barge-in-strategy.d.ts +11 -9
- package/dist/barge-in/barge-in-strategy.js +39 -23
- package/dist/barge-in/echo-cancellation.d.ts +0 -1
- package/dist/barge-in/echo-cancellation.js +0 -1
- package/dist/barge-in/echo.d.ts +0 -1
- package/dist/barge-in/echo.js +0 -1
- package/dist/barge-in/lexicon.d.ts +0 -1
- package/dist/barge-in/lexicon.js +0 -1
- package/dist/barge-in/speech-ledger.d.ts +0 -2
- package/dist/barge-in/speech-ledger.js +3 -4
- package/dist/barge-in/word-classifier.d.ts +0 -1
- package/dist/barge-in/word-classifier.js +0 -1
- package/dist/call/asr-usage.d.ts +53 -0
- package/dist/call/asr-usage.js +42 -0
- package/dist/call/async.d.ts +2 -0
- package/dist/call/async.js +14 -0
- package/dist/call/env.d.ts +88 -0
- package/dist/call/env.js +294 -0
- package/dist/call/extraction/core.d.ts +99 -0
- package/dist/call/extraction/core.js +259 -0
- package/dist/call/extraction/defaults.d.ts +10 -0
- package/dist/call/extraction/defaults.js +25 -0
- package/dist/call/extraction/index.d.ts +7 -0
- package/dist/call/extraction/index.js +24 -0
- package/dist/call/extraction/orchestrator.d.ts +144 -0
- package/dist/call/extraction/orchestrator.js +309 -0
- package/dist/call/failed-leg.d.ts +43 -0
- package/dist/call/failed-leg.js +77 -0
- package/dist/call/http.d.ts +94 -0
- package/dist/call/http.js +145 -0
- package/dist/call/ledger.d.ts +18 -0
- package/dist/call/ledger.js +80 -0
- package/dist/call/llm-tap.d.ts +7 -0
- package/dist/call/llm-tap.js +41 -0
- package/dist/call/logging.d.ts +16 -0
- package/dist/call/logging.js +92 -0
- package/dist/call/outbound.d.ts +144 -0
- package/dist/call/outbound.js +404 -0
- package/dist/call/output.d.ts +108 -0
- package/dist/call/output.js +77 -0
- package/dist/call/plan.d.ts +119 -0
- package/dist/call/plan.js +2 -0
- package/dist/call/recall.d.ts +115 -0
- package/dist/call/recall.js +312 -0
- package/dist/call/records.d.ts +9 -0
- package/dist/call/records.js +71 -0
- package/dist/call/report.d.ts +65 -0
- package/dist/call/report.js +263 -0
- package/dist/call/sanitize.d.ts +16 -0
- package/dist/call/sanitize.js +72 -0
- package/dist/call/sip.d.ts +111 -0
- package/dist/call/sip.js +212 -0
- package/dist/call/voicemail.d.ts +159 -0
- package/dist/call/voicemail.js +246 -0
- package/dist/core/call-disposables.d.ts +2 -2
- package/dist/core/call-disposables.js +8 -3
- package/dist/core/call-ended-budget.d.ts +11 -0
- package/dist/core/call-ended-budget.js +31 -0
- package/dist/core/container.d.ts +1 -3
- package/dist/core/container.js +9 -49
- package/dist/core/create-agent-script.d.ts +6 -1
- package/dist/core/create-agent-script.js +161 -28
- package/dist/core/decorators.d.ts +0 -1
- package/dist/core/decorators.js +0 -1
- package/dist/core/define-module.d.ts +0 -1
- package/dist/core/define-module.js +0 -1
- package/dist/core/dump-policy.d.ts +0 -1
- package/dist/core/dump-policy.js +0 -1
- package/dist/core/hooks.d.ts +15 -4
- package/dist/core/hooks.js +0 -1
- package/dist/core/media-bootstrap.d.ts +19 -4
- package/dist/core/media-bootstrap.js +53 -13
- package/dist/core/open-timeout.d.ts +12 -0
- package/dist/core/open-timeout.js +48 -0
- package/dist/core/provide-media.d.ts +0 -8
- package/dist/core/provide-media.js +1 -22
- package/dist/core/runtime-events.d.ts +28 -0
- package/dist/{llm/llm-module.js → core/runtime-events.js} +19 -16
- package/dist/core/tokens.d.ts +0 -10
- package/dist/core/tokens.js +0 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.js +0 -1
- package/dist/core/version.d.ts +2 -3
- package/dist/core/version.js +2 -3
- package/dist/dialog/dialog-definition.d.ts +0 -5
- package/dist/dialog/dialog-definition.js +1 -6
- package/dist/dialog/dialog-ports.d.ts +3 -1
- package/dist/dialog/dialog-ports.js +10 -2
- package/dist/dialog/online-call-host.d.ts +26 -4
- package/dist/dialog/online-call-host.js +94 -12
- package/dist/dialog/online-call-module.d.ts +5 -11
- package/dist/dialog/online-call-module.js +4 -36
- package/dist/dialog/turn-metrics.d.ts +46 -0
- package/dist/dialog/turn-metrics.js +141 -0
- package/dist/dialog-events/active-media.d.ts +50 -2
- package/dist/dialog-events/active-media.js +146 -34
- package/dist/dialog-events/event-source.d.ts +0 -1
- package/dist/dialog-events/event-source.js +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts +0 -1
- package/dist/dialog-events/virtual-finals-module.js +0 -1
- package/dist/dialog-events/virtual-finals.d.ts +2 -1
- package/dist/dialog-events/virtual-finals.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +8 -26
- package/dist/lifecycle/lifecycle.d.ts +25 -3
- package/dist/lifecycle/lifecycle.js +92 -14
- package/dist/result/result-store.d.ts +0 -1
- package/dist/result/result-store.js +0 -1
- package/dist/templates/authoring.d.ts +222 -0
- package/dist/templates/authoring.js +2 -0
- package/dist/templates/builder/agent.d.ts +34 -0
- package/dist/templates/builder/agent.js +87 -0
- package/dist/templates/builder/blocks.d.ts +54 -0
- package/dist/templates/builder/blocks.js +92 -0
- package/dist/templates/builder/data-check.d.ts +2 -0
- package/dist/templates/builder/data-check.js +61 -0
- package/dist/templates/builder/draft.d.ts +73 -0
- package/dist/templates/builder/draft.js +142 -0
- package/dist/templates/builder/index.d.ts +8 -0
- package/dist/templates/builder/index.js +55 -0
- package/dist/templates/builder/presets.d.ts +34 -0
- package/dist/templates/builder/presets.js +45 -0
- package/dist/templates/builder/spec-of.d.ts +13 -0
- package/dist/templates/builder/spec-of.js +18 -0
- package/dist/templates/builder/steps.d.ts +25 -0
- package/dist/templates/builder/steps.js +27 -0
- package/dist/templates/business/adapter.d.ts +12 -0
- package/dist/templates/business/adapter.js +980 -0
- package/dist/templates/business/agent-integrations.d.ts +24 -0
- package/dist/templates/business/agent-integrations.js +233 -0
- package/dist/templates/business/extraction-rules-transcript.d.ts +158 -0
- package/dist/templates/business/extraction-rules-transcript.js +405 -0
- package/dist/templates/business/extraction-rules.d.ts +107 -0
- package/dist/templates/business/extraction-rules.js +267 -0
- package/dist/templates/business/index.d.ts +6 -0
- package/dist/{result → templates/business}/index.js +8 -2
- package/dist/templates/business/input.d.ts +56 -0
- package/dist/templates/business/input.js +299 -0
- package/dist/templates/business/integration-data.d.ts +87 -0
- package/dist/templates/business/integration-data.js +312 -0
- package/dist/templates/business/integrations.d.ts +76 -0
- package/dist/templates/business/integrations.js +535 -0
- package/dist/templates/business/legs-policy.d.ts +43 -0
- package/dist/templates/business/legs-policy.js +268 -0
- package/dist/templates/business/report-label.d.ts +7 -0
- package/dist/templates/business/report-label.js +29 -0
- package/dist/templates/business/report.d.ts +67 -0
- package/dist/templates/business/report.js +284 -0
- package/dist/templates/business/result-catalog.d.ts +142 -0
- package/dist/templates/business/result-catalog.js +208 -0
- package/dist/templates/business/result-rules.d.ts +105 -0
- package/dist/templates/business/result-rules.js +167 -0
- package/dist/templates/business/results.d.ts +73 -0
- package/dist/templates/business/results.js +183 -0
- package/dist/templates/business/rule-env.d.ts +18 -0
- package/dist/templates/business/rule-env.js +38 -0
- package/dist/templates/business/sources.d.ts +76 -0
- package/dist/templates/business/sources.js +239 -0
- package/dist/templates/business/test-presets.d.ts +10 -0
- package/dist/templates/business/test-presets.js +68 -0
- package/dist/templates/catalog-match/block.d.ts +32 -0
- package/dist/templates/catalog-match/block.js +95 -0
- package/dist/templates/catalog-match/catalog.d.ts +77 -0
- package/dist/templates/catalog-match/catalog.js +222 -0
- package/dist/templates/catalog-match/recognizer.d.ts +44 -0
- package/dist/templates/catalog-match/recognizer.js +206 -0
- package/dist/templates/catalog-match/reconcile.d.ts +4 -0
- package/dist/templates/catalog-match/reconcile.js +39 -0
- package/dist/templates/catalog-match/request.d.ts +57 -0
- package/dist/templates/catalog-match/request.js +139 -0
- package/dist/templates/catalog-match/types.d.ts +197 -0
- package/dist/templates/catalog-match/types.js +2 -0
- package/dist/templates/catalog-match/verify.d.ts +76 -0
- package/dist/templates/catalog-match/verify.js +220 -0
- package/dist/templates/decision-model/index.d.ts +52 -0
- package/dist/templates/decision-model/index.js +68 -0
- package/dist/templates/engine/asr-picks.d.ts +11 -0
- package/dist/templates/engine/asr-picks.js +44 -0
- package/dist/templates/engine/call.d.ts +104 -0
- package/dist/templates/engine/call.js +322 -0
- package/dist/templates/engine/config.d.ts +447 -0
- package/dist/templates/engine/config.js +493 -0
- package/dist/templates/engine/define.d.ts +1 -0
- package/dist/templates/engine/define.js +9 -0
- package/dist/templates/engine/dialog.d.ts +253 -0
- package/dist/templates/engine/dialog.js +167 -0
- package/dist/templates/engine/echo-numbers.d.ts +7 -0
- package/dist/templates/engine/echo-numbers.js +19 -0
- package/dist/templates/engine/expand.d.ts +6 -0
- package/dist/templates/engine/expand.js +125 -0
- package/dist/templates/engine/filters.d.ts +81 -0
- package/dist/templates/engine/filters.js +654 -0
- package/dist/templates/engine/hook-state.d.ts +18 -0
- package/dist/templates/engine/hook-state.js +100 -0
- package/dist/templates/engine/hooks.d.ts +51 -0
- package/dist/templates/engine/hooks.js +310 -0
- package/dist/templates/engine/index.d.ts +13 -0
- package/dist/templates/engine/index.js +30 -0
- package/dist/templates/engine/language-vars.d.ts +6 -0
- package/dist/templates/engine/language-vars.js +40 -0
- package/dist/templates/engine/language.d.ts +32 -0
- package/dist/templates/engine/language.js +155 -0
- package/dist/templates/engine/lookup.d.ts +20 -0
- package/dist/templates/engine/lookup.js +52 -0
- package/dist/templates/engine/match.d.ts +48 -0
- package/dist/templates/engine/match.js +253 -0
- package/dist/templates/engine/media.d.ts +428 -0
- package/dist/templates/engine/media.js +1240 -0
- package/dist/templates/engine/script.d.ts +11 -0
- package/dist/templates/engine/script.js +69 -0
- package/dist/templates/engine/turns/actions.d.ts +5 -0
- package/dist/templates/engine/turns/actions.js +128 -0
- package/dist/templates/engine/turns/carry.d.ts +15 -0
- package/dist/templates/engine/turns/carry.js +74 -0
- package/dist/templates/engine/turns/choices-offers.d.ts +21 -0
- package/dist/templates/engine/turns/choices-offers.js +143 -0
- package/dist/templates/engine/turns/choices.d.ts +22 -0
- package/dist/templates/engine/turns/choices.js +141 -0
- package/dist/templates/engine/turns/closing-guard.d.ts +73 -0
- package/dist/templates/engine/turns/closing-guard.js +162 -0
- package/dist/templates/engine/turns/closing.d.ts +10 -0
- package/dist/templates/engine/turns/closing.js +82 -0
- package/dist/templates/engine/turns/compile-forms.d.ts +24 -0
- package/dist/templates/engine/turns/compile-forms.js +68 -0
- package/dist/templates/engine/turns/context.d.ts +96 -0
- package/dist/templates/engine/turns/context.js +158 -0
- package/dist/templates/engine/turns/events.d.ts +409 -0
- package/dist/templates/engine/turns/events.js +5 -0
- package/dist/templates/engine/turns/hook-forms.d.ts +62 -0
- package/dist/templates/engine/turns/hook-forms.js +79 -0
- package/dist/templates/engine/turns/ladders.d.ts +42 -0
- package/dist/templates/engine/turns/ladders.js +119 -0
- package/dist/templates/engine/turns/language.d.ts +8 -0
- package/dist/templates/engine/turns/language.js +121 -0
- package/dist/templates/engine/turns/notes-dates.d.ts +9 -0
- package/dist/templates/engine/turns/notes-dates.js +42 -0
- package/dist/templates/engine/turns/notes-detect.d.ts +13 -0
- package/dist/templates/engine/turns/notes-detect.js +36 -0
- package/dist/templates/engine/turns/notes.d.ts +27 -0
- package/dist/templates/engine/turns/notes.js +176 -0
- package/dist/templates/engine/turns/opening.d.ts +34 -0
- package/dist/templates/engine/turns/opening.js +306 -0
- package/dist/templates/engine/turns/overtalk.d.ts +21 -0
- package/dist/templates/engine/turns/overtalk.js +247 -0
- package/dist/templates/engine/turns/pending.d.ts +9 -0
- package/dist/templates/engine/turns/pending.js +88 -0
- package/dist/templates/engine/turns/reply-rules.d.ts +184 -0
- package/dist/templates/engine/turns/reply-rules.js +335 -0
- package/dist/templates/engine/turns/rules.d.ts +20 -0
- package/dist/templates/engine/turns/rules.js +144 -0
- package/dist/templates/engine/turns/silence.d.ts +7 -0
- package/dist/templates/engine/turns/silence.js +127 -0
- package/dist/templates/engine/turns/state-spec.d.ts +305 -0
- package/dist/templates/engine/turns/state-spec.js +2 -0
- package/dist/templates/engine/turns/state.d.ts +38 -0
- package/dist/templates/engine/turns/state.js +101 -0
- package/dist/templates/engine/turns/tracking.d.ts +50 -0
- package/dist/templates/engine/turns/tracking.js +184 -0
- package/dist/templates/engine/turns/transfer.d.ts +19 -0
- package/dist/templates/engine/turns/transfer.js +93 -0
- package/dist/templates/engine/turns/turn.d.ts +17 -0
- package/dist/templates/engine/turns/turn.js +363 -0
- package/dist/templates/engine/turns/voicemail.d.ts +8 -0
- package/dist/templates/engine/turns/voicemail.js +101 -0
- package/dist/templates/engine/variants.d.ts +36 -0
- package/dist/templates/engine/variants.js +159 -0
- package/dist/templates/engine/voice-dialog.d.ts +24 -0
- package/dist/templates/engine/voice-dialog.js +157 -0
- package/dist/templates/engine/voice.d.ts +174 -0
- package/dist/templates/engine/voice.js +1337 -0
- package/dist/templates/expr/caller-after.d.ts +20 -0
- package/dist/templates/expr/caller-after.js +53 -0
- package/dist/templates/expr/check.d.ts +19 -0
- package/dist/templates/expr/check.js +314 -0
- package/dist/templates/expr/compiled.d.ts +8 -0
- package/dist/templates/expr/compiled.js +8 -0
- package/dist/templates/expr/context.d.ts +28 -0
- package/dist/templates/expr/context.js +55 -0
- package/dist/templates/expr/day-table.d.ts +4 -0
- package/dist/templates/expr/day-table.js +80 -0
- package/dist/templates/expr/evaluate.d.ts +26 -0
- package/dist/templates/expr/evaluate.js +885 -0
- package/dist/templates/expr/facts.d.ts +7 -0
- package/dist/templates/expr/facts.js +81 -0
- package/dist/templates/expr/index.d.ts +4 -0
- package/dist/templates/expr/index.js +11 -0
- package/dist/templates/expr/line-tally.d.ts +64 -0
- package/dist/templates/expr/line-tally.js +88 -0
- package/dist/templates/expr/matchers-state.d.ts +23 -0
- package/dist/templates/expr/matchers-state.js +37 -0
- package/dist/templates/expr/matchers.d.ts +12 -0
- package/dist/templates/expr/matchers.js +99 -0
- package/dist/templates/expr/readers.d.ts +14 -0
- package/dist/templates/expr/readers.js +351 -0
- package/dist/templates/expr/slots.d.ts +14 -0
- package/dist/templates/expr/slots.js +678 -0
- package/dist/templates/expr/template.d.ts +12 -0
- package/dist/templates/expr/template.js +76 -0
- package/dist/templates/expr/test-call.d.ts +8 -0
- package/dist/templates/expr/test-call.js +32 -0
- package/dist/templates/expr/transcript.d.ts +36 -0
- package/dist/templates/expr/transcript.js +394 -0
- package/dist/templates/expr/types.d.ts +1011 -0
- package/dist/templates/expr/types.js +2 -0
- package/dist/templates/expr/values.d.ts +42 -0
- package/dist/templates/expr/values.js +166 -0
- package/dist/templates/expr/voice-ops.d.ts +26 -0
- package/dist/templates/expr/voice-ops.js +85 -0
- package/dist/templates/helpers/decision.d.ts +55 -0
- package/dist/templates/helpers/decision.js +83 -0
- package/dist/templates/helpers/fuzzy.d.ts +9 -0
- package/dist/templates/helpers/fuzzy.js +44 -0
- package/dist/templates/helpers/index.d.ts +6 -0
- package/dist/templates/helpers/index.js +35 -0
- package/dist/templates/index.d.ts +9 -0
- package/dist/templates/index.js +68 -0
- package/dist/templates/integration-forms.d.ts +252 -0
- package/dist/templates/integration-forms.js +2 -0
- package/dist/templates/knowledge/block.d.ts +44 -0
- package/dist/templates/knowledge/block.js +199 -0
- package/dist/templates/knowledge/dense.d.ts +87 -0
- package/dist/templates/knowledge/dense.js +158 -0
- package/dist/templates/knowledge/flow.d.ts +328 -0
- package/dist/templates/knowledge/flow.js +509 -0
- package/dist/templates/knowledge/retriever.d.ts +75 -0
- package/dist/templates/knowledge/retriever.js +204 -0
- package/dist/templates/knowledge/service.d.ts +77 -0
- package/dist/templates/knowledge/service.js +316 -0
- package/dist/templates/knowledge/text.d.ts +31 -0
- package/dist/templates/knowledge/text.js +66 -0
- package/dist/templates/knowledge/types.d.ts +120 -0
- package/dist/templates/knowledge/types.js +2 -0
- package/dist/templates/locale.d.ts +259 -0
- package/dist/templates/locale.js +4 -0
- package/dist/templates/locales/en-lexicons.d.ts +9 -0
- package/dist/templates/locales/en-lexicons.js +101 -0
- package/dist/templates/locales/en.d.ts +132 -0
- package/dist/templates/locales/en.js +261 -0
- package/dist/templates/locales/es.d.ts +65 -0
- package/dist/templates/locales/es.js +208 -0
- package/dist/templates/locales/hi.d.ts +47 -0
- package/dist/templates/locales/hi.js +235 -0
- package/dist/templates/locales/id.d.ts +43 -0
- package/dist/templates/locales/id.js +127 -0
- package/dist/templates/locales/index.d.ts +34 -0
- package/dist/templates/locales/index.js +112 -0
- package/dist/templates/locales/kk-lexicons.d.ts +22 -0
- package/dist/templates/locales/kk-lexicons.js +89 -0
- package/dist/templates/locales/kk.d.ts +140 -0
- package/dist/templates/locales/kk.js +306 -0
- package/dist/templates/locales/kn.d.ts +29 -0
- package/dist/templates/locales/kn.js +22 -0
- package/dist/templates/locales/listen-only.d.ts +15 -0
- package/dist/templates/locales/listen-only.js +27 -0
- package/dist/templates/locales/ms-lexicons.d.ts +13 -0
- package/dist/templates/locales/ms-lexicons.js +113 -0
- package/dist/templates/locales/ms.d.ts +76 -0
- package/dist/templates/locales/ms.js +179 -0
- package/dist/templates/locales/parse.d.ts +86 -0
- package/dist/templates/locales/parse.js +461 -0
- package/dist/templates/locales/ru-lexicons.d.ts +27 -0
- package/dist/templates/locales/ru-lexicons.js +127 -0
- package/dist/templates/locales/ru-stem.d.ts +2 -0
- package/dist/templates/locales/ru-stem.js +53 -0
- package/dist/templates/locales/ru.d.ts +143 -0
- package/dist/templates/locales/ru.js +387 -0
- package/dist/templates/locales/shared.d.ts +122 -0
- package/dist/templates/locales/shared.js +318 -0
- package/dist/templates/locales/ta.d.ts +29 -0
- package/dist/templates/locales/ta.js +22 -0
- package/dist/templates/locales/te.d.ts +29 -0
- package/dist/templates/locales/te.js +22 -0
- package/dist/templates/locales/tl-lexicons.d.ts +2 -0
- package/dist/templates/locales/tl-lexicons.js +230 -0
- package/dist/templates/locales/tl.d.ts +59 -0
- package/dist/templates/locales/tl.js +82 -0
- package/dist/templates/locales/vi.d.ts +59 -0
- package/dist/templates/locales/vi.js +160 -0
- package/dist/templates/locales/word-regex.d.ts +13 -0
- package/dist/templates/locales/word-regex.js +43 -0
- package/dist/templates/locales/words-kk.d.ts +2 -0
- package/dist/templates/locales/words-kk.js +23 -0
- package/dist/templates/locales/words-ru.d.ts +4 -0
- package/dist/templates/locales/words-ru.js +92 -0
- package/dist/templates/spec.d.ts +2856 -0
- package/dist/templates/spec.js +2 -0
- package/dist/testing/fake-channel.d.ts +0 -1
- package/dist/testing/fake-channel.js +0 -1
- package/dist/testing/index.d.ts +24 -1
- package/dist/testing/index.js +117 -2
- package/dist/voice/call-voice.d.ts +581 -0
- package/dist/voice/call-voice.js +1399 -0
- package/dist/voice/intent-interrupt.d.ts +32 -0
- package/dist/voice/intent-interrupt.js +91 -0
- package/dist/voice/self-echo.d.ts +28 -0
- package/dist/voice/self-echo.js +135 -0
- package/dist/voice/sentence-tag.d.ts +5 -0
- package/dist/voice/sentence-tag.js +42 -0
- package/dist/voice/speech-leak.d.ts +74 -0
- package/dist/voice/speech-leak.js +216 -0
- package/dist/voice/transfer.d.ts +90 -0
- package/dist/voice/transfer.js +331 -0
- package/dist/voice/turn-timing.d.ts +293 -0
- package/dist/voice/turn-timing.js +567 -0
- package/docs/README.md +3 -6
- package/docs/framework/README.md +6 -10
- package/docs/framework/architecture.md +2 -2
- package/docs/framework/container-and-di.md +1 -2
- package/docs/framework/invariants.md +6 -6
- package/docs/framework/package-layout.md +17 -23
- package/docs/framework/testing.md +8 -6
- package/package.json +22 -55
- package/skill/AGENTS.md +43 -0
- package/skill/AGENTS.recommend.md +27 -0
- package/skill/SKILL.md +100 -0
- package/skill/references/agent-file.md +230 -0
- package/skill/references/blocks.md +246 -0
- package/skill/references/builder.md +163 -0
- package/skill/references/business.md +659 -0
- package/skill/references/conversation.md +586 -0
- package/skill/references/core.md +89 -0
- package/skill/references/examples.md +73 -0
- package/skill/references/expressions.md +342 -0
- package/skill/references/format.md +114 -0
- package/skill/references/library-dev.md +84 -0
- package/skill/references/locales.md +149 -0
- package/skill/references/migration.md +133 -0
- package/skill/references/new-agent.md +170 -0
- package/skill/references/porting.md +165 -0
- package/templates/agent/README.md +55 -0
- package/templates/agent/package.json +24 -0
- package/templates/agent/src/agent.spec.ts +51 -0
- package/templates/agent/src/agent.ts +268 -0
- package/templates/agent/src/entities.ts +44 -0
- package/templates/agent/src/prompt.sqrl +21 -0
- package/templates/agent/src/variants/fixed-opening.ts +144 -0
- package/templates/agent/tsconfig.build.json +4 -0
- package/templates/agent/tsconfig.json +18 -0
- package/dist/asr/index.d.ts +0 -3
- package/dist/asr/index.d.ts.map +0 -1
- package/dist/asr/index.js +0 -6
- package/dist/asr/index.js.map +0 -1
- package/dist/barge-in/barge-in-module.d.ts.map +0 -1
- package/dist/barge-in/barge-in-module.js.map +0 -1
- package/dist/barge-in/barge-in-service.d.ts.map +0 -1
- package/dist/barge-in/barge-in-service.js.map +0 -1
- package/dist/barge-in/barge-in-strategy.d.ts.map +0 -1
- package/dist/barge-in/barge-in-strategy.js.map +0 -1
- package/dist/barge-in/echo-cancellation.d.ts.map +0 -1
- package/dist/barge-in/echo-cancellation.js.map +0 -1
- package/dist/barge-in/echo.d.ts.map +0 -1
- package/dist/barge-in/echo.js.map +0 -1
- package/dist/barge-in/index.d.ts +0 -13
- package/dist/barge-in/index.d.ts.map +0 -1
- package/dist/barge-in/index.js +0 -28
- package/dist/barge-in/index.js.map +0 -1
- package/dist/barge-in/lexicon.d.ts.map +0 -1
- package/dist/barge-in/lexicon.js.map +0 -1
- package/dist/barge-in/lexicons/en.d.ts +0 -2
- package/dist/barge-in/lexicons/en.d.ts.map +0 -1
- package/dist/barge-in/lexicons/en.js +0 -36
- package/dist/barge-in/lexicons/en.js.map +0 -1
- package/dist/barge-in/lexicons/id.d.ts +0 -2
- package/dist/barge-in/lexicons/id.d.ts.map +0 -1
- package/dist/barge-in/lexicons/id.js +0 -39
- package/dist/barge-in/lexicons/id.js.map +0 -1
- package/dist/barge-in/lexicons/index.d.ts +0 -10
- package/dist/barge-in/lexicons/index.d.ts.map +0 -1
- package/dist/barge-in/lexicons/index.js +0 -11
- package/dist/barge-in/lexicons/index.js.map +0 -1
- package/dist/barge-in/lexicons/ru.d.ts +0 -2
- package/dist/barge-in/lexicons/ru.d.ts.map +0 -1
- package/dist/barge-in/lexicons/ru.js +0 -39
- package/dist/barge-in/lexicons/ru.js.map +0 -1
- package/dist/barge-in/speech-ledger.d.ts.map +0 -1
- package/dist/barge-in/speech-ledger.js.map +0 -1
- package/dist/barge-in/word-classifier.d.ts.map +0 -1
- package/dist/barge-in/word-classifier.js.map +0 -1
- package/dist/bridge/bridge.d.ts +0 -28
- package/dist/bridge/bridge.d.ts.map +0 -1
- package/dist/bridge/bridge.js +0 -117
- package/dist/bridge/bridge.js.map +0 -1
- package/dist/bridge/index.d.ts +0 -3
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/index.js +0 -8
- package/dist/bridge/index.js.map +0 -1
- package/dist/core/call-disposables.d.ts.map +0 -1
- package/dist/core/call-disposables.js.map +0 -1
- package/dist/core/container.d.ts.map +0 -1
- package/dist/core/container.js.map +0 -1
- package/dist/core/create-agent-script.d.ts.map +0 -1
- package/dist/core/create-agent-script.js.map +0 -1
- package/dist/core/decorators.d.ts.map +0 -1
- package/dist/core/decorators.js.map +0 -1
- package/dist/core/define-module.d.ts.map +0 -1
- package/dist/core/define-module.js.map +0 -1
- package/dist/core/dump-policy.d.ts.map +0 -1
- package/dist/core/dump-policy.js.map +0 -1
- package/dist/core/hooks.d.ts.map +0 -1
- package/dist/core/hooks.js.map +0 -1
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -36
- package/dist/core/index.js.map +0 -1
- package/dist/core/media-bootstrap.d.ts.map +0 -1
- package/dist/core/media-bootstrap.js.map +0 -1
- package/dist/core/provide-media.d.ts.map +0 -1
- package/dist/core/provide-media.js.map +0 -1
- package/dist/core/tokens.d.ts.map +0 -1
- package/dist/core/tokens.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/dialog/basic-ports.d.ts +0 -54
- package/dist/dialog/basic-ports.d.ts.map +0 -1
- package/dist/dialog/basic-ports.js +0 -206
- package/dist/dialog/basic-ports.js.map +0 -1
- package/dist/dialog/define-dialog.d.ts +0 -21
- package/dist/dialog/define-dialog.d.ts.map +0 -1
- package/dist/dialog/define-dialog.js +0 -21
- package/dist/dialog/define-dialog.js.map +0 -1
- package/dist/dialog/dialog-definition.d.ts.map +0 -1
- package/dist/dialog/dialog-definition.js.map +0 -1
- package/dist/dialog/dialog-ports.d.ts.map +0 -1
- package/dist/dialog/dialog-ports.js.map +0 -1
- package/dist/dialog/index.d.ts +0 -7
- package/dist/dialog/index.d.ts.map +0 -1
- package/dist/dialog/index.js +0 -23
- package/dist/dialog/index.js.map +0 -1
- package/dist/dialog/online-call-host.d.ts.map +0 -1
- package/dist/dialog/online-call-host.js.map +0 -1
- package/dist/dialog/online-call-module.d.ts.map +0 -1
- package/dist/dialog/online-call-module.js.map +0 -1
- package/dist/dialog-events/active-media.d.ts.map +0 -1
- package/dist/dialog-events/active-media.js.map +0 -1
- package/dist/dialog-events/event-source.d.ts.map +0 -1
- package/dist/dialog-events/event-source.js.map +0 -1
- package/dist/dialog-events/index.d.ts +0 -8
- package/dist/dialog-events/index.d.ts.map +0 -1
- package/dist/dialog-events/index.js +0 -24
- package/dist/dialog-events/index.js.map +0 -1
- package/dist/dialog-events/max-listen-source.d.ts +0 -27
- package/dist/dialog-events/max-listen-source.d.ts.map +0 -1
- package/dist/dialog-events/max-listen-source.js +0 -98
- package/dist/dialog-events/max-listen-source.js.map +0 -1
- package/dist/dialog-events/overtalk-source.d.ts +0 -61
- package/dist/dialog-events/overtalk-source.d.ts.map +0 -1
- package/dist/dialog-events/overtalk-source.js +0 -232
- package/dist/dialog-events/overtalk-source.js.map +0 -1
- package/dist/dialog-events/silence-source.d.ts +0 -32
- package/dist/dialog-events/silence-source.d.ts.map +0 -1
- package/dist/dialog-events/silence-source.js +0 -128
- package/dist/dialog-events/silence-source.js.map +0 -1
- package/dist/dialog-events/virtual-finals-module.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals-module.js.map +0 -1
- package/dist/dialog-events/virtual-finals.d.ts.map +0 -1
- package/dist/dialog-events/virtual-finals.js.map +0 -1
- package/dist/dtmf/dtmf.d.ts +0 -27
- package/dist/dtmf/dtmf.d.ts.map +0 -1
- package/dist/dtmf/dtmf.js +0 -87
- package/dist/dtmf/dtmf.js.map +0 -1
- package/dist/dtmf/index.d.ts +0 -3
- package/dist/dtmf/index.d.ts.map +0 -1
- package/dist/dtmf/index.js +0 -8
- package/dist/dtmf/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/index.d.ts +0 -3
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js +0 -9
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/lifecycle.js.map +0 -1
- package/dist/llm/index.d.ts +0 -7
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -18
- package/dist/llm/index.js.map +0 -1
- package/dist/llm/llm-markers-module.d.ts +0 -15
- package/dist/llm/llm-markers-module.d.ts.map +0 -1
- package/dist/llm/llm-markers-module.js +0 -48
- package/dist/llm/llm-markers-module.js.map +0 -1
- package/dist/llm/llm-markers.d.ts +0 -36
- package/dist/llm/llm-markers.d.ts.map +0 -1
- package/dist/llm/llm-markers.js +0 -210
- package/dist/llm/llm-markers.js.map +0 -1
- package/dist/llm/llm-module.d.ts +0 -20
- package/dist/llm/llm-module.d.ts.map +0 -1
- package/dist/llm/llm-module.js.map +0 -1
- package/dist/match/index.d.ts +0 -3
- package/dist/match/index.d.ts.map +0 -1
- package/dist/match/index.js +0 -10
- package/dist/match/index.js.map +0 -1
- package/dist/match/match.d.ts +0 -33
- package/dist/match/match.d.ts.map +0 -1
- package/dist/match/match.js +0 -85
- package/dist/match/match.js.map +0 -1
- package/dist/outbound/index.d.ts +0 -3
- package/dist/outbound/index.d.ts.map +0 -1
- package/dist/outbound/index.js +0 -8
- package/dist/outbound/index.js.map +0 -1
- package/dist/outbound/outbound.d.ts +0 -40
- package/dist/outbound/outbound.d.ts.map +0 -1
- package/dist/outbound/outbound.js +0 -84
- package/dist/outbound/outbound.js.map +0 -1
- package/dist/result/index.d.ts +0 -2
- package/dist/result/index.d.ts.map +0 -1
- package/dist/result/index.js.map +0 -1
- package/dist/result/result-store.d.ts.map +0 -1
- package/dist/result/result-store.js.map +0 -1
- package/dist/testing/fake-channel.d.ts.map +0 -1
- package/dist/testing/fake-channel.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/docs/agents/README.md +0 -41
- package/docs/agents/barge-in.md +0 -67
- package/docs/agents/dialog.md +0 -98
- package/docs/agents/getting-started.md +0 -142
- package/docs/agents/imports.md +0 -40
- package/docs/agents/media-and-ports.md +0 -82
- package/docs/agents/modules.md +0 -83
- package/docs/agents/phases.md +0 -83
- package/docs/framework/extending.md +0 -59
- package/docs/framework/idn-parity.md +0 -18
- package/examples/minimal-agent/README.md +0 -7
- package/examples/minimal-agent/agent.ts +0 -94
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
# Business part: input, extraction, results, report, integrations, recalls
|
|
2
|
+
|
|
3
|
+
These blocks replace the per-agent `render-payload`, `extraction/*`, `output`, `call-result`, `callback` files that
|
|
4
|
+
agents used to copy. They are data only: what one client needs and the data cannot say yet becomes a generic template
|
|
5
|
+
of the library (with a default that keeps every other agent unchanged), never code in the agent.
|
|
6
|
+
|
|
7
|
+
## Input: CMS data → call variables
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
input: {
|
|
11
|
+
timeZone: 'Asia/Kuala_Lumpur',
|
|
12
|
+
fields: {
|
|
13
|
+
customer_name: { from: [{ header: 'customer_name' }, { entity: 'customer_name' }], format: 'name' },
|
|
14
|
+
amount: { from: [{ header: 'next_payment_amount' }, { entity: 'amount' }], format: { kind: 'amount', currency: 'MYR' } },
|
|
15
|
+
due_date: { from: { entity: 'due_date' }, format: { kind: 'date', style: 'dayMonth' } },
|
|
16
|
+
greeting: { format: 'timeOfDayGreeting' },
|
|
17
|
+
days_left: { from: { daysBetween: [{ var: 'today' }, { var: 'due_date' }] }, prompt: 'omitEmpty' },
|
|
18
|
+
customer_data: { group: { full_name: { from: { entity: 'full_name' } }, iin: { from: { entity: 'iin' }, prompt: false } } },
|
|
19
|
+
},
|
|
20
|
+
required: { fields: ['customer_name', 'amount'], onMissing: 'log' },
|
|
21
|
+
testData: { enabledBy: { global: 'test_mode' }, values: { customer_name: 'Test User', amount: 1500 }, onlyWhenEmpty: true },
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Fields are evaluated in declaration order. A field reads its sources in order (header → proto → param → entity is
|
|
26
|
+
the usual chain); values read are text (strings trimmed, numbers as decimal text); test data next; `default` (a value) when
|
|
27
|
+
nothing is found — and also when the formatted value comes out empty.
|
|
28
|
+
- `{ header: 'name' }` reads the dialer's header bag (`proto_additional`, `X-name`), then the INVITE headers (any case,
|
|
29
|
+
a list's first value); `order: 'inviteFirst'` reads the INVITE's first (the bag when missing or blank), `order:
|
|
30
|
+
'invite'` only the INVITE's (the first header of that name, even a blank one).
|
|
31
|
+
`{ global }` / `{ storage }` are CMS globals (`context.storage`): the input fetches them once before the call.
|
|
32
|
+
- `format` reads the value out with the locale pack: `amount` (`currency`), `date` (`style` + pack options such as
|
|
33
|
+
`weekday`, or `pattern` with `YYYY YY MM M DD D MMMM MMM dddd ddd`; strings are parsed as calendar days in the formats
|
|
34
|
+
dialers send), `number`, `digits`, `name`, `text`, `count` (`forms`; with `case` the noun forms are that case's, e.g. `{ kind: 'count', forms: ['дня', 'дней', 'дней'], locale: 'ru', case: 'gen' }` → «четырнадцати дней»), `timeOfDayGreeting` / `timeOfDay` (of the call
|
|
35
|
+
hour when there is no `from`; `bands: { morning: 5, afternoon: 12, evening: 17, night: 22 }` moves the edges, the
|
|
36
|
+
pack's default otherwise), `relativeDay`, `timestamp` (an instant — epoch ms or ISO — by `pattern` with the date
|
|
37
|
+
tokens and `HH H mm ss`, in `timeZone`, default `input.timeZone`); `name` takes `punctuation: 'space'`,
|
|
38
|
+
`decode: 'none'`, `order: 'givenFirst'` (`es`). `locale: 'en'` formats with another pack (machine dates with English
|
|
39
|
+
month abbreviations).
|
|
40
|
+
- `readEach: ReadSpec | ReadSpec[]` reads every source's value in turn before the first non-empty one is taken (e.g.
|
|
41
|
+
`[STRIP, DECODE]`: a header that is empty once cleaned gives way to the dialog param), so `from: [header, param, …]`
|
|
42
|
+
replaces a raw field per source and a `firstOf` over them.
|
|
43
|
+
- `read` cleans the sourced value first (a reader of the data language: `msisdn`, `amount`, `date` orders, `personName`,
|
|
44
|
+
`flag` …; `expressions.md` § Readers).
|
|
45
|
+
- `from` as an expression (`{ daysBetween: [{ fact: 'today' }, { var: 'due' }] }`, `{ cases }`, `{ bands }` …)
|
|
46
|
+
computes a field from the fields declared before it and the call facts (`{ fact: 'today' }` in `input.timeZone`,
|
|
47
|
+
`now`, `hour`, `minute`); `{ call: 'today' }` reads the same day as a source. Day arithmetic: `{ addDays }`.
|
|
48
|
+
- `dialogEnv: [{ key, value, unless?, on? }]` (`value` an expression of the call, `unless` a condition on `{ self: true }`) writes values to the dialog env (`undefined` leaves the key; `unless`
|
|
49
|
+
skips a value already there): when the call is set up (`on: 'call'`, default: the live pass and the failed-leg pass),
|
|
50
|
+
or on every pass once the variables are read (`on: 'everyPass'`: also the pre-call pass and the passes after a leg).
|
|
51
|
+
A later pass reads them as `call.memory` / `{ dialogEnv }` (e.g. a client callback URL the after-call pass needs when
|
|
52
|
+
its own dialog params lack it).
|
|
53
|
+
- `group` builds a nested object for the prompt (its `prompt: false` members stay in the vars only).
|
|
54
|
+
- The prompt payload is every field with `prompt` not false, in declaration order.
|
|
55
|
+
- `prompt: false` keeps a field out of the prompt (report-only); `'omitEmpty'` drops the key when empty.
|
|
56
|
+
- `required`: a missing field is logged (`onMissing: 'log'`, the only mode).
|
|
57
|
+
- `testData`: switched on by a source (e.g. a CMS global); `values` fixed, or `presets` as data picked by the value that
|
|
58
|
+
switched it on (a preset name or number picks a record; § Test records as data);
|
|
59
|
+
`onlyWhenEmpty` never overrides real data (per field);
|
|
60
|
+
`unlessAnyOf: [fields]` uses no test value at all when any of those fields has a value from its own sources (a real
|
|
61
|
+
customer record is never mixed with test values).
|
|
62
|
+
- `decode: 'uri'` on a field URI-decodes a string read from an `X-*` header (`header` / `proto` source); a malformed
|
|
63
|
+
value is kept as it is.
|
|
64
|
+
- A `group` none of whose fields reach the prompt is not in the prompt (a bag of raw dialer values).
|
|
65
|
+
- A computed field may build a whole client object once (e.g. the client's reading of the row) for later fields,
|
|
66
|
+
rules and the report to read (`{ var }`).
|
|
67
|
+
- The integration context (which input entities were missing) is logged once per call.
|
|
68
|
+
|
|
69
|
+
## Prompt
|
|
70
|
+
|
|
71
|
+
See `agent-file.md` § prompt. The platform renders the template with the call variables plus the library's own:
|
|
72
|
+
`reply_language`, `reply_language_provisional`, gate flags, `today`, `now`. Scenario-dependent wording is
|
|
73
|
+
`prompt.variants`: the first set whose `when` holds is added after the input fields (and `vars`) at every request.
|
|
74
|
+
A call variable set during the call (e.g. the unclear-reply count of `turn.replyRules`) reaches the request through
|
|
75
|
+
`vars` / `variants` too: `variants: [{ when: true, vars: { object: { unclear_streak: { var: 'unclear_streak' } }, omitEmpty: true } }]`.
|
|
76
|
+
|
|
77
|
+
## Extraction
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
extraction: {
|
|
81
|
+
model: 'platform', // or { provider, endpoint, deployment, key: { storage: 'llm_key' } }
|
|
82
|
+
entities: [
|
|
83
|
+
{ name: 'ptp', description: 'Promise to pay: date and amount the customer agreed to, relative to {today}.', schema: {...}, implies: 'PTP', priority: 1 },
|
|
84
|
+
{ name: 'refuse', description: '...', schema: {...}, implies: 'REFUSE', priority: 2 },
|
|
85
|
+
],
|
|
86
|
+
vars: { object: { today: { var: 'today' } } },
|
|
87
|
+
summary: { language: 'en' },
|
|
88
|
+
normalize: [{ entity: 'ptp', fix: { cases: [{ when: { self: true, eq: 'null' }, value: null }], else: { self: true } } }],
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- Runs after the call on the transcript (or the per-call LLM dialog with `platform.llmDialogPerCall`).
|
|
93
|
+
- `implies` + `priority`: the extracted entity with the best priority sets the extracted result.
|
|
94
|
+
- `when` (a condition) on an entity: it is asked for only on calls where it holds (e.g. a name check only when the record has a
|
|
95
|
+
name); otherwise it is neither in the request nor in the row.
|
|
96
|
+
- `prompt` replaces the extraction prompt; to extend the library's own, build on `DEFAULT_EXTRACT_PROMPT` (exported
|
|
97
|
+
from `@voctiv/agent-runtime/templates`).
|
|
98
|
+
- `description` is a `Text`: `{placeholders}` from `extraction.vars`.
|
|
99
|
+
- Keys of an own model never go into the file: `key` is a `Source` (`storage`, `global`, `env`), read after the call;
|
|
100
|
+
no key → the platform model (logged). The model goes to the platform as `{ apiKey, baseUrl: endpoint, provider,
|
|
101
|
+
...settings, deploymentName: deployment }`; `fallback` (same shape) is asked again when the first pick is listed in
|
|
102
|
+
`recheckOn`. `fieldOrder: ['apiKey', 'kwargs', …]` puts the listed fields of the object sent first, in that order
|
|
103
|
+
(some ports must send the model exactly as the old agent did).
|
|
104
|
+
- `normalize` runs on the entities before the result is decided and before they reach the row.
|
|
105
|
+
- `normalize`: per-entity fixes (`fix`: an expression of the value `{ self: true }`). Expressions run after the call
|
|
106
|
+
see the conversation: the transcript conditions, the conversation's rule `{ counter }` and `{ flag }`,
|
|
107
|
+
`{ fact: 'preResult' }`.
|
|
108
|
+
- `rules` (`ExtractionRule[]`, data, after `normalize`, before the result is picked; only when the entities are not
|
|
109
|
+
empty): ordered entity fixes. Each may hold `when` (a `Condition` over the running entities `{ entity }`, the call,
|
|
110
|
+
`{ fact: 'preResult' }`, and the locals `picked` — the result the running entities imply by priority — and
|
|
111
|
+
`extracted` — the extractor's own entities). Forms:
|
|
112
|
+
- `{ set: { name: Expr }, from?: 'extracted', clearAbove?: name, onlyPresent? }` — set values (read the entities
|
|
113
|
+
before the rule; `{ omit: true }` sets nothing); `from: 'extracted'` restarts from the extractor's entities;
|
|
114
|
+
`clearAbove` then makes `false` every entity implying a result of a higher priority than that entity;
|
|
115
|
+
`onlyPresent` adds no new keys;
|
|
116
|
+
- `{ entity: name | '*', op: 'nullStrings', match?, value? }` (trimmed text matching `match`, default `/^null$/i`,
|
|
117
|
+
→ `value`, default `null`), `{ entity, op: 'trim' }`, `{ entity, op: 'emptyAs', value }`,
|
|
118
|
+
`{ entity, replace: { re, with } }` (texts only);
|
|
119
|
+
- `{ entity: name | '*', allowed: ['a', 'b'] | { fromDescription: 'VALUES:' }, otherwise?: '', nullAs?: 'keep' |
|
|
120
|
+
'otherwise', write?: 'asIs' | 'trimmed' }` — a closed vocabulary (the trimmed text, not-a-text as `''`; with
|
|
121
|
+
`fromDescription` the list is the first description line starting with the marker, text entities only);
|
|
122
|
+
`{ entity, pattern: RegExp, … }` the same with a pattern;
|
|
123
|
+
- `{ coerce: { name: 'boolean' | 'number' | 'text' }, keepOthers?: false }`;
|
|
124
|
+
- `{ entity, op: 'restoreDecimalOf', refs: [Expr…], ignore?: '₹,' }` (an amount that is a reference with its decimal
|
|
125
|
+
point deleted becomes the reference) and `{ entity, op: 'capAt', refs: [Expr] }` (an amount above the reference,
|
|
126
|
+
to two decimals, becomes it); also usable from `results.rules[].then.fix`;
|
|
127
|
+
- transcript-backed corrections (each may hold `when`; a «filled» slot is a text not blank, `null` or `none`; the
|
|
128
|
+
words, aliases and line patterns are the agent's data). A `ReadBack` describes a line the agent reads back for
|
|
129
|
+
the caller to confirm: `{ line, closing, rejected, correction?, yes?, correctionYes?, skip? }` — the read-back is
|
|
130
|
+
«closed on» when the latest `line` before the last agent line matching `closing` got no caller answer matching
|
|
131
|
+
`rejected` (after `correction`, only the answers to it count); `skip`: agent lines (trimmed text) an answer is read
|
|
132
|
+
past to the line it answers (silence probes). A `ChoiceOption` is `{ key, value?: Expr, words?: string[], pick?:
|
|
133
|
+
Matcher, amount?: Expr }` (`words` are whole words on the line lower-cased with non-letters as spaces):
|
|
134
|
+
- `{ snapToReference: { entity, to: [Expr…] } }` — a filled amount whose digits (or number) are a reference's is
|
|
135
|
+
written as that reference text (`140316` → `1403.16`);
|
|
136
|
+
- `{ choice: { entity, options, askedBy?, yes?, readBack?, skip?, clearUnsaid?, language? } }` — the option the
|
|
137
|
+
caller chose, latest line first: `pick` words, a number nearest an option's `amount` (same whole units, within
|
|
138
|
+
10 %, digits inside) when answering an agent line matching `askedBy`, or a `yes` to an agent line naming one
|
|
139
|
+
option's amount; a closed-on read-back naming one amount wins; several picked in the latest line keep the
|
|
140
|
+
extracted one if it is among them. Nothing chosen with `clearUnsaid`: a filled value that is an option's amount,
|
|
141
|
+
or whose whole number the caller never said, is cleared;
|
|
142
|
+
- `{ dateNotPast: { entity, layout: 'YY.MM.DD', today?: Expr } }` — a filled day before today: a month more than
|
|
143
|
+
six months ahead is read as this month's day, still past → `''` (layout tokens `YYYY` `YY` `MM` `DD`);
|
|
144
|
+
- `{ fromConfirmedLine: { readBack, unless?, date?: { entity, layout, todayWords?, today?, parse?, language? },
|
|
145
|
+
option?: { entity, options }, set? } }` — the call closed on the read-back: its day (`todayWords` → today, else
|
|
146
|
+
the first day the locale's `parse.dates` reads with `parse` that is not past), its single named option, `set`;
|
|
147
|
+
- `{ corroborate: { entity, options, yes, readBack?, skip? } }` — a filled option stays only when the caller said
|
|
148
|
+
one of its `words`, said `yes` to an agent line naming only it (latest such answer), or the closed-on read-back
|
|
149
|
+
names only it; else `''`; an empty one is filled from such a `yes`;
|
|
150
|
+
- `{ require: { flags, slots: [{ when?, entities }…], backfill?: { entity, value, when? } } }` — a slot of the
|
|
151
|
+
first entry whose `when` holds is not filled → every flag `false`; else `backfill` fills its empty entity;
|
|
152
|
+
- `{ requireConfirmed: { readBack, flags } }` — a flag is `true` but the read-back was neither closed on nor
|
|
153
|
+
answered `yes` (or `correctionYes` / `yes` to `correction` after it) → every flag `false`.
|
|
154
|
+
Strict booleans in conditions: `{ of: { json: { entity: 'x' } }, eq: 'true' }` (`isTrue` also takes the text).
|
|
155
|
+
```ts
|
|
156
|
+
rules: [
|
|
157
|
+
{ entity: '*', op: 'nullStrings' },
|
|
158
|
+
{ when: { all: [{ entity: 'wrong_number', truthy: true }, { entity: 'claims_no_loan', truthy: true }] }, set: { claims_no_loan: false } },
|
|
159
|
+
{ when: { all: [{ fact: 'preResult', eq: 'refusal' }, { local: 'picked', notIn: ['promise_to_pay'] }] },
|
|
160
|
+
from: 'extracted', set: { refusal: true }, clearAbove: 'refusal' },
|
|
161
|
+
]
|
|
162
|
+
```
|
|
163
|
+
The same list as a row-only view: report field `{ entities: '*', view: rules, pick?: ['name'] }` writes the
|
|
164
|
+
entities as the view leaves them (all, or the `pick` keys) in a connected call's row; the decision keeps the
|
|
165
|
+
extractor's entities (a client's «sanitized» columns, an aligned copy after `{ entity: '*' }`).
|
|
166
|
+
- Results with `extract: false` (technical: voicemail, no answer) skip extraction.
|
|
167
|
+
- `onFailure` (a failed extract request, after `retry`): `'failureResult'` (default) — `extract request failure`;
|
|
168
|
+
`'keepDecided'` — the result the call decided itself (a fixed close's, e.g. a request not to be called), not
|
|
169
|
+
`goodbye`, `default` or a technical one; `'keepResult'` — the call's own pre-result whatever it is (see below).
|
|
170
|
+
- `retry: { max, backoffFactor?, attemptTimeoutMs? }`: a failed extract request (an error, or `attemptTimeoutMs`
|
|
171
|
+
passed) is sent again up to `max` times, the n-th after `backoffFactor ** n` seconds (default one request, as long
|
|
172
|
+
as the gateway takes).
|
|
173
|
+
- A call the operator transfer took over (`transfer.whileBridged.skipExtraction`) is reported without extraction,
|
|
174
|
+
except `transfer.extract`: those entities (only ones that imply no result) are still extracted and go in front of
|
|
175
|
+
`transfer.entities` (a failed request is logged and leaves them out).
|
|
176
|
+
|
|
177
|
+
## Lookup at answer
|
|
178
|
+
|
|
179
|
+
`input.lookup: { integration, field, result? }` reads the call's data from a client service at answer on a live call,
|
|
180
|
+
while the opening's first clip plays: the integration of `phase: 'lookup'` named by `integration` (its request built
|
|
181
|
+
from the input fields; its `value` reads the answer) gives the value of the field `field`, and the call's variables are
|
|
182
|
+
built again with it (every field computed from it follows: prompt variables, texts, step conditions, the
|
|
183
|
+
row). LLM requests wait for it (an eager greeting is requested once it is in, its step's `when` reading the new
|
|
184
|
+
variables); the row of a call that ended first waits for it too. `result` (an expression of the variables): the call's result from
|
|
185
|
+
then on (a record the client says must not be talked to), unless the call is closing. A lookup that fails leaves the
|
|
186
|
+
variables as they were. Typical: a field the lookup fills, fields computed from it, an `llmGreeting` with `when` and a
|
|
187
|
+
last `close` step (text and result expressions) for a lookup that closes the call.
|
|
188
|
+
|
|
189
|
+
## Results
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
results: {
|
|
193
|
+
table: {
|
|
194
|
+
PTP: {},
|
|
195
|
+
REFUSE: {},
|
|
196
|
+
DEFAULT: { recall: true },
|
|
197
|
+
silence: { recall: true, extract: false },
|
|
198
|
+
voicemail: { recall: true, extract: false },
|
|
199
|
+
transfer_connected: { outranksExtraction: true },
|
|
200
|
+
},
|
|
201
|
+
fromFacts: [
|
|
202
|
+
{ at: 'callEnd', when: { fact: 'callerFinals', eq: 0 }, result: 'silence' },
|
|
203
|
+
{ at: 'goodbye', when: { fact: 'callerTurns', lt: 2 }, result: 'bad connection' },
|
|
204
|
+
],
|
|
205
|
+
rules: [{ when: { entity: 'ptp', empty: false }, then: { result: 'PTP' } }],
|
|
206
|
+
labels: { map: { PTP: 'A' } },
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Order of decision:
|
|
211
|
+
|
|
212
|
+
1. During the call a result may be set by actions (`close`, `hangup`), the voicemail detector, transfer, timeouts —
|
|
213
|
+
the **pre-result**.
|
|
214
|
+
2. `fromFacts` rules at `goodbye` / `silenceLimit` / `callEnd` may change it from what the caller did. Their call view
|
|
215
|
+
has `result` (the result so far), `callerTurns`, `callerFinals`, `phase` (`closing` when the agent was ending the
|
|
216
|
+
call), the rule `counters` and `flags` (e.g. «a question was answered» → `answered`) and at a goodbye `afterSilence` (the reply answered a silence turn).
|
|
217
|
+
`greetingDropUntil: 'callerTurn'` keeps `greeting drop` until the caller's first turn (an answer to the opening's
|
|
218
|
+
liveness check is none); default `'openingEnd'`.
|
|
219
|
+
3. Extraction (unless the result has `extract: false`) gives the **extracted result**.
|
|
220
|
+
4. The final result is the extracted one, unless the pre-result `outranksExtraction`.
|
|
221
|
+
5. `rules` (`results.rules`, data) change the result, the entities, the extracted result and the redial in order;
|
|
222
|
+
they have the last word.
|
|
223
|
+
6. `labels.map` renames labels in the row's `result` field (after `rulesOn: 'report'` rules and the catalog label).
|
|
224
|
+
|
|
225
|
+
`table` is merged over the library's base table — the result canon (`silence`, `voicemail`, `greeting drop`,
|
|
226
|
+
`bad connection issue`, `goodbye` (reported as `default`), `extract request failure`…); the key `'*'` applies to
|
|
227
|
+
every label (under the label's own entry). `recall: true` books a redial (budget and delay from `platform.recall`)
|
|
228
|
+
and is the row's `triggers_callback`; rows with `recall` are not final. A client's result tree is `results.rules`
|
|
229
|
+
(the result, the redial — `recall: 'keep'` keeps the one decided before the rules —, the entities the row shows when
|
|
230
|
+
the client's rules also rewrite them: a promise recovered from the transcript, a date gate that turns a promise into a
|
|
231
|
+
refusal, and the extracted result); they read `{ fact: 'endedBy' }` and the call's flags (e.g. `closing.afterSilence`).
|
|
232
|
+
Use `extraction.normalize` only for fixes that may change the extracted result too.
|
|
233
|
+
|
|
234
|
+
`extraction.onFailure: 'keepResult'`: a request that failed (after `retry`) keeps the call's own pre-result (the
|
|
235
|
+
result is decided from it, no entities; fact `extractionFailed` and `call.extractionFailed` in the row say it failed)
|
|
236
|
+
instead of `extract request failure`. `extraction.requestOrder`: key order of the request (`dialogUuid`, `prompt`,
|
|
237
|
+
`call_summary`, entity names; the rest follow). `extraction.namesDialog`: the request names the LLM dialog also when
|
|
238
|
+
that is the CMS dialog (`platform.llmDialogPerCall: false`).
|
|
239
|
+
|
|
240
|
+
`extraction.catalog(call)`: the entities of this call when they depend on it (one catalog per scenario): the request
|
|
241
|
+
and the row's entity columns use them; `extraction.entities` still lists every entity any call can have. As data:
|
|
242
|
+
`catalog: { cases: [{ when: { var: 'is_overdue' }, value: OVERDUE_ENTITIES }], else: PREDUE_ENTITIES }` (the first
|
|
243
|
+
case that holds; no `else` → `entities`).
|
|
244
|
+
|
|
245
|
+
`remember: [{ key, value(row, call) }]` keeps values for the next attempts of the dialog (`call.memory`, the dialog
|
|
246
|
+
env under `key`), written after the row and before the redial; `undefined` leaves the key. With an integration's
|
|
247
|
+
`answer(response, call)` reading `call.memory`, this is how a client rule like «ignore the CRM's no after a dropped
|
|
248
|
+
leg» stays data.
|
|
249
|
+
|
|
250
|
+
### Result rules (`results.rules`)
|
|
251
|
+
|
|
252
|
+
Client result logic as data (result trees, promise guards, «a call that ended on this question» dispositions, a
|
|
253
|
+
label by how far a promised date is): an ordered list of `{ when?, then, stop?, log? }`. Each rule sees the running
|
|
254
|
+
decision — `{ fact: 'result' }`, `{ fact: 'preResult' }`, `{ fact: 'extractedResult' }`, the running entities
|
|
255
|
+
(`{ entity }`), the call (transcript conditions, variables, `flag`, `endedBy`; the state blocks too: `{ fact: 'stage' }`,
|
|
256
|
+
`{ stage }`, tracking line flags — also in `results.catalog`, `extraction.rules` and report rows) and the named facts
|
|
257
|
+
`extractionSkipped`, `entitiesExtracted` (extraction ran and returned entities), `pickedResult` (the result the
|
|
258
|
+
running entities imply by priority), `nextResult` (the same without the extracted result). The first rule that holds
|
|
259
|
+
ends the list; `stop: false` goes on with the decision so far (a chain of checks).
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
results: {
|
|
263
|
+
rules: [
|
|
264
|
+
{ then: { recall: 'byResult' }, stop: false }, // the redial is the final result's
|
|
265
|
+
{ when: { all: [{ flag: 'closing.afterSilence' }, { fact: 'result', in: ['default', 'busy'] }] },
|
|
266
|
+
then: { result: 'bad connection issue' }, stop: false },
|
|
267
|
+
{ when: { all: [{ fact: 'extractedResult', eq: 'promise_to_pay' }, { entity: 'conditional_promise', truthy: true }] },
|
|
268
|
+
then: { result: 'refusal', extractedResult: 'result' }, stop: false, log: 'promise_validation' },
|
|
269
|
+
{ when: { fact: 'extractedResult', eq: 'promise_to_pay' },
|
|
270
|
+
then: { result: { cases: [{ when: { entity: 'promised_date', days: { from: { var: 'today' }, max: 0 } }, value: 'PTP today' }], else: 'PTP later' } } },
|
|
271
|
+
],
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
`then` (applied in this order):
|
|
276
|
+
- `fix`: entity fixes of `extraction.rules` (`restoreDecimalOf`, `capAt`, `nullStrings`…); `eachEntity: { when, value }`:
|
|
277
|
+
every entity value for which `when` holds (`{ self: true }` is the value) becomes `value`; `entities`: named
|
|
278
|
+
entities set to expressions over the entities before this step (`{ omit: true }` sets nothing);
|
|
279
|
+
- `result`: a label; an expression (`cases`, `lookup`, `template`; `null` / `''` keeps the result); `'preResult'` (as
|
|
280
|
+
reported: `goodbye` is `default`); `'nextByPriority'` (the best truthy entity whose result is not the extracted
|
|
281
|
+
one, else the pre-result); `{ bestEntityExcept: [...], else? }`; `{ firstTrueEntity: [names], else? }` (the first
|
|
282
|
+
entity that is `true` / `'true'` gives its own name). A result picked from the entities is also the new extracted
|
|
283
|
+
result (`null` when it fell back);
|
|
284
|
+
- `extractedResult`: `'keep'` (default), `'pick'` (picked again from the entities after the rule), `'result'`, a label,
|
|
285
|
+
`null`;
|
|
286
|
+
- `recall`: `'keep'` (as decided before the rules), `'byResult'` (the final result's `table` entry), or a condition
|
|
287
|
+
(`true` / `false` / a question about the new result). The last rule that sets one wins; none: unchanged result keeps
|
|
288
|
+
its redial, a new one reads `table`;
|
|
289
|
+
- `suffix: { text, when? }`: appended to the row's result label (after `labels.map`) when `when` holds on the decision
|
|
290
|
+
after the rule (« prolongation» on a promise label).
|
|
291
|
+
|
|
292
|
+
`rulesOn: 'report'`: the rules only rewrite the row's `result` field (the decision, the redial and the integrations
|
|
293
|
+
keep the result; `escalation` → `escalation_<reason>`).
|
|
294
|
+
|
|
295
|
+
`table[label].extractWhen: { when, only }` on a result that skips extraction (`extract: false`, or a technical
|
|
296
|
+
result): when `when` holds on the call, extraction still runs; the result the entities pick after `extraction.normalize`
|
|
297
|
+
and `extraction.rules` replaces the label only when it is in `only` (otherwise, and on a failed request, the result
|
|
298
|
+
stays as if skipped — no extracted result, no entities, no summary; logged `extraction_kept_result`).
|
|
299
|
+
|
|
300
|
+
Transcript question for these rules: `{ callerAfterLast: { agent, line?, scope?, question? } }` (`expressions.md`) —
|
|
301
|
+
the caller's answer around the agent's last line of a kind, each answer tested by a condition on the line.
|
|
302
|
+
|
|
303
|
+
### Result catalog (`results.catalog`)
|
|
304
|
+
|
|
305
|
+
The client's label sheet as data: the decided result (the **token**) or a label the extractor picked maps to the
|
|
306
|
+
client's label and its columns.
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
results: {
|
|
310
|
+
catalog: {
|
|
311
|
+
scenario: { var: 'call_direction' }, // picks a sheet ('*' when absent or missing)
|
|
312
|
+
values: { debtor: [{ value: 'Will pay', covers: ['promise', 'paid today'], aliases: ['promise'] }, …] },
|
|
313
|
+
entity: 'client_result', // the label the extractor picked from the sheet
|
|
314
|
+
match: 'trim', // 'exact' | 'trim' | { key: Expr of { self: true } }
|
|
315
|
+
accept: [{ sheet: 'debtor', value: 'Will pay', requires: { any: [{ local: 'token', eq: 'promise_to_pay' }, …] } }],
|
|
316
|
+
byToken: { debtor: { voicemail: 'Technical', promise_to_pay: [{ when: …, label: …, columns: { kpi: 'True' } }, { label: … }], '*': 'Technical' } },
|
|
317
|
+
default: 'Unknown', // absent: the token itself
|
|
318
|
+
strictValues: true, // a token's label off the sheet → the sheet's default
|
|
319
|
+
unanswered: { label: 'no answer', when: { rowKind: ['failedLeg'] } },
|
|
320
|
+
columns: { names: ['result1', 'result2'], table: { silence: ['Failed', 'Silence'] }, default: ['Ok', null],
|
|
321
|
+
failedRow: ['Failed', 'Unavailable'], skipWhen: …, failedWhen: …, overrides: [{ when: { local: 'cells.0', eq: 'Failed' }, row: […] }] },
|
|
322
|
+
text: { line: '- {value} — covers: {covers}', coversSep: ' | ', valuesSep: ', ' },
|
|
323
|
+
vars: { text: 'catalog_text', values: 'catalog_values' }, // extraction variables for `{placeholders}`
|
|
324
|
+
applyTo: 'row', // 'row' | 'result' | 'fields'
|
|
325
|
+
},
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
- The label: a leg matching `unanswered` gets that label; else the extracted label when the entity's value meets a
|
|
330
|
+
sheet value (labels first, then `aliases`; `match`) and every `accept` rule that applies to it holds (locals
|
|
331
|
+
`label`, `token`; `value` is a label, a list or `{ except }`); else the token's entry of the sheet (`byToken`),
|
|
332
|
+
the sheet's `'*'`, `default`, the token itself. An entry is a label, an expression, an item `{ when?, label,
|
|
333
|
+
columns? }` or items tried in order. The token is `token` (an expression) or the decided result (`'undefined'`
|
|
334
|
+
when none).
|
|
335
|
+
- `applyTo: 'row'` (default): the row's `result` field is the label (before `labels.map`); `'result'`: the label is
|
|
336
|
+
the result after `results.rules` (the redial stays as decided; `cancel` and the redial read the label);
|
|
337
|
+
`'fields'`: only the report fields below.
|
|
338
|
+
- Report fields: `{ catalog: 'label' }`, `{ catalog: 'fallback' }` (true when the extractor's label was not on the
|
|
339
|
+
sheet or not accepted, also on an unanswered leg), `{ catalog: { column } }` (an item's / value's column, else a
|
|
340
|
+
tree column), `{ catalog: 'columns' }` (the tree spread: `key` default the row's `result` written so far; `skipWhen`
|
|
341
|
+
writes nothing; `failedWhen`, default a null key, writes `failedRow` or nothing; a key off the table is `default`;
|
|
342
|
+
the first `override` whose `when` holds — locals `cells`, `key` — replaces the cells; `null` cells are `nullAs`,
|
|
343
|
+
default `''`). Each takes `when` / `otherwise` (not written / this value when `when` does not hold).
|
|
344
|
+
- Sets of labels (KPI, redial) are plain lists in conditions: `{ row: 'result', in: KPI }`.
|
|
345
|
+
- `vars`: the shown labels (`hideFromExtractor` left out) as `text` lines and `values`, added to the extraction
|
|
346
|
+
variables.
|
|
347
|
+
|
|
348
|
+
## Voice variants in the row
|
|
349
|
+
|
|
350
|
+
`voice.tts.variants`: the call's variant tag is the row's `fact: 'voiceTag'` (null on a dial that never connected) and
|
|
351
|
+
`call.voiceTag`; `platform.dialogLocale.voiceFlag: '{voice}'` puts it on the CMS dialog.
|
|
352
|
+
|
|
353
|
+
## Report row
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
report: {
|
|
357
|
+
fields: {
|
|
358
|
+
result: { fact: 'result' },
|
|
359
|
+
pre_result: { fact: 'preResult' },
|
|
360
|
+
call_status: { fact: 'status' },
|
|
361
|
+
call_start_time: { fact: 'startTime' },
|
|
362
|
+
attempt: { fact: 'attempt' },
|
|
363
|
+
customer_name: { var: 'customer_name' }, // a key as written, else a dotted path (`{ var: 'customer.name' }`)
|
|
364
|
+
ptp_date: { entity: 'ptp.date', nullish: null },
|
|
365
|
+
entities: { entity: '*' }, // every entity, null when not extracted
|
|
366
|
+
lang: { fact: 'language', map: { kk: 'kaz' }, default: 'rus' },
|
|
367
|
+
},
|
|
368
|
+
startTimeFormat: 'iso-ms',
|
|
369
|
+
failedDialRow: 'once',
|
|
370
|
+
service: { recordLink: 'player', callStatus: 'answer', failedDialStartTime: 'attempt' }, // the defaults
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Facts: `result`, `preResult`, `extractedResult`, `status` (row status for the platform), `triggersCallback`, `extractionFailed`,
|
|
375
|
+
`extractionSkipped`, `attempt`, `durationSec`, `asrDurationSec`, `sipCode`, `sipPhrase`, `callUuid`, `dialogUuid`,
|
|
376
|
+
`llmDialogUuid`, `transcript`, `summary`, `startTime`, `recordUrl`, `transcriptUrl`, `llmLogUrl`, `voiceTag`,
|
|
377
|
+
`endedBy`, `language` (the reply language the call ended in, as `prompt.languageNames` names it; null on a row of a
|
|
378
|
+
leg that never connected), `agentVersion`. `callUuid` placed after `{ fact: 'service' }` adds the leg's call UUID to a
|
|
379
|
+
failed-leg row (a connected call's service fields already carry it).
|
|
380
|
+
|
|
381
|
+
`{ fact: 'service', omit: [...] }` leaves service fields out (e.g. `call_status` when the client's row never had it).
|
|
382
|
+
`report.unansweredLegRow: true` (with `outboundMode: 'from_invite'`, no `failedLegPass`): the live pass of a leg nobody answered writes its row — like a failed leg's (`result` `undefined`, no extraction facts or entities), service fields `status` `-ERR`, `call_status`, `call_status_phrase`, `attempt`, `call_start_time`, `call_uuid` — and the headless passes write nothing. Report fields read `{ fact: 'connected' }` (false on a row of a leg that never connected, a cancelled or headless pass) and, on every row of a connected call (also one whose extraction never ran), the conversation (transcript conditions, `{ fact: 'callerFinals' }` …).
|
|
383
|
+
`report.headlessRow: true`: a pass with no call (the pre-call pass of an inbound agent, an `after_call_failed`
|
|
384
|
+
continuation with nothing else to report) returns a row of the `var` / `value` / expression fields and `result`
|
|
385
|
+
(`undefined`) instead of nothing. Report fields read the operator transfer's progress as `{ fact: 'transferStarted' }`,
|
|
386
|
+
`transferCompleted`, `transferStartedAt`.
|
|
387
|
+
|
|
388
|
+
Spreads: `{ entity: '*' }` writes the entities extraction returned (none when skipped or failed); `{ fact: 'service' }`
|
|
389
|
+
writes the platform's service fields at that place (status, attempt, duration, start time, SIP status, transcript,
|
|
390
|
+
ids, CMS links per `platform.links` — `buildCommonFields` of `src/call/output.ts`), appended at the end when not listed;
|
|
391
|
+
`{ fact: 'service', without: [...] }` leaves some of them out (an older row layout without `call_start_time` /
|
|
392
|
+
`call_status`); an expression field listed after it may rewrite one in place (key order stays). A failed
|
|
393
|
+
dial (no connection) produces the same row shape: every entity null and first in the row (named fields win), `result`,
|
|
394
|
+
`preResult`, `extractedResult`, `summary` null, `triggersCallback` true. A row whose extraction threw has only the
|
|
395
|
+
`var` / `value` / expression fields, `result` (`undefined`), the call facts (`asrDurationSec`, `callUuid`, SIP code…) and
|
|
396
|
+
the service fields — no extraction facts, no entities. `labels.map` renames `result` after the row is built.
|
|
397
|
+
|
|
398
|
+
- A field that throws on the call's data is written null (a spread, `catalog: 'columns'` or a `view` without `pick`
|
|
399
|
+
writes nothing), logged as `report_field_failed` with the field and the error; the row is written and the
|
|
400
|
+
integrations and the redial go on. A row the runtime cannot build at all (the error row, a failed dial's or a failed
|
|
401
|
+
leg's) is replaced by a minimal one — `result` `undefined`, `status` `-ERR`, `triggers_callback` false and the service
|
|
402
|
+
fields that are known — logged as `report_row_failed`.
|
|
403
|
+
- An expression field reads the row so far (`{ row }`) and the call (`{ fact: 'rowKind' }` — the row's `kind` (`call`, `error`:
|
|
404
|
+
extraction did not run or failed, `failedDial`, `failedLeg`, `cancelled`, `headless`), `connected` (`call` / `error`),
|
|
405
|
+
`service` (the service fields as `{ fact: 'service' }` writes them), `callUuid`, `dialogUuid`, `asrDurationSec`,
|
|
406
|
+
`sipCode`, `sipPhrase`, `replyLanguage` (`null`: none) / `replyLanguageProvisional`; a client row of its own columns
|
|
407
|
+
is built from them with `service: false`), `{ entity }`, `{ fact: 'result' }` — the decided label before
|
|
408
|
+
`labels.map`, `preResult` / `extractedResult` / `triggersCallback` — `null` on rows without them; after the call
|
|
409
|
+
also `callerTurns` / `callerFinals`, the conversation's counts, and `endedAtMs`, when the call ended, before
|
|
410
|
+
extraction); `{ omit: true }` writes nothing (a field only some rows have).
|
|
411
|
+
`{ spread: { object: {…} } }` writes several fields at once in the order of the object (an entities block of the
|
|
412
|
+
client's own layout). Block fields (`blocks.md`): `{ knowledgeTrace: 'call' | 'notConnected' }` (the
|
|
413
|
+
`knowledgeAnswer` decision trace on a call's row / all-`null` on a dial that never connected) and
|
|
414
|
+
`{ catalogMatch: 'row', entities?: 'all' }` (the `catalogMatch` levels, reconcile and check keys on a call's row). `asrDurationSec` is whole seconds. `startTimeFormat: 'iso-ms'` writes the start time with
|
|
415
|
+
its milliseconds (the platform's status line has it to the second); `'iso-offset'` writes the wall clock of
|
|
416
|
+
`input.timeZone` to the second with its offset (`2026-09-08T15:10:12+08:00`). Named fields placed before
|
|
417
|
+
`{ fact: 'service' }` keep their place in the row when the service spread writes them (the key order of a client's
|
|
418
|
+
row); a `spread` field after `{ entity: '*' }` overwrites an entity's value in its place (a field that is both input
|
|
419
|
+
and entity).
|
|
420
|
+
`startTimeFormat: 'dd-mm-yyyy hh:mm:ss'` writes it in the script host's local time. `report.service` changes the service block where agents differ: `recordLink: 'records'` (the CMS records page instead of the player), `callStatus: 'signals'` (a connected call's `call_status` is the last SIP signal the leg's script saw — code and phrase, or its state — else the platform's call status, null when none; default `'200 OK'` once answered), `failedDialStartTime: 'none'` (a failed dial's row has no start time), `source: 'script'` (a connected call's service fields as the script saw the leg — the SIP code and phrase it saw, null when none; the answer as the start with ms; the recognizer's seconds; the reply language in `call.rowFacts` — as a `from_invite` agent writes them, also for an `on_answer` agent; default by `platform.outboundMode`). `failedDialRow`: `'once'` per dialog, `'oncePerLeg'` (a pass repeated for the same SIP leg writes none), `'everyAttempt'`; `failedDialEntities: 'inPlace'` puts a failed dial's null entities where `{ entity: '*' }` stands (default first in the row). `service: false`: the platform's service fields are not appended (only the listed fields and facts are written). `beforeCallRow: true`: the pre-call pass (it schedules the first leg) writes a row too, built like a failed dial's (`call.preResult` null).
|
|
421
|
+
- A call the transfer took over (`transfer.whileBridged.skipExtraction`) is reported without extraction: `result` the
|
|
422
|
+
transfer's label, `extractionSkipped` true, entities `transfer.entities`.
|
|
423
|
+
- With `platform.failedLegPass`: the script schedules its leg
|
|
424
|
+
with the `after_call_failed` continuation (`legs.onFailedCall: null`: the platform's own, no handler named on the leg), the live pass of a leg nobody answered hands the SIP status over through
|
|
425
|
+
the dialog env and writes no row, and the headless `after_call_failed` pass writes the leg's row (kind `failedLeg`:
|
|
426
|
+
like a row whose extraction threw, `result` `undefined`, service fields `status` `-ERR`, `call_status`,
|
|
427
|
+
`call_status_phrase`, `attempt`, `call_start_time`; `callUuid` from the leg) and runs the after-call integrations;
|
|
428
|
+
with `legs.redialFailed: 'campaign'` it then redials the number by the campaign's contact rule (`agent-file.md`).
|
|
429
|
+
- `failedLegPass.statusFrom`: `'liveRun'` takes the SIP status the live pass handed over before the platform's;
|
|
430
|
+
`'none'` writes none (default `'host'`).
|
|
431
|
+
- A row in the client's own layout: `report.service: false` and every column an expression reading the row's facts
|
|
432
|
+
(its `kind`, the library's `service` fields — status, SIP code and phrase, attempt, start time, duration, ids —,
|
|
433
|
+
`callUuid`, `dialogUuid`, `asrDurationSec`, …) and the agent's lines (`{ lineTally }`: counts of fixed lines by their
|
|
434
|
+
mixer alias, how far the call got); `{ omit: true }` leaves a column out of rows that do not have it (a failed leg's
|
|
435
|
+
row).
|
|
436
|
+
- What the row knows of the leg follows `platform.outboundMode` (or `platform.followLeg: 'script'` on a script started
|
|
437
|
+
on the answer). `from_invite`: the script sees the INVITE's response
|
|
438
|
+
itself — the service fields carry the SIP code and phrase (`call_status`, `call_status_phrase`), the start is the
|
|
439
|
+
answer (ISO with ms), the record link is the records page, `asrDurationSec` counts the recognizer's seconds.
|
|
440
|
+
`on_answer` (default): the platform's final status line (`call_status: '200 OK'`), the platform's call start (to the
|
|
441
|
+
second), the player link, the attempt counted by the script at answer. Redials are booked only with
|
|
442
|
+
`platform.recall`.
|
|
443
|
+
|
|
444
|
+
Links: `platform.links: { host, llmHost?, dialogHost? }`. A host read from a source (`{ from: { global: 'platform' },
|
|
445
|
+
map: { idn: … }, default: … }`) is resolved after the call: the row is built with the default and its links move to
|
|
446
|
+
the resolved host before the row is reported.
|
|
447
|
+
|
|
448
|
+
## Integrations
|
|
449
|
+
|
|
450
|
+
Written as data: § Integrations as data below.
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
integrations: [
|
|
454
|
+
{ id: 'crm', phase: 'afterCall', when: 'answered', method: 'POST',
|
|
455
|
+
url: { from: { global: 'crm_url' } }, headers: { 'X-ApiKey': { from: { storage: 'crm_key' } } },
|
|
456
|
+
requestId: 'callUuid', timeoutMs: 10000, retries: 2, retryOn: '5xx', writeBack: 'send_call_result_status',
|
|
457
|
+
body: { object: { loan_id: { var: 'loan_id' }, result: { row: 'result' }, ptp_date: { row: 'ptp_date' } } } },
|
|
458
|
+
{ id: 'sms', phase: 'afterCall', when: { all: [{ row: 'result', eq: 'no_answer' }, { fact: 'attempt', gte: 3 }] },
|
|
459
|
+
enabledBy: { from: { global: 'followup_enable' }, equals: 'true' },
|
|
460
|
+
method: 'POST', url: { from: { global: 'sms_url' } }, body: { object: { to: { var: 'msisdn' }, text: '...' } } },
|
|
461
|
+
{ id: 'eligible', phase: 'preDial', method: 'GET', url: { from: { global: 'check_url' } }, answer: { test: { input: 'call', isTrue: true } }, timeoutMs: 3000 },
|
|
462
|
+
]
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
- `afterCall` integrations run after the row is built (after links and `remember`), in order, within the after-call
|
|
466
|
+
budget; a failure is logged and does not change the row unless `writeBack` names a field for the status.
|
|
467
|
+
`writeBack: { field, value }` writes what the expression `value` gives for the outcome (`{ input: 'applied' }`,
|
|
468
|
+
`skipped`, `status`, `error`)
|
|
469
|
+
(`applied: false` on a row `when` excluded; `undefined` writes nothing) — e.g. a client's own status texts.
|
|
470
|
+
- `url` may use `{dialogUuid}`, `{callUuid}`, `{msisdn}` and call variables; `path` is appended to the resolved URL
|
|
471
|
+
with its trailing slashes removed (a base URL from storage + a fixed path). A header that resolves to nothing (key not
|
|
472
|
+
configured) skips the request (logged `<id>_skipped`). `body` is an expression (`{ object }` …; `{ row }` reads the row);
|
|
473
|
+
it is sent as JSON. Requests go through the library's HTTP client (event `<id>_http`, `X-Request-Id` per
|
|
474
|
+
`requestId`, default timeout 15 s, redirects not followed — a 3xx is a failure, the logged URL has no query);
|
|
475
|
+
retries per `retries` / `retryOn`, 500 ms apart; a POST is repeated only when it certainly did not arrive (connection
|
|
476
|
+
refused, DNS) or on a 5xx other than 504, unless an `Idempotency-Key` header is set (then also after a timeout); placeholder
|
|
477
|
+
values are URL-encoded; a `when` or `writeBack.value` that fails skips the integration / writes nothing (logged);
|
|
478
|
+
an after-call data `when` reads `{ fact: 'connected' }` (the leg was answered) and `{ fact: 'rowKind' }` (`call` /
|
|
479
|
+
`failedDial`);
|
|
480
|
+
nothing throws.
|
|
481
|
+
- A client service with a protocol of its own (a token from a login, several requests) is a request kind of the
|
|
482
|
+
library (`kind: 'startAgentDialog'` / `'askAgent'` below), or a new generic one added to the library.
|
|
483
|
+
- `preDial`: `answer` (an expression of the answer's JSON, `{ input: 'path' }`) gives true / false, or `null` for an
|
|
484
|
+
unusable answer; a failed request or `null`
|
|
485
|
+
dials only with `failOpen`; a switched-off gate dials.
|
|
486
|
+
- `preDial` integrations gate every dial (`platform.preDial`).
|
|
487
|
+
- `call.outcome` in the after-call view: the decided `result`, `preResult`, `triggersCallback` and `entities` of a
|
|
488
|
+
connected call (`null`: its extraction threw; absent on a leg that never connected) — e.g. a callback booking the
|
|
489
|
+
time the caller named (`callbacks`, § Leg policy as data).
|
|
490
|
+
- The after-call view carries `call.recallScheduled` (this pass booked the next leg; `null` unless
|
|
491
|
+
`recall.beforeIntegrations`), `call.budget` (the campaign's redial budget) and `call.attempt`: «the last leg» is
|
|
492
|
+
`recallScheduled !== true || attempt >= budget`.
|
|
493
|
+
- URLs, keys and switches come from sources, never literals with secrets.
|
|
494
|
+
|
|
495
|
+
## Integrations as data
|
|
496
|
+
|
|
497
|
+
Every part of an HTTP integration may be data; locals of its expressions (`{ local: name }`, `{name}` in templates):
|
|
498
|
+
`dialogUuid`, `callUuid`, `direction` (`in` / `out` / null), the `inputs`, and after the answer `status`, `text`,
|
|
499
|
+
`json`, `err`, `ok`, `ms`, `url`, `body`, the `read.save` values (a lookup also `sipHeaders`, `outcome`, `why`).
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
{ id: 'crm', phase: 'afterCall', when: { row: 'client_id', empty: false }, method: 'POST', url: 'https://crm/api',
|
|
503
|
+
inputs: { key: { from: { storage: 'crm_key' } } }, // read before the checks that ask (afterInputs)
|
|
504
|
+
headers: { 'X-ApiKey': { local: 'key' }, Authorization: { bearer: { local: 'token' } } }, // or { basic: [user, password] }
|
|
505
|
+
query: { ref: { var: 'ref' } }, // empty values left out
|
|
506
|
+
skipWhen: [{ when: { var: 'msisdn', empty: true }, why: 'no msisdn' }, { when: { local: 'key', empty: true }, why: 'no key', afterInputs: true }],
|
|
507
|
+
cooldown: { key: { template: 'last_crm_{msisdn}' }, hours: 48, expireDays: 3 }, // agent env, stamped after a 2xx
|
|
508
|
+
body: { object: { result: { row: 'result' }, payload: { object: { name: { row: 'name' } } } } },
|
|
509
|
+
serialize: { values: 'string', emptyAs: 'None' }, // 'python': None / True / False; form: true
|
|
510
|
+
read: { save: { ref: 'data.id' }, expect: 'object' },
|
|
511
|
+
rowFields: { crm_ref: { local: 'ref' } }, onFail: { crm_ref: null }, onSkip: { crm_ref: null },
|
|
512
|
+
writeBack: { field: 'send_status', value: { cases: [{ when: { input: 'skipped', empty: false }, value: 'skipped' }], else: { input: 'status' } } },
|
|
513
|
+
log: { event: 'crm', fields: { object: { result: { row: 'result' } } }, reasonKey: 'why',
|
|
514
|
+
sent: { event: 'crm_done', fields: { object: { result: { template: '{status}: {text}' } } } }, anyStatus: true } }
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
- Order: `enabledBy` → `skipWhen` (in order; `inputs` read before the first check with `afterInputs`, else after the
|
|
518
|
+
checks; `afterInputs: ['a', 'b']` reads only those inputs there, the rest later — e.g. a key read only once a call
|
|
519
|
+
ref is there) → `cooldown` → headers / URL / query → body → request(s) → log lines → `rowFields` / `writeBack`.
|
|
520
|
+
- `serialize.values`: `string` (null → `''`, every leaf its text), `python` (Python `f"{v}"`: `None`, `True`/`False`);
|
|
521
|
+
`emptyAs`: a blank leaf becomes that text, or `{ omit: true }` drops the key. `form: true` sends form fields.
|
|
522
|
+
- `log` replaces the default lines (`<id>_skipped { reason }`, `<id>_sent { status }`, `<id>_failed`): `event` is the
|
|
523
|
+
base name (`<event>_skipped` / `_sent` / `_failed`, HTTP line `httpEvent` or `<event>_http`), `fields` go on every
|
|
524
|
+
line, each line may set its own `event` (an expression), `fields` (replacing the default ones) and `when`, or be
|
|
525
|
+
`false`; the locals include `jsonError` (the JSON parser's error text of an answer that is not JSON, else `null`);
|
|
526
|
+
`after` is one more line after any outcome, a skip included (its `when` decides; e.g. a summary of a
|
|
527
|
+
lookup); `anyStatus` logs a
|
|
528
|
+
non-2xx answer as sent (it still counts as failed).
|
|
529
|
+
- `preDial` answer as data: `read.answer: { path, expect: 'boolean', or? }` — a boolean at `path` (anything else: no
|
|
530
|
+
usable answer → `failOpen`); `or` holding turns a no into a yes (e.g. `{ memory: 'drop_seen', eq: true }`).
|
|
531
|
+
- `phase: 'lookup'` + `input.lookup: { integration: id, field, result? }`: the lookup at answer is this request; its
|
|
532
|
+
`value` (locals of the outcome plus `outcome`: `sent` / `skipped` / `failed`, `why`) is the field's value (default:
|
|
533
|
+
the parsed 2xx answer, else `null`).
|
|
534
|
+
- `phase: 'dialogEnd'`: requests run when the dialog ends (`platform.afterLeg` policy `onDone.integrations`, input `{
|
|
535
|
+
pass }` read as `{ row: 'pass' }`).
|
|
536
|
+
|
|
537
|
+
### Agent kinds: `startAgentDialog`, `askAgent`
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
{ id: 'zalo', phase: 'afterCall', kind: 'startAgentDialog', when: { row: 'result', in: ['refusal'] },
|
|
541
|
+
inputs: { agent: { from: { storage: 'zalo_agent_uuid' } }, user: { from: { storage: 'api_username' } }, password: { from: { storage: 'api_password' } } },
|
|
542
|
+
skipWhen: [{ when: { local: 'agent', empty: true }, why: 'no agent', afterInputs: true }],
|
|
543
|
+
startAgentDialog: { host: 'https://cms.example', agentUuid: { local: 'agent' }, user: { local: 'user' }, password: { local: 'password' },
|
|
544
|
+
selection: { template: 'FUP_{dialogUuid}' }, body: { object: { msisdn: { var: 'msisdn' } } }, store: 'zalo_dialog_uuid' },
|
|
545
|
+
log: { fields: { object: { result: { row: 'result' } } }, reasonKey: 'why' } }
|
|
546
|
+
{ id: 'declension', phase: 'beforeCall', kind: 'askAgent', timeoutMs: 8000,
|
|
547
|
+
ask: { agentUuid: '…', items: { customer: { var: 'full_name' } }, dialogName: { template: 'declension {dialogUuid}' }, hidden: true,
|
|
548
|
+
parse: 'firstObject', accept: { of: { local: 'json.ru.nom' }, eq: { local: 'source' } }, store: 'name_declensions', itemKey: 'who' } }
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
- `startAgentDialog`: `POST <host>/api/v2/ext/auth` (basic `user:password`, form content type) → `token` →
|
|
552
|
+
`POST <host>/api/v2/ext/dialog/dialog-initial?agent_uuid=…[&with_selection=true&selection_name=…]` (bearer, JSON
|
|
553
|
+
`body`); HTTP lines `<event>_auth`, `<event>_dialog_initial`; `<event>_created` (locals `agentUuid`,
|
|
554
|
+
`newDialogUuid`), `<event>_failed` (`{ status, text }`, or `{ err }` — an auth that failed throws `ext auth failed
|
|
555
|
+
with status N`), `<event>_skipped` (no agent env for a `cooldown`: `<event>_failed { err }`). `store`: the row field of the new dialog's id (`null` on any other outcome).
|
|
556
|
+
`requestId` defaults to the dialog UUID; `cooldown` is stamped after the dialog is created.
|
|
557
|
+
- `askAgent` (`phase: 'beforeCall'`: the pre-call pass, after `platform.beforeCall`, before the first leg): one
|
|
558
|
+
question per item in parallel, each in a dialog of its own; a usable answer (`parse`, `accept`; locals `json`,
|
|
559
|
+
`answer`, `source`, `item`) is kept as `value` (default the JSON) — `{ [item]: value | null }` in the dialog env
|
|
560
|
+
under `store`, read by input fields with `{ dialogEnv }`. Lines: `<event>_sent { <itemKey>, ms, … }`,
|
|
561
|
+
`<event>_failed { <itemKey>, reason: 'timeout' | 'unusable_answer' (source, answer ≤ 2000 chars) | 'error' (err), ms }`.
|
|
562
|
+
|
|
563
|
+
## Test records as data
|
|
564
|
+
|
|
565
|
+
```ts
|
|
566
|
+
testData: { enabledBy: { storage: 'test_mode' }, onlyWhenEmpty: false, unlessAnyOf: ['name_in'],
|
|
567
|
+
presets: {
|
|
568
|
+
aliases: { '1': 'overdue', on: 'overdue', true: 'overdue', '2': 'predue' },
|
|
569
|
+
common: { company: 'Brand' },
|
|
570
|
+
presets: {
|
|
571
|
+
overdue: { name_in: { pickOne: ['Ana Reyes', 'Jose Cruz'] }, total: { mul: [{ random: { int: [3, 50] } }, 500] }, due_in: { addDays: [{ fact: 'today' }, { neg: { random: { int: [5, 60] } } }] } },
|
|
572
|
+
predue: { name_in: 'Ana Reyes', total: 1000, minimum: { mul: [{ var: 'total' }, 0.15] } },
|
|
573
|
+
},
|
|
574
|
+
} }
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
- The switch's value (trimmed, lower case) names the preset through `aliases`, else by itself, else by its whole
|
|
578
|
+
number (`1.0` → `1`), else `otherwise`; or `keyOf` (an expression of `{ input: '' }`, the raw value, e.g. regex
|
|
579
|
+
`cases`, `{ read: 'jsNumber' }` for a client's `Number(raw)`) names it — it replaces `aliases` and the number rule;
|
|
580
|
+
an unknown or empty name: no test values.
|
|
581
|
+
- `sources: { name: Source }` are read like input sources (a CMS global with a QA value) and are `{ var }` to every
|
|
582
|
+
field and `when`; a field whose value is `{ omit: true }` gives no test value (the field keeps its own sources).
|
|
583
|
+
- `common` then the preset's fields are evaluated in declaration order: earlier fields are `{ var }`, the switch's
|
|
584
|
+
value `{ input: '' }`, the clock of `input.timeZone`; random draws (`random`, `pickOne`) happen in that order (keys
|
|
585
|
+
no input field reads are ignored — helper fields keep a draw order). `when` (over the values) can keep the record off.
|
|
586
|
+
|
|
587
|
+
## Leg policy as data
|
|
588
|
+
|
|
589
|
+
```ts
|
|
590
|
+
platform: {
|
|
591
|
+
failedLegPass: true, legs: { onSuccessCall: 'on_success_call',
|
|
592
|
+
dialNumber: { read: { kind: 'phone', national: 10, country: '7', plus: true }, of: { self: true } },
|
|
593
|
+
routeRules: [{ when: { local: 'msisdn', matches: /^case/ }, msisdn: '77777', channel: 'autotest_trunk', protoAdditional: { caller_id: { local: 'msisdn' } } }],
|
|
594
|
+
trunkPool: { trunks: [{ name: 't1', id: 15, callerId: '77273454082' }], domain: 'sip.example',
|
|
595
|
+
headers: { caller_id: '{callerId}', 'Remote-Party-ID': '"{callerId}" <sip:{callerId}@{domain}>;party=calling;screen=yes;privacy=off' } },
|
|
596
|
+
callbacks: { timeZone: 'Asia/Almaty', hours: { morning: 10, afternoon: 14, evening: 18, dayOnly: 10 }, passedDelaySec: 1800,
|
|
597
|
+
fallbackDelaySec: 900, fallbackMaxCalls: 3, entryPoint: 'main', onFailedCall: 'on_failed_call', envKey: 'callback_schedule' } },
|
|
598
|
+
afterLeg: {
|
|
599
|
+
attempts: { memoryKey: 'attempt' },
|
|
600
|
+
settings: { count: { from: ['params', 'initial', 'dialog', 'agent'], default: 3 }, delaySec: { from: ['params', 'initial', 'dialog', 'agent'], default: 300 } },
|
|
601
|
+
onFailed: { write: { result: null, status: '-ERR' }, decide: { object: { redial: { test: { local: 'attempt', lte: { local: 'count' } } } } },
|
|
602
|
+
log: { event: '[recall] after-call failed' }, onDone: { dialogResult: 'done' } },
|
|
603
|
+
onSuccess: { decide: { object: { redial: { test: { all: [{ memory: 'result', in: ['silence'] }, { local: 'attempt', lte: { local: 'count' } }] } } } },
|
|
604
|
+
onDone: { integrations: ['ad_target_delivery'], dialogResult: 'done' } },
|
|
605
|
+
},
|
|
606
|
+
}
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
- `afterLeg` as an `AfterLegPolicy`: the leg is counted first (`max(memory[key],
|
|
610
|
+
attempt − 1) + 1` written back), the settings come from the first place that has them, then `write`, `decide` (an
|
|
611
|
+
object `{ redial, delaySec?, … }`; locals `attempt`, `count`, `delaySec`, `pass`, `nowMs`; `{ memory }` reads what
|
|
612
|
+
the live pass kept), `log` (default fields `{ attempt, ...decision, recallCount, recallDelaySec }`; locals plus
|
|
613
|
+
`decision`), the redial (`decision.delaySec`, else the setting) — or, with no leg placed, `onDone.integrations`
|
|
614
|
+
(input `{ pass }`) and `onDone.dialogResult`.
|
|
615
|
+
- `routeRules` (first that holds; local `msisdn`) and `trunkPool` (a trunk at random per leg: its `trunkId`, its
|
|
616
|
+
headers over the leg's own, the channel dropped) re-route each leg. The
|
|
617
|
+
failed-leg redials (`redialFailed: 'campaign'`) and the callbacks go over the pool too. `trunkLog: true`: the first
|
|
618
|
+
leg's line is `{ msisdn, entryPoint, selectedTrunk, trunkNumber, trunkId }` and the failed-leg redial lines carry
|
|
619
|
+
`selectedTrunk`, `trunkNumber` after `callUuid` (instead of the recall values and the handler).
|
|
620
|
+
- `numberMsisdn: false` (with `dialNumber`): a number value of the dialog's msisdn (not a text) is not dialled — the
|
|
621
|
+
first leg logs `no msisdn`, the failed-leg redial skips with `no_msisdn` (default: read as its text).
|
|
622
|
+
- `callbacks`: after a connected call (`call.outcome`; none: a callback is asked) that asks for one (`when`, default
|
|
623
|
+
`triggersCallback`), at `time` (default entity `callback_time`: `YYYY-MM-DD`, `… HH:mm`, `… morning|afternoon|evening`
|
|
624
|
+
in `timeZone`; passed → `passedDelaySec`; none → the campaign's delay, else `fallbackDelaySec`), within the
|
|
625
|
+
campaign's recall count of calls (`fallbackMaxCalls` without one; calls so far = attempts, failed-leg redials and
|
|
626
|
+
callbacks booked), once per call; recorded in the dialog env `envKey`, the dialog result `pending`. Lines
|
|
627
|
+
`callback_scheduled`, `callback_not_scheduled { reason }`, `callback_schedule_failed`.
|
|
628
|
+
|
|
629
|
+
## Recalls and attempts
|
|
630
|
+
|
|
631
|
+
An agent whose legs follow the client's own rules (a trunk pool with its caller IDs, its dial format, callbacks at the
|
|
632
|
+
time the caller named, the redial of a leg nobody answered) describes them as data: `platform.legs` (`dialNumber`, `trunkPool`, `routeRules`, `redialFailed`), `callbacks` and
|
|
633
|
+
the `afterLeg` policy (above), its counts kept in the dialog env (`{ memory }`). The library's own recall
|
|
634
|
+
(`platform.recall`) stays off.
|
|
635
|
+
An agent that owns its redials after each leg (the legacy `on_success_call` / `on_failed_call` model: every leg names
|
|
636
|
+
both passes, the platform's recall is off) uses `platform.failedLegPass` + `platform.legs.onSuccessCall` +
|
|
637
|
+
`platform.afterLeg` (an `AfterLegPolicy`, above): the live pass keeps what the next pass reads with
|
|
638
|
+
`results.remember`, the policy counts the leg, decides the redial or closes the dialog (`onDone.dialogResult`) and
|
|
639
|
+
makes the client's own end-of-dialog requests (`onDone.integrations`). No result books a platform recall
|
|
640
|
+
(`recall: false`).
|
|
641
|
+
|
|
642
|
+
- Attempts are counted by the script (dialog env).
|
|
643
|
+
- With `platform.recall.platformRecallOff` every leg the script places turns the platform's own recall off, the first
|
|
644
|
+
leg is placed once per dialog and the row says `triggers_callback: false`; the script's own redial still follows the
|
|
645
|
+
decision (`results.table[label].recall`).
|
|
646
|
+
- A redial is booked when the final result has `recall: true` and the budget allows (`budgetCheck`), with
|
|
647
|
+
`delaySec` — the campaign's (`{ from: { platform: true } }`), or by result: `{ busy: 3600, default: { from: {
|
|
648
|
+
platform: true } } }` (listed results their own seconds, the rest the campaign's; a failed dial always the campaign's).
|
|
649
|
+
The script books it itself.
|
|
650
|
+
- Redials are deduplicated by `dedupBy`; a dialog the script did not dial (inbound) is never redialed.
|
|
651
|
+
- A second `after_call_failed` pass for a SIP leg already reported (same leg id; also the failed-leg pass) writes no
|
|
652
|
+
row, runs no after-call integrations and books no redial; it logs `duplicate_leg_pass` as an error. A leg known only
|
|
653
|
+
by the dialog UUID is reported on every pass.
|
|
654
|
+
- `recall.legLedger`: attempts and redials by the ledger of the legs the script placed (see `agent-file.md`); a
|
|
655
|
+
repeated failure report of one leg writes no second row, and a dialog the script placed no leg on is never redialled.
|
|
656
|
+
- `report.failedDialCallback` (default true): `triggers_callback` of a failed dial's row.
|
|
657
|
+
- The redial is booked after the after-call integrations, or before them with `recall.beforeIntegrations`.
|
|
658
|
+
- `call.previous` (result and attempt of the previous call of this dialog) and `call.memory` (`results.remember`) let
|
|
659
|
+
texts and rules depend on earlier attempts (e.g. a different greeting on a callback).
|