@onereach/step-voice 6.0.19 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dst/Choice.js +1 -1
- package/dst/Custom Voice Input.js +1 -1
- package/dst/Join Conference.d.ts +5 -2
- package/dst/Join Conference.js +5 -0
- package/dst/Keypad Input.js +1 -1
- package/dst/{Kick From Conference.js → Leave Conference.js } +6 -1
- package/dst/voice.d.ts +5 -4
- package/dst/voice.js +7 -62
- package/package.json +4 -3
- /package/dst/{Kick From Conference.d.ts → Leave Conference.d.ts} +0 -0
package/dst/Choice.js
CHANGED
|
@@ -255,7 +255,7 @@ class Choice extends voice_1.default {
|
|
|
255
255
|
actionFromBot: true
|
|
256
256
|
});
|
|
257
257
|
command.params.sections = speechSections;
|
|
258
|
-
command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList });
|
|
258
|
+
command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList, initial: true });
|
|
259
259
|
await this.pauseRecording(call, command, sensitiveData);
|
|
260
260
|
return this.exitFlow();
|
|
261
261
|
});
|
|
@@ -202,7 +202,7 @@ class CustomVoiceInput extends voice_1.default {
|
|
|
202
202
|
actionFromBot: true
|
|
203
203
|
});
|
|
204
204
|
command.params.sections = speechSections;
|
|
205
|
-
command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList });
|
|
205
|
+
command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList, initial: true });
|
|
206
206
|
await this.pauseRecording(call, command, sensitiveData);
|
|
207
207
|
return this.exitFlow();
|
|
208
208
|
});
|
package/dst/Join Conference.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import VoiceStep from './voice';
|
|
1
|
+
import VoiceStep, { TODO, VoiceEvent } from './voice';
|
|
2
2
|
interface INPUT {
|
|
3
3
|
conferenceName: string;
|
|
4
4
|
stayInConference: boolean;
|
|
5
5
|
}
|
|
6
|
-
export default class JoinConference extends VoiceStep<INPUT
|
|
6
|
+
export default class JoinConference extends VoiceStep<INPUT, TODO, VoiceEvent & {
|
|
7
|
+
user: string;
|
|
8
|
+
room: string;
|
|
9
|
+
}> {
|
|
7
10
|
runStep(): Promise<void>;
|
|
8
11
|
}
|
|
9
12
|
export {};
|
package/dst/Join Conference.js
CHANGED
|
@@ -13,6 +13,10 @@ class JoinConference extends voice_1.default {
|
|
|
13
13
|
await this.handleHangup(call);
|
|
14
14
|
return await this.waitConvEnd();
|
|
15
15
|
case 'conference-start':
|
|
16
|
+
call.conference = {
|
|
17
|
+
room: event.params.room,
|
|
18
|
+
user: event.params.user
|
|
19
|
+
};
|
|
16
20
|
await this.transcript(call, {
|
|
17
21
|
conferenceId: conferenceName,
|
|
18
22
|
reportingSettingsKey: 'transcript',
|
|
@@ -26,6 +30,7 @@ class JoinConference extends voice_1.default {
|
|
|
26
30
|
return this.exitStep('next', lodash_1.default.omit(event.params, ['type']));
|
|
27
31
|
}
|
|
28
32
|
case 'conference-end':
|
|
33
|
+
call.conference = undefined;
|
|
29
34
|
await this.transcript(call, {
|
|
30
35
|
conferenceId: conferenceName,
|
|
31
36
|
reportingSettingsKey: 'transcript',
|
package/dst/Keypad Input.js
CHANGED
|
@@ -170,7 +170,7 @@ class KeypadInput extends voice_1.default {
|
|
|
170
170
|
action: 'Call Prompt',
|
|
171
171
|
actionFromBot: true
|
|
172
172
|
});
|
|
173
|
-
command.params.firstDigitTimeout = this.rptsTimeout({ noReplyDelay, repromptsList });
|
|
173
|
+
command.params.firstDigitTimeout = this.rptsTimeout({ noReplyDelay, repromptsList, initial: true });
|
|
174
174
|
command.params.sections = speechSections;
|
|
175
175
|
await this.pauseRecording(call, command, sensitiveData);
|
|
176
176
|
return this.exitFlow();
|
|
@@ -6,13 +6,18 @@ const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
|
6
6
|
class KickFromConference extends voice_1.default {
|
|
7
7
|
async runStep() {
|
|
8
8
|
const call = await this.fetchData();
|
|
9
|
-
|
|
9
|
+
if (call.conference == null) {
|
|
10
|
+
this.log.debug('already not in conference');
|
|
11
|
+
return this.exitStep('next');
|
|
12
|
+
}
|
|
13
|
+
const { room, user } = call.conference;
|
|
10
14
|
this.triggers.local(`in/voice/${call.id}`, async (event) => {
|
|
11
15
|
switch (event.params.type) {
|
|
12
16
|
case 'hangup':
|
|
13
17
|
await this.handleHangup(call);
|
|
14
18
|
return await this.waitConvEnd();
|
|
15
19
|
case 'conference-end':
|
|
20
|
+
call.conference = undefined;
|
|
16
21
|
await this.transcript(call, {
|
|
17
22
|
conferenceId: room,
|
|
18
23
|
reportingSettingsKey: 'transcript',
|
package/dst/voice.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export interface IVoiceCall extends IConversationData {
|
|
|
25
25
|
to?: string;
|
|
26
26
|
from?: string;
|
|
27
27
|
headers?: Record<string, string>;
|
|
28
|
+
conference?: {
|
|
29
|
+
room: string;
|
|
30
|
+
user: string;
|
|
31
|
+
};
|
|
28
32
|
}
|
|
29
33
|
export type EventType = 'hangup' | 'ack' | 'error' | 'cancel' | 'background' | 'avm-detected' | 'recognition' | 'digit' | 'digits' | 'conference-start' | 'conference-end' | 'playback' | 'timeout' | 'record' | 'bridge' | 'bridge/ended' | 'is_flow_ready' | 'call' | 'dtmf-sent';
|
|
30
34
|
export declare class VoiceStepError extends BasicError {
|
|
@@ -56,8 +60,6 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends Vo
|
|
|
56
60
|
exitStepByThread(exitId: string, result: any): any;
|
|
57
61
|
exitToThread(): void;
|
|
58
62
|
sendCommands({ id, type, callback }: IVoiceCall, commands: TODO[]): Promise<void>;
|
|
59
|
-
handleDataThreadStart(): void;
|
|
60
|
-
handleDataThreadEnd(): void;
|
|
61
63
|
handleHeartbeat(call: IVoiceCall): Promise<void>;
|
|
62
64
|
handleCancel(): void;
|
|
63
65
|
extractSectionMessages(sections: IPromtpSection[]): string;
|
|
@@ -76,12 +78,11 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends Vo
|
|
|
76
78
|
buildChoice(choice: TODO): TODO;
|
|
77
79
|
exitChoiceData(type: string, params?: TODO): TODO;
|
|
78
80
|
rptsSend(call: IVoiceCall, { command, reporting, repromptsList, noReplyDelay, speechSections, textType, ttsSettings, sensitiveData }: TODO): Promise<void>;
|
|
79
|
-
rptsTimeout({ noReplyDelay, repromptsList }: TODO): number;
|
|
81
|
+
rptsTimeout({ noReplyDelay, repromptsList, initial }: TODO): number;
|
|
80
82
|
rptsRestart(): void;
|
|
81
83
|
rptsHasMore({ repromptsList }: TODO): boolean;
|
|
82
84
|
get rptsIndex(): number;
|
|
83
85
|
get rptsStarted(): boolean;
|
|
84
|
-
sleepUntilHangup(): Promise<void>;
|
|
85
86
|
canVoicerHearbeat(call: IVoiceCall): boolean;
|
|
86
87
|
canVoicerAck(call: IVoiceCall): boolean;
|
|
87
88
|
}
|
package/dst/voice.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.VoiceStepError = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const nanoid_1 = require("nanoid");
|
|
8
|
-
const types_1 = require("@onereach/flow-sdk/dst/types");
|
|
9
8
|
const uuid_1 = require("uuid");
|
|
10
9
|
// TODO: !!!!! import ConvStep from '@onereach/step-conversation/dst/step' !!!!!
|
|
11
10
|
const step_1 = tslib_1.__importDefault(require("./step"));
|
|
@@ -18,7 +17,8 @@ class VoiceStep extends step_1.default {
|
|
|
18
17
|
async runBefore() {
|
|
19
18
|
await super.runBefore();
|
|
20
19
|
if (this.cache != null) {
|
|
21
|
-
this.
|
|
20
|
+
if (this.thread.id !== this.dataThreadId)
|
|
21
|
+
this.thread.refThread(this.dataThreadId);
|
|
22
22
|
if (!this.state.direct)
|
|
23
23
|
await this.handleHeartbeat(this.cache);
|
|
24
24
|
}
|
|
@@ -26,9 +26,6 @@ class VoiceStep extends step_1.default {
|
|
|
26
26
|
exitStep(exitId, data, byThread = false) {
|
|
27
27
|
if (byThread)
|
|
28
28
|
return this.exitStepByThread(exitId, data);
|
|
29
|
-
if (this.cache != null) {
|
|
30
|
-
this.handleDataThreadEnd();
|
|
31
|
-
}
|
|
32
29
|
return super.exitStep(exitId, data);
|
|
33
30
|
}
|
|
34
31
|
exitStepByThread(exitId, result) {
|
|
@@ -75,50 +72,6 @@ class VoiceStep extends step_1.default {
|
|
|
75
72
|
if (result == null)
|
|
76
73
|
throw new Error(`failed to send command to call: ${id}`);
|
|
77
74
|
}
|
|
78
|
-
handleDataThreadStart() {
|
|
79
|
-
if (this.dataThreadId === types_1.MAIN_THREAD_ID || this.thread.id === this.dataThreadId)
|
|
80
|
-
return;
|
|
81
|
-
const dataThread = this.process.getThread(this.dataThreadId);
|
|
82
|
-
if (dataThread == null)
|
|
83
|
-
return;
|
|
84
|
-
if (dataThread.state.name === this.sleepUntilHangup.name) {
|
|
85
|
-
this.log.debug('attach to sleep data thread', { thread: this.thread.id });
|
|
86
|
-
dataThread.waits[`thread/end/${this.thread.id}`] = {};
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
this.triggers.hook({ name: "ending" /* ACTION.ending */, thread: this.dataThreadId, sync: true, times: 1 }, async () => {
|
|
90
|
-
// TODO: this is not required in newer versions, delete in v6.1+
|
|
91
|
-
delete this.waits['@ending'];
|
|
92
|
-
delete this.waits.ending;
|
|
93
|
-
if (dataThread.state.name === this.sleepUntilHangup.name) {
|
|
94
|
-
this.log.debug('hook attach to sleep data thread', { thread: this.thread.id });
|
|
95
|
-
dataThread.waits[`thread/end/${this.thread.id}`] = {};
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
this.log.debug('hook create sleep data thread', { thread: this.thread.id });
|
|
99
|
-
dataThread.gotoState({
|
|
100
|
-
direct: true,
|
|
101
|
-
step: this.currentStepId,
|
|
102
|
-
name: this.sleepUntilHangup.name,
|
|
103
|
-
waits: {
|
|
104
|
-
[`thread/end/${this.thread.id}`]: {}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
handleDataThreadEnd() {
|
|
110
|
-
if (this.dataThreadId === types_1.MAIN_THREAD_ID || this.thread.id === this.dataThreadId)
|
|
111
|
-
return;
|
|
112
|
-
const dataThread = this.process.getThread(this.dataThreadId);
|
|
113
|
-
if (dataThread == null)
|
|
114
|
-
return;
|
|
115
|
-
if (dataThread.state.name === this.sleepUntilHangup.name) {
|
|
116
|
-
this.log.debug('remove sleep data thread', { thread: this.thread.id });
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
118
|
-
delete dataThread.waits[`thread/end/${this.thread.id}`];
|
|
119
|
-
this.process.enqueue({ name: 'activate', thread: this.dataThreadId });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
75
|
async handleHeartbeat(call) {
|
|
123
76
|
const allowHeartbeat = this.canVoicerHearbeat(call);
|
|
124
77
|
if (allowHeartbeat) {
|
|
@@ -254,13 +207,13 @@ class VoiceStep extends step_1.default {
|
|
|
254
207
|
if (call.ended)
|
|
255
208
|
return;
|
|
256
209
|
const isHangedUpByBot = call.sessionEndedBy === 'Bot';
|
|
210
|
+
call.conference = undefined;
|
|
211
|
+
call.ended = true;
|
|
257
212
|
await this.transcript(call, {
|
|
258
213
|
action: 'Call End',
|
|
259
214
|
reportingSettingsKey: 'transcriptHangup',
|
|
260
215
|
actionFromBot: isHangedUpByBot
|
|
261
216
|
});
|
|
262
|
-
call.ended = true;
|
|
263
|
-
await this.updateData();
|
|
264
217
|
}
|
|
265
218
|
buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }) {
|
|
266
219
|
return lodash_1.default.map(sections, section => ({
|
|
@@ -376,9 +329,9 @@ class VoiceStep extends step_1.default {
|
|
|
376
329
|
else
|
|
377
330
|
await this.sendCommands(call, [command]);
|
|
378
331
|
}
|
|
379
|
-
rptsTimeout({ noReplyDelay, repromptsList }) {
|
|
380
|
-
const
|
|
381
|
-
return Number(lodash_1.default.get(
|
|
332
|
+
rptsTimeout({ noReplyDelay, repromptsList, initial = false }) {
|
|
333
|
+
const next = repromptsList[initial ? 0 : this.rptsIndex + 1];
|
|
334
|
+
return Number(lodash_1.default.get(next, 'time', noReplyDelay)) * 1000 || 60000;
|
|
382
335
|
}
|
|
383
336
|
rptsRestart() {
|
|
384
337
|
this.state.repIdx = undefined;
|
|
@@ -392,14 +345,6 @@ class VoiceStep extends step_1.default {
|
|
|
392
345
|
get rptsStarted() {
|
|
393
346
|
return this.rptsIndex !== 0;
|
|
394
347
|
}
|
|
395
|
-
async sleepUntilHangup() {
|
|
396
|
-
const threadEndPrefix = 'thread/end/';
|
|
397
|
-
if (this.event.name.startsWith(threadEndPrefix)) {
|
|
398
|
-
this.event.processed = true;
|
|
399
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
400
|
-
delete this.waits[this.event.name];
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
348
|
canVoicerHearbeat(call) {
|
|
404
349
|
return call.vv >= 1;
|
|
405
350
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/step-voice",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Roman Zolotarov",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"uuid": "^9.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@onereach/flow-sdk": "^3.2.
|
|
22
|
+
"@onereach/flow-sdk": "^3.2.50",
|
|
23
|
+
"@onereach/orbes": "^3.1.57",
|
|
23
24
|
"@onereach/step-voice": "./test",
|
|
24
25
|
"@swc/cli": "^0.1.62",
|
|
25
26
|
"@swc/core": "^1.3.57",
|
|
@@ -80,4 +81,4 @@
|
|
|
80
81
|
"node_modules"
|
|
81
82
|
]
|
|
82
83
|
}
|
|
83
|
-
}
|
|
84
|
+
}
|
|
File without changes
|