@onereach/step-voice 7.0.5 → 7.0.7
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/dst/Global Command.d.ts +2 -2
- package/dst/Global Command.js +2 -6
- package/dst/Initiate Call.d.ts +1 -1
- package/dst/Wait For Call.d.ts +3 -3
- package/dst/Wait For Call.js +9 -2
- package/dst/step.d.ts +4 -2
- package/dst/voice.d.ts +8 -4
- package/dst/voice.js +7 -5
- package/package.json +3 -3
package/dst/Global Command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IEvent } from '@onereach/flow-sdk/dst/types/event';
|
|
2
2
|
import VoiceStep, { IVoiceCall, TODO, VoiceEvent } from './voice';
|
|
3
3
|
interface INPUT {
|
|
4
4
|
asr: TODO;
|
|
@@ -59,7 +59,7 @@ export default class GlobalCommand extends VoiceStep<Partial<INPUT>, OUTPUT, EVE
|
|
|
59
59
|
} | undefined;
|
|
60
60
|
} | undefined;
|
|
61
61
|
hangup(call: IVoiceCall): Promise<unknown>;
|
|
62
|
-
exitThread(event:
|
|
62
|
+
exitThread(event: IEvent<EVENT>, type: string, stepExit: string): Promise<void>;
|
|
63
63
|
buildGrammar(call: IVoiceCall, choices: TODO[]): Promise<any>;
|
|
64
64
|
acceptAck(eventParams: any): void;
|
|
65
65
|
}
|
package/dst/Global Command.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/explicit-function-return-type */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const process_1 = require("@onereach/flow-sdk/dst/types/process");
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
8
8
|
const CALL_QUALITY_RATINGS = {
|
|
@@ -92,9 +92,7 @@ class GlobalCommand extends voice_1.default {
|
|
|
92
92
|
await this.initGrammar(call);
|
|
93
93
|
}
|
|
94
94
|
if (allowAck) {
|
|
95
|
-
this.log.debug('subscribing gc to ack');
|
|
96
95
|
this.triggers.local('ack', ({ params: { ack } }) => {
|
|
97
|
-
this.log.debug('gc ack received', { ack });
|
|
98
96
|
delete worker.state.acktrd;
|
|
99
97
|
if (ack)
|
|
100
98
|
this.exitStep('no commands');
|
|
@@ -153,7 +151,7 @@ class GlobalCommand extends voice_1.default {
|
|
|
153
151
|
this.triggers.otherwise(async () => {
|
|
154
152
|
await this.initGrammar(call);
|
|
155
153
|
});
|
|
156
|
-
this.triggers.hook({ name: "waitEnd" /* ACTION.waitEnd */, thread:
|
|
154
|
+
this.triggers.hook({ name: "waitEnd" /* ACTION.waitEnd */, thread: process_1.MAIN_THREAD_ID, sync: true, times: 1 }, async () => {
|
|
157
155
|
// TODO: this is not required in newer versions, delete in v6.1+
|
|
158
156
|
const allowAck = this.canVoicerAck(call);
|
|
159
157
|
if (!allowAck) {
|
|
@@ -168,7 +166,6 @@ class GlobalCommand extends voice_1.default {
|
|
|
168
166
|
this.end();
|
|
169
167
|
});
|
|
170
168
|
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
171
|
-
this.log.debug('gc in/voice event', event.params);
|
|
172
169
|
switch (event.params.type) {
|
|
173
170
|
case 'ack': {
|
|
174
171
|
this.acceptAck({ ack: true });
|
|
@@ -339,7 +336,6 @@ class GlobalCommand extends voice_1.default {
|
|
|
339
336
|
}
|
|
340
337
|
acceptAck(eventParams) {
|
|
341
338
|
if (this.state.acktrd) {
|
|
342
|
-
this.log.debug('accepting ack', eventParams);
|
|
343
339
|
this.process.enqueue({
|
|
344
340
|
thread: this.state.acktrd,
|
|
345
341
|
name: 'ack',
|
package/dst/Initiate Call.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface INPUT {
|
|
|
21
21
|
isAMD?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export default class InitiateCall extends VoiceStep<INPUT, TODO, CallStartEvent> {
|
|
24
|
-
get conversation(): string | import("@onereach/flow-sdk/
|
|
24
|
+
get conversation(): string | import("@onereach/flow-sdk/types").IMergeField;
|
|
25
25
|
runStep(): Promise<void>;
|
|
26
26
|
onAwake(): Promise<void>;
|
|
27
27
|
waitForCall(): Promise<void>;
|
package/dst/Wait For Call.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import VoiceStep, { CallStartEvent, TODO } from './voice';
|
|
2
|
-
import {
|
|
2
|
+
import { IEvent } from '@onereach/flow-sdk/dst/types/event';
|
|
3
3
|
export default class WaitForCall extends VoiceStep<TODO, TODO, TODO> {
|
|
4
|
-
get conversation(): string | import("@onereach/flow-sdk/
|
|
4
|
+
get conversation(): string | import("@onereach/flow-sdk/types").IMergeField;
|
|
5
5
|
runStep(): Promise<void>;
|
|
6
|
-
onCall(event:
|
|
6
|
+
onCall(event: IEvent<CallStartEvent>): Promise<any>;
|
|
7
7
|
}
|
package/dst/Wait For Call.js
CHANGED
|
@@ -36,13 +36,20 @@ class WaitForCall extends voice_1.default {
|
|
|
36
36
|
delete call.from;
|
|
37
37
|
delete call.to;
|
|
38
38
|
const presetTime = (Number(endOfInputTimeout) || 0) * 60 * 1000;
|
|
39
|
+
const { sessionId: previousSessionId = '', beginningSessionId = '', } = event?.reporting ?? {};
|
|
39
40
|
await this.session.start({
|
|
40
41
|
timeout: presetTime || defaultSessionTimeout,
|
|
41
42
|
reporting: {
|
|
42
43
|
settingsKey: 'session',
|
|
43
44
|
startedBy: 'Visitor',
|
|
44
|
-
sessionType: 'Phone'
|
|
45
|
-
|
|
45
|
+
sessionType: 'Phone',
|
|
46
|
+
previousSessionId,
|
|
47
|
+
beginningSessionId
|
|
48
|
+
},
|
|
49
|
+
reportingSessions: [{
|
|
50
|
+
previousSessionId,
|
|
51
|
+
beginningSessionId
|
|
52
|
+
}]
|
|
46
53
|
});
|
|
47
54
|
await this.startConversation(call);
|
|
48
55
|
await this.transcript(call, {
|
package/dst/step.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Step from '@onereach/flow-sdk/dst/step';
|
|
2
|
-
import {
|
|
2
|
+
import { CONFIG, IThreadId } from '@onereach/flow-sdk/dst/types/thread';
|
|
3
|
+
import { IMergeField } from '@onereach/flow-sdk/dst/types/mergeFields';
|
|
4
|
+
import { IEvent } from "@onereach/flow-sdk/types/event";
|
|
3
5
|
export interface ConvStepDataIn {
|
|
4
6
|
conversation?: string | IMergeField;
|
|
5
7
|
conversationThread?: IThreadId;
|
|
@@ -10,7 +12,7 @@ export interface IConversation {
|
|
|
10
12
|
export interface IConversationData {
|
|
11
13
|
_conv: IConversation;
|
|
12
14
|
}
|
|
13
|
-
export default class ConvStep<TData extends IConversationData, TIn = unknown, TOut = unknown,
|
|
15
|
+
export default class ConvStep<TData extends IConversationData, TIn = unknown, TOut = unknown, TEvents extends IEvent<any> = IEvent<any>> extends Step<CONFIG<TIn & ConvStepDataIn, TOut, TEvents, any, any, any>> {
|
|
14
16
|
private convDataCache?;
|
|
15
17
|
get cache(): TData | undefined;
|
|
16
18
|
get conversation(): string | IMergeField;
|
package/dst/voice.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ICallback
|
|
1
|
+
import { ICallback } from '@onereach/flow-sdk/dst/types/eventManager';
|
|
2
|
+
import { IPromtpSection, IVoiceReporterTranscriptEventArgs } from '@onereach/flow-sdk/dst/types/reporter';
|
|
3
|
+
import { IEvent } from '@onereach/flow-sdk/dst/types/event';
|
|
2
4
|
import ConvStep, { IConversationData } from './step';
|
|
3
5
|
import BasicError from '@onereach/flow-sdk/dst/errors/base';
|
|
6
|
+
import { WITH_VAR } from "@onereach/flow-sdk/types/thread";
|
|
4
7
|
export type TODO = any;
|
|
5
8
|
export interface SensitiveData {
|
|
6
9
|
muteStep: boolean;
|
|
@@ -65,7 +68,7 @@ export interface CallStartEvent extends VoiceEvent {
|
|
|
65
68
|
}
|
|
66
69
|
export interface HandleInterruptionParams<TParams extends VoiceEvent = VoiceEvent> {
|
|
67
70
|
call: IVoiceCall;
|
|
68
|
-
event:
|
|
71
|
+
event: IEvent<TParams>;
|
|
69
72
|
speechSections: IPromtpSection[];
|
|
70
73
|
repromptsList?: {
|
|
71
74
|
message?: string;
|
|
@@ -73,9 +76,10 @@ export interface HandleInterruptionParams<TParams extends VoiceEvent = VoiceEven
|
|
|
73
76
|
}[];
|
|
74
77
|
reportingSettingsKey?: string;
|
|
75
78
|
}
|
|
79
|
+
export type VoiceEvents<TParams> = IEvent<TParams, WITH_VAR<'in/voice/'>> | IEvent<TParams, WITH_VAR<'in/voice/', '/event'>>;
|
|
76
80
|
export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends VoiceEvent = VoiceEvent> extends ConvStep<IVoiceCall, TIn & {
|
|
77
81
|
handleCancel?: boolean;
|
|
78
|
-
}, TOut, TParams
|
|
82
|
+
}, TOut, VoiceEvents<TParams>> {
|
|
79
83
|
runBefore(): Promise<void>;
|
|
80
84
|
exitStep(exitId: string, data?: any, byThread?: boolean): any;
|
|
81
85
|
exitStepByThread(exitId: string, result: any): any;
|
|
@@ -107,6 +111,6 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends Vo
|
|
|
107
111
|
get rptsStarted(): boolean;
|
|
108
112
|
canVoicerHearbeat(call: IVoiceCall): boolean;
|
|
109
113
|
canVoicerAck(call: IVoiceCall): boolean;
|
|
110
|
-
getInterruptionMetadata(event:
|
|
114
|
+
getInterruptionMetadata(event: IEvent<TParams>): VoiceInterruptionMetadata | null;
|
|
111
115
|
handleInterruption(params: HandleInterruptionParams<TParams>): Promise<void>;
|
|
112
116
|
}
|
package/dst/voice.js
CHANGED
|
@@ -13,7 +13,6 @@ class VoiceStepError extends base_1.default {
|
|
|
13
13
|
}
|
|
14
14
|
exports.VoiceStepError = VoiceStepError;
|
|
15
15
|
class VoiceStep extends step_1.default {
|
|
16
|
-
// static Error = VoiceStepError
|
|
17
16
|
async runBefore() {
|
|
18
17
|
await super.runBefore();
|
|
19
18
|
if (this.cache != null) {
|
|
@@ -52,7 +51,7 @@ class VoiceStep extends step_1.default {
|
|
|
52
51
|
async sendCommands({ id, type, callback }, commands) {
|
|
53
52
|
if (lodash_1.default.isEmpty(commands))
|
|
54
53
|
return;
|
|
55
|
-
const
|
|
54
|
+
const event = {
|
|
56
55
|
target: this.helpers.providersAccountId,
|
|
57
56
|
name: `out/voice/${type}`,
|
|
58
57
|
params: {
|
|
@@ -63,8 +62,11 @@ class VoiceStep extends step_1.default {
|
|
|
63
62
|
commands,
|
|
64
63
|
step: { key: this.session.key, trd: this.isGlobal ? this.workerThreadId : this.thread.id } // response should be sent to this session
|
|
65
64
|
},
|
|
66
|
-
reporting:
|
|
67
|
-
|
|
65
|
+
reporting: {
|
|
66
|
+
...this.session.getSessionRef(),
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const result = await this.thread.eventManager.emit(event, {
|
|
68
70
|
target: callback,
|
|
69
71
|
invocationType: 'async',
|
|
70
72
|
timeout: 5000
|
|
@@ -251,7 +253,7 @@ class VoiceStep extends step_1.default {
|
|
|
251
253
|
return eventId;
|
|
252
254
|
}
|
|
253
255
|
throwError(error = new Error('unknown')) {
|
|
254
|
-
throw new VoiceStepError(error.message ?? error,
|
|
256
|
+
throw new VoiceStepError(error.message ?? error, { name: error?.name });
|
|
255
257
|
}
|
|
256
258
|
async handleHangup(call) {
|
|
257
259
|
if (call.ended)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/step-voice",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.7",
|
|
4
4
|
"author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Roman Zolotarov",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"uuid": "^9.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@onereach/flow-sdk": "^
|
|
23
|
-
"@onereach/orbes": "^
|
|
22
|
+
"@onereach/flow-sdk": "^8.0.5",
|
|
23
|
+
"@onereach/orbes": "^7.2.9",
|
|
24
24
|
"@onereach/step-voice": "./test",
|
|
25
25
|
"@swc/cli": "^0.1.62",
|
|
26
26
|
"@swc/core": "^1.3.57",
|