@onereach/step-voice 5.0.9-fixsubflow.5 → 5.0.9-fixsubflow.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/Cancel.js +1 -1
- package/dst/Choice.js +1 -1
- package/dst/Custom Voice Input.js +1 -1
- package/dst/Global Command.js +5 -10
- package/dst/Hangup.js +1 -1
- package/dst/Initiate Call.js +1 -1
- package/dst/Join Conference.js +1 -1
- package/dst/Keypad Input.js +1 -1
- package/dst/Kick From Conference.js +1 -1
- package/dst/Say Message.js +1 -1
- package/dst/Send DTMF.js +1 -1
- package/dst/Transfer.js +1 -1
- package/dst/Voice Recording.js +1 -1
- package/dst/step.d.ts +3 -13
- package/dst/step.js +29 -17
- package/dst/voice.d.ts +0 -1
- package/dst/voice.js +0 -9
- package/package.json +1 -1
package/dst/Cancel.js
CHANGED
|
@@ -11,7 +11,7 @@ class VoiceCancel extends voice_1.default {
|
|
|
11
11
|
// return
|
|
12
12
|
// }
|
|
13
13
|
const call = await this.fetchData();
|
|
14
|
-
this.triggers.
|
|
14
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
15
15
|
switch (event.params.type) {
|
|
16
16
|
case 'hangup':
|
|
17
17
|
await this.handleHangup(call);
|
package/dst/Choice.js
CHANGED
|
@@ -93,7 +93,7 @@ class Choice extends voice_1.default {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
// There's a specific need to do so. There might be ${variable} section
|
|
96
|
-
this.triggers.
|
|
96
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
97
97
|
const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
|
|
98
98
|
switch (event.params.type) {
|
|
99
99
|
case 'digit':
|
|
@@ -84,7 +84,7 @@ class CustomVoiceInput extends voice_1.default {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
// There's a specific need to do so. There might be ${variable} section
|
|
87
|
-
this.triggers.
|
|
87
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
88
88
|
const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
|
|
89
89
|
switch (event.params.type) {
|
|
90
90
|
// digit recognition removed
|
package/dst/Global Command.js
CHANGED
|
@@ -49,16 +49,7 @@ class GlobalCommand extends voice_1.default {
|
|
|
49
49
|
async _worker() {
|
|
50
50
|
const call = await this.fetchData();
|
|
51
51
|
if (call.vv >= 1 && lodash_1.default.isFunction(this.triggers.hook)) {
|
|
52
|
-
this.triggers.hook({ name: 'waitEnd', thread: 'main', sync: true }, async () => {
|
|
53
|
-
this.thread.background = call._conv.glb.length > 1;
|
|
54
|
-
if (this.thread.background)
|
|
55
|
-
this.end();
|
|
56
|
-
});
|
|
57
52
|
this.triggers.hook({ name: 'end', thread: 'main' }, async () => {
|
|
58
|
-
this.log.debug('gc terminate', { bg: this.thread.background });
|
|
59
|
-
// if (await this.popConvStep()) {
|
|
60
|
-
// await this.sendEventToStep({ toWorker: this.isWorker, action: 'onAwake' })
|
|
61
|
-
// }
|
|
62
53
|
await this.sendCommands(call, [{ name: 'grammar', params: {} }]);
|
|
63
54
|
if (!this.thread.ending)
|
|
64
55
|
this.end();
|
|
@@ -68,7 +59,7 @@ class GlobalCommand extends voice_1.default {
|
|
|
68
59
|
if (this.event.name.startsWith('@'))
|
|
69
60
|
return;
|
|
70
61
|
}
|
|
71
|
-
this.triggers.
|
|
62
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
72
63
|
event.processed = undefined;
|
|
73
64
|
switch (event.params.type) {
|
|
74
65
|
case 'hangup': {
|
|
@@ -131,6 +122,10 @@ class GlobalCommand extends voice_1.default {
|
|
|
131
122
|
this.event.processed = true;
|
|
132
123
|
break;
|
|
133
124
|
}
|
|
125
|
+
case 'cancel': {
|
|
126
|
+
this.event.processed = true;
|
|
127
|
+
return this.end();
|
|
128
|
+
}
|
|
134
129
|
default:
|
|
135
130
|
return {};
|
|
136
131
|
}
|
package/dst/Hangup.js
CHANGED
|
@@ -5,7 +5,7 @@ const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
|
5
5
|
class Hangup extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const call = await this.fetchData();
|
|
8
|
-
this.triggers.
|
|
8
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
9
9
|
switch (event.params.type) {
|
|
10
10
|
case 'hangup':
|
|
11
11
|
await this.handleHangup(call);
|
package/dst/Initiate Call.js
CHANGED
|
@@ -49,7 +49,7 @@ class InitiateCall extends voice_1.default {
|
|
|
49
49
|
async waitForCall() {
|
|
50
50
|
const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread } = this.data;
|
|
51
51
|
const call = await this.fetchData();
|
|
52
|
-
this.triggers.
|
|
52
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
53
53
|
switch (event.params.type) {
|
|
54
54
|
case 'is_flow_ready': {
|
|
55
55
|
// TODO this.exitFlow({is_ready : true}) should be enough
|
package/dst/Join Conference.js
CHANGED
|
@@ -7,7 +7,7 @@ class JoinConference extends voice_1.default {
|
|
|
7
7
|
async runStep() {
|
|
8
8
|
const call = await this.fetchData();
|
|
9
9
|
const { conferenceName, stayInConference } = this.data;
|
|
10
|
-
this.triggers.
|
|
10
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
11
11
|
switch (event.params.type) {
|
|
12
12
|
case 'hangup':
|
|
13
13
|
await this.handleHangup(call);
|
package/dst/Keypad Input.js
CHANGED
|
@@ -66,7 +66,7 @@ class KeypadInput extends voice_1.default {
|
|
|
66
66
|
}
|
|
67
67
|
const repromptsList = this.buildReprompts({ prompts: this.data.prompts, allowKeypadBargeIn: keypadBargeIn });
|
|
68
68
|
const speechSections = this.buildSections({ sections: this.data.audio, textType, ttsSettings, allowKeypadBargeIn: keypadBargeIn });
|
|
69
|
-
this.triggers.
|
|
69
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
70
70
|
const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
|
|
71
71
|
switch (event.params.type) {
|
|
72
72
|
case 'digits': {
|
|
@@ -7,7 +7,7 @@ class KickFromConference extends voice_1.default {
|
|
|
7
7
|
async runStep() {
|
|
8
8
|
const call = await this.fetchData();
|
|
9
9
|
const { room, user } = this.data;
|
|
10
|
-
this.triggers.
|
|
10
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
11
11
|
switch (event.params.type) {
|
|
12
12
|
case 'hangup':
|
|
13
13
|
await this.handleHangup(call);
|
package/dst/Say Message.js
CHANGED
|
@@ -8,7 +8,7 @@ class SayMessage extends voice_1.default {
|
|
|
8
8
|
async runStep() {
|
|
9
9
|
const { audio, textType, tts, sensitiveData } = this.data;
|
|
10
10
|
const call = await this.fetchData();
|
|
11
|
-
this.triggers.
|
|
11
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
12
12
|
switch (event.params.type) {
|
|
13
13
|
case 'hangup':
|
|
14
14
|
await this.handleHangup(call);
|
package/dst/Send DTMF.js
CHANGED
|
@@ -46,7 +46,7 @@ class SendDTMF extends voice_1.default {
|
|
|
46
46
|
afterDelay: +afterDelay
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
this.triggers.
|
|
49
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
50
50
|
// if (channel.callback.id)
|
|
51
51
|
// await this.mergeFields[_conversation].set(
|
|
52
52
|
// this.takeCallback(),
|
package/dst/Transfer.js
CHANGED
|
@@ -6,7 +6,7 @@ const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
|
6
6
|
class Transfer extends voice_1.default {
|
|
7
7
|
async runStep() {
|
|
8
8
|
const call = await this.fetchData();
|
|
9
|
-
this.triggers.
|
|
9
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
10
10
|
switch (event.params.type) {
|
|
11
11
|
case 'bridge': {
|
|
12
12
|
await this.transcript(call, {
|
package/dst/Voice Recording.js
CHANGED
|
@@ -23,7 +23,7 @@ class Recording extends voice_1.default {
|
|
|
23
23
|
sections
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
this.triggers.
|
|
26
|
+
this.triggers.local(`in/voice/${call.id}/event`, async (event) => {
|
|
27
27
|
const url = event.params.mediaPath;
|
|
28
28
|
switch (event.params.type) {
|
|
29
29
|
case 'hangup':
|
package/dst/step.d.ts
CHANGED
|
@@ -5,8 +5,7 @@ export interface ConvStepDataIn {
|
|
|
5
5
|
conversationThread?: IThreadId;
|
|
6
6
|
}
|
|
7
7
|
export interface IConversation {
|
|
8
|
-
|
|
9
|
-
glb: IConversationStep[];
|
|
8
|
+
dummy?: never;
|
|
10
9
|
}
|
|
11
10
|
export interface IConversationData {
|
|
12
11
|
_conv: IConversation;
|
|
@@ -16,17 +15,9 @@ export declare const enum ConvThreadType {
|
|
|
16
15
|
glb = "glb",
|
|
17
16
|
wrk = "wrk"
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
key: string;
|
|
21
|
-
trd: string;
|
|
22
|
-
typ?: string;
|
|
23
|
-
name?: string;
|
|
24
|
-
label?: string;
|
|
25
|
-
step?: string;
|
|
26
|
-
}
|
|
27
|
-
export default abstract class ConvStep<TData extends IConversationData, TIn = unknown, TOut = unknown, TParams = any> extends Step<TIn & ConvStepDataIn, TOut, TParams> {
|
|
18
|
+
export default class ConvStep<TData extends IConversationData, TIn = unknown, TOut = unknown, TParams = any> extends Step<TIn & ConvStepDataIn, TOut, TParams> {
|
|
28
19
|
private convDataCache?;
|
|
29
|
-
|
|
20
|
+
_worker(_data: IConversationData): Promise<void>;
|
|
30
21
|
get cache(): TData | undefined;
|
|
31
22
|
get conversation(): string | IMergeField;
|
|
32
23
|
get conversationId(): string;
|
|
@@ -69,4 +60,3 @@ export default abstract class ConvStep<TData extends IConversationData, TIn = un
|
|
|
69
60
|
protected _clearCache(): void;
|
|
70
61
|
protected _refreshCache(): Promise<void>;
|
|
71
62
|
}
|
|
72
|
-
export {};
|
package/dst/step.js
CHANGED
|
@@ -3,7 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const step_1 = tslib_1.__importDefault(require("@onereach/flow-sdk/dst/step"));
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
7
|
+
// interface IConversationStep {
|
|
8
|
+
// key: string
|
|
9
|
+
// trd: string
|
|
10
|
+
// typ?: string
|
|
11
|
+
// name?: string // for debug
|
|
12
|
+
// label?: string // for debug
|
|
13
|
+
// step?: string // for debug
|
|
14
|
+
// }
|
|
6
15
|
class ConvStep extends step_1.default {
|
|
16
|
+
async _worker(_data) { }
|
|
7
17
|
get cache() {
|
|
8
18
|
return this.convDataCache;
|
|
9
19
|
}
|
|
@@ -107,6 +117,7 @@ class ConvStep extends step_1.default {
|
|
|
107
117
|
return;
|
|
108
118
|
if (this.thread.id !== this.workerThreadId) {
|
|
109
119
|
const worker = this.process.newThread(this.workerThreadId, thread => {
|
|
120
|
+
thread.background = true;
|
|
110
121
|
thread.state = {
|
|
111
122
|
name: 'worker',
|
|
112
123
|
step: this.step.id,
|
|
@@ -203,11 +214,11 @@ class ConvStep extends step_1.default {
|
|
|
203
214
|
async onAwake() {
|
|
204
215
|
this.state.name = this.state.resumeState;
|
|
205
216
|
this.state.resumeState = undefined;
|
|
206
|
-
const conv = await this.getConversation()
|
|
207
|
-
if (this.isWorker && conv.glb.length === 1) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
217
|
+
// const conv = await this.getConversation()
|
|
218
|
+
// if (this.isWorker && conv.glb.length === 1) {
|
|
219
|
+
// this.log.debug('make global thread foreground')
|
|
220
|
+
// this.thread.background = false
|
|
221
|
+
// }
|
|
211
222
|
}
|
|
212
223
|
async onPause() {
|
|
213
224
|
this.state.resumeState = this.state.prevName;
|
|
@@ -218,18 +229,19 @@ class ConvStep extends step_1.default {
|
|
|
218
229
|
this.state.resumeState = undefined;
|
|
219
230
|
}
|
|
220
231
|
async notifyConvEnd({ onlyLocal } = {}) {
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
232
|
+
this.log.debug('notifyConvEnd', { onlyLocal });
|
|
233
|
+
// const conv = await this.getConversation()
|
|
234
|
+
// const lcl = conv.lcl.splice(0)
|
|
235
|
+
// const wrk = onlyLocal ? [] : conv.glb.splice(0)
|
|
236
|
+
// if (lcl.length > 0 || wrk.length > 0) {
|
|
237
|
+
// await this.updateData()
|
|
238
|
+
// for (const step of lcl) {
|
|
239
|
+
// await this.sendEventToStep({ toStep: step, action: 'onConvEnd' })
|
|
240
|
+
// }
|
|
241
|
+
// for (const step of wrk) {
|
|
242
|
+
// await this.sendEventToStep({ toStep: step, action: 'onConvEnd' })
|
|
243
|
+
// }
|
|
244
|
+
// }
|
|
233
245
|
}
|
|
234
246
|
async waitConvEnd() {
|
|
235
247
|
const workerThread = this.process.getThread(this.workerThreadId);
|
package/dst/voice.d.ts
CHANGED
|
@@ -44,7 +44,6 @@ export interface CallStartEvent extends VoiceEvent {
|
|
|
44
44
|
export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends VoiceEvent = VoiceEvent> extends ConvStep<IVoiceCall, TIn & {
|
|
45
45
|
handleCancel?: boolean;
|
|
46
46
|
}, TOut, TParams> {
|
|
47
|
-
_worker(call: IVoiceCall): Promise<void>;
|
|
48
47
|
runBefore(): Promise<void>;
|
|
49
48
|
sendCommands({ id, type, callback }: IVoiceCall, commands: TODO[]): Promise<void>;
|
|
50
49
|
handleHeartbeat(call: IVoiceCall): Promise<void>;
|
package/dst/voice.js
CHANGED
|
@@ -13,15 +13,6 @@ class VoiceStepError extends base_1.default {
|
|
|
13
13
|
exports.VoiceStepError = VoiceStepError;
|
|
14
14
|
class VoiceStep extends step_1.default {
|
|
15
15
|
// static Error = VoiceStepError
|
|
16
|
-
async _worker(call) {
|
|
17
|
-
this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
|
|
18
|
-
console.log('EVENT', {
|
|
19
|
-
name: this.constructor.name,
|
|
20
|
-
thread: this.thread.id,
|
|
21
|
-
event
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
16
|
async runBefore() {
|
|
26
17
|
await super.runBefore();
|
|
27
18
|
if (this.cache != null) {
|