@onereach/step-voice 5.0.0 → 5.0.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/dst/Choice.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import VoiceStep, { TODO, VoiceEvent } from './voice';
1
+ import VoiceStep, { SensitiveData, TODO, VoiceEvent } from './voice';
2
2
  interface INPUT {
3
3
  textType: string;
4
4
  asr: TODO;
@@ -6,11 +6,7 @@ interface INPUT {
6
6
  audio: TODO[];
7
7
  choices: TODO[];
8
8
  prompts: TODO[];
9
- sensitiveData: {
10
- muteStep: boolean;
11
- muteUser: boolean;
12
- muteBot: boolean;
13
- };
9
+ sensitiveData: SensitiveData;
14
10
  noReplyDelay: number;
15
11
  promptsTriggers: TODO[];
16
12
  usePromptsTriggers: boolean;
package/dst/Choice.js CHANGED
@@ -94,15 +94,6 @@ class Choice extends voice_1.default {
94
94
  };
95
95
  // There's a specific need to do so. There might be ${variable} section
96
96
  this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
97
- if (call.recordCall && sensitiveData?.muteStep) {
98
- await this.sendCommands(call, [{
99
- name: 'resume-record-session',
100
- params: {
101
- muteUser: sensitiveData.muteUser,
102
- muteBot: sensitiveData.muteBot
103
- }
104
- }]);
105
- }
106
97
  const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
107
98
  switch (event.params.type) {
108
99
  case 'digit':
@@ -119,6 +110,7 @@ class Choice extends voice_1.default {
119
110
  action: 'Call DTMF',
120
111
  actionFromBot: false
121
112
  });
113
+ await this.resumeRecording(call, sensitiveData);
122
114
  return this.exitStep(exitId, this.exitChoiceData('dtmf', params));
123
115
  }
124
116
  else if (this.rptsHasMore({ repromptsList })) {
@@ -146,6 +138,7 @@ class Choice extends voice_1.default {
146
138
  action: 'Call DTMF',
147
139
  actionFromBot: false
148
140
  });
141
+ await this.resumeRecording(call, sensitiveData);
149
142
  return this.exitStep('unrecognized', this.exitChoiceData('dtmf', {
150
143
  digit
151
144
  }));
@@ -155,6 +148,7 @@ class Choice extends voice_1.default {
155
148
  const exitId = params.exitId;
156
149
  const phrases = params.phrases;
157
150
  if (lodash_1.default.isEmpty(phrases)) {
151
+ await this.resumeRecording(call, sensitiveData);
158
152
  return this.exitStep('unrecognized', {});
159
153
  }
160
154
  const voiceProcessResult = lodash_1.default.chain(phrases)
@@ -170,6 +164,7 @@ class Choice extends voice_1.default {
170
164
  action: 'Call Recognition',
171
165
  actionFromBot: false
172
166
  });
167
+ await this.resumeRecording(call, sensitiveData);
173
168
  // There might be hooks after this step which we will try to avoid
174
169
  return this.exitStep(exitId, this.exitChoiceData('voice', params));
175
170
  }
@@ -200,6 +195,7 @@ class Choice extends voice_1.default {
200
195
  action: 'Call Recognition',
201
196
  actionFromBot: false
202
197
  });
198
+ await this.resumeRecording(call, sensitiveData);
203
199
  // We might end up in same session
204
200
  return this.exitStep('unrecognized', this.exitChoiceData('voice', params));
205
201
  }
@@ -227,6 +223,7 @@ class Choice extends voice_1.default {
227
223
  action: 'Call Prompt',
228
224
  actionFromBot: false
229
225
  });
226
+ await this.resumeRecording(call, sensitiveData);
230
227
  // We might end up in same session
231
228
  return this.exitStep('no reply', {});
232
229
  }
@@ -256,18 +253,7 @@ class Choice extends voice_1.default {
256
253
  });
257
254
  command.params.sections = speechSections;
258
255
  command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList });
259
- await this.sendCommands(call, [
260
- ...call.recordCall && sensitiveData?.muteStep
261
- ? [{
262
- name: 'stop-record-session',
263
- params: {
264
- muteUser: sensitiveData.muteUser,
265
- muteBot: sensitiveData.muteBot
266
- }
267
- }]
268
- : [],
269
- command
270
- ]);
256
+ await this.pauseRecording(call, command, sensitiveData);
271
257
  return this.exitFlow();
272
258
  });
273
259
  }
@@ -1,4 +1,4 @@
1
- import VoiceStep, { TODO, VoiceEvent } from './voice';
1
+ import VoiceStep, { SensitiveData, TODO, VoiceEvent } from './voice';
2
2
  interface INPUT {
3
3
  textType: string;
4
4
  asr: TODO;
@@ -6,11 +6,7 @@ interface INPUT {
6
6
  audio: TODO[];
7
7
  choices: TODO[];
8
8
  prompts: TODO[];
9
- sensitiveData: {
10
- muteStep: boolean;
11
- muteUser: boolean;
12
- muteBot: boolean;
13
- };
9
+ sensitiveData: SensitiveData;
14
10
  noReplyDelay: number;
15
11
  promptsTriggers: TODO[];
16
12
  usePromptsTriggers: boolean;
@@ -74,15 +74,6 @@ class CustomVoiceInput extends voice_1.default {
74
74
  };
75
75
  // There's a specific need to do so. There might be ${variable} section
76
76
  this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
77
- if (call.recordCall && sensitiveData?.muteStep) {
78
- await this.sendCommands(call, [{
79
- name: 'resume-record-session',
80
- params: {
81
- muteUser: sensitiveData.muteUser,
82
- muteBot: sensitiveData.muteBot
83
- }
84
- }]);
85
- }
86
77
  const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
87
78
  switch (event.params.type) {
88
79
  // digit recognition removed
@@ -91,6 +82,7 @@ class CustomVoiceInput extends voice_1.default {
91
82
  const exitId = params.exitId;
92
83
  const phrases = params.phrases;
93
84
  if (lodash_1.default.isEmpty(phrases)) {
85
+ await this.resumeRecording(call, sensitiveData);
94
86
  return this.exitStep('unrecognized', {});
95
87
  }
96
88
  const voiceProcessResult = lodash_1.default.chain(phrases)
@@ -106,6 +98,7 @@ class CustomVoiceInput extends voice_1.default {
106
98
  action: 'Call Recognition',
107
99
  actionFromBot: false
108
100
  });
101
+ await this.resumeRecording(call, sensitiveData);
109
102
  // There might be hooks after this step which we will try to avoid
110
103
  return this.exitStep(exitId, this.exitChoiceData('voice', params));
111
104
  }
@@ -136,6 +129,7 @@ class CustomVoiceInput extends voice_1.default {
136
129
  action: 'Call Recognition',
137
130
  actionFromBot: false
138
131
  });
132
+ await this.resumeRecording(call, sensitiveData);
139
133
  // We might end up in same session
140
134
  return this.exitStep('unrecognized', this.exitChoiceData('voice', params));
141
135
  }
@@ -163,6 +157,7 @@ class CustomVoiceInput extends voice_1.default {
163
157
  action: 'Call Prompt',
164
158
  actionFromBot: false
165
159
  });
160
+ await this.resumeRecording(call, sensitiveData);
166
161
  // We might end up in same session
167
162
  return this.exitStep('no reply', {});
168
163
  }
@@ -192,18 +187,7 @@ class CustomVoiceInput extends voice_1.default {
192
187
  });
193
188
  command.params.sections = speechSections;
194
189
  command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList });
195
- await this.sendCommands(call, [
196
- ...call.recordCall && sensitiveData?.muteStep
197
- ? [{
198
- name: 'stop-record-session',
199
- params: {
200
- muteUser: sensitiveData.muteUser,
201
- muteBot: sensitiveData.muteBot
202
- }
203
- }]
204
- : [],
205
- command
206
- ]);
190
+ await this.pauseRecording(call, command, sensitiveData);
207
191
  return this.exitFlow();
208
192
  });
209
193
  }
@@ -1,15 +1,11 @@
1
- import VoiceStep, { TODO, VoiceEvent } from './voice';
1
+ import VoiceStep, { SensitiveData, TODO, VoiceEvent } from './voice';
2
2
  interface INPUT {
3
3
  textType: string;
4
4
  asr: TODO;
5
5
  tts: TODO;
6
6
  audio: TODO[];
7
7
  prompts: TODO[];
8
- sensitiveData: {
9
- muteStep: boolean;
10
- muteUser: boolean;
11
- muteBot: boolean;
12
- };
8
+ sensitiveData: SensitiveData;
13
9
  noReplyDelay: number;
14
10
  interTimeout: number;
15
11
  endUserInputValidationOther: TODO;
@@ -68,15 +68,6 @@ class KeypadInput extends voice_1.default {
68
68
  const speechSections = this.buildSections({ sections: this.data.audio, textType, ttsSettings, allowKeypadBargeIn: keypadBargeIn });
69
69
  this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
70
70
  const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
71
- if (call.recordCall && sensitiveData?.muteStep) {
72
- await this.sendCommands(call, [{
73
- name: 'resume-record-session',
74
- params: {
75
- muteUser: sensitiveData.muteUser,
76
- muteBot: sensitiveData.muteBot
77
- }
78
- }]);
79
- }
80
71
  switch (event.params.type) {
81
72
  case 'digits': {
82
73
  const digits = event.params.digits;
@@ -93,6 +84,7 @@ class KeypadInput extends voice_1.default {
93
84
  reportingSettingsKey,
94
85
  actionFromBot: false
95
86
  });
87
+ await this.resumeRecording(call, sensitiveData);
96
88
  return this.exitStep('reply', exitKeypadData({ mfVersion, digits, event }));
97
89
  }
98
90
  else {
@@ -121,6 +113,7 @@ class KeypadInput extends voice_1.default {
121
113
  reportingSettingsKey,
122
114
  actionFromBot: false
123
115
  });
116
+ await this.resumeRecording(call, sensitiveData);
124
117
  return this.exitStep('unrecognized', exitKeypadData({ mfVersion, digits, event }));
125
118
  }
126
119
  }
@@ -148,6 +141,7 @@ class KeypadInput extends voice_1.default {
148
141
  reportingSettingsKey,
149
142
  actionFromBot: false
150
143
  });
144
+ await this.resumeRecording(call, sensitiveData);
151
145
  return this.exitStep('no reply', {});
152
146
  }
153
147
  case 'hangup': {
@@ -176,18 +170,7 @@ class KeypadInput extends voice_1.default {
176
170
  });
177
171
  command.params.firstDigitTimeout = this.rptsTimeout({ noReplyDelay, repromptsList });
178
172
  command.params.sections = speechSections;
179
- await this.sendCommands(call, [
180
- ...call.recordCall && sensitiveData?.muteStep
181
- ? [{
182
- name: 'stop-record-session',
183
- params: {
184
- muteUser: sensitiveData.muteUser,
185
- muteBot: sensitiveData.muteBot
186
- }
187
- }]
188
- : [],
189
- command
190
- ]);
173
+ await this.pauseRecording(call, command, sensitiveData);
191
174
  return this.exitFlow();
192
175
  });
193
176
  }
@@ -1,15 +1,11 @@
1
- import VoiceStep, { TODO } from './voice';
1
+ import VoiceStep, { SensitiveData, TODO } from './voice';
2
2
  interface INPUT {
3
3
  textType: string;
4
4
  tts: TODO;
5
5
  audio: TODO[];
6
6
  choices: TODO[];
7
7
  prompts: TODO[];
8
- sensitiveData: {
9
- muteStep: boolean;
10
- muteUser: boolean;
11
- muteBot: boolean;
12
- };
8
+ sensitiveData: SensitiveData;
13
9
  }
14
10
  export default class SayMessage extends VoiceStep<Partial<INPUT>> {
15
11
  runStep(): Promise<void>;
@@ -9,20 +9,12 @@ class SayMessage extends voice_1.default {
9
9
  const { audio, textType, tts, sensitiveData } = this.data;
10
10
  const call = await this.fetchData();
11
11
  this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
12
- if (call.recordCall && sensitiveData?.muteStep) {
13
- await this.sendCommands(call, [{
14
- name: 'resume-record-session',
15
- params: {
16
- muteUser: sensitiveData.muteUser,
17
- muteBot: sensitiveData.muteBot
18
- }
19
- }]);
20
- }
21
12
  switch (event.params.type) {
22
13
  case 'hangup':
23
14
  await this.handleHangup(call);
24
15
  return await this.waitConvEnd();
25
16
  case 'playback':
17
+ await this.resumeRecording(call, sensitiveData);
26
18
  return this.exitStep('next');
27
19
  case 'error':
28
20
  return this.throwError(event.params.error);
@@ -56,18 +48,7 @@ class SayMessage extends voice_1.default {
56
48
  reportingSettingsKey: 'transcript',
57
49
  actionFromBot: true
58
50
  });
59
- await this.sendCommands(call, [
60
- ...call.recordCall && sensitiveData?.muteStep
61
- ? [{
62
- name: 'stop-record-session',
63
- params: {
64
- muteUser: sensitiveData.muteUser,
65
- muteBot: sensitiveData.muteBot
66
- }
67
- }]
68
- : [],
69
- command
70
- ]);
51
+ await this.pauseRecording(call, command, sensitiveData);
71
52
  return this.exitFlow();
72
53
  });
73
54
  }
@@ -1,13 +1,9 @@
1
- import VoiceStep, { TODO, VoiceEvent } from './voice';
1
+ import VoiceStep, { SensitiveData, TODO, VoiceEvent } from './voice';
2
2
  interface INPUT {
3
3
  textType: string;
4
4
  audio: TODO;
5
5
  tts: TODO;
6
- sensitiveData: {
7
- muteStep: boolean;
8
- muteUser: boolean;
9
- muteBot: boolean;
10
- };
6
+ sensitiveData: SensitiveData;
11
7
  terminationKey: string;
12
8
  recordDurationSeconds: string;
13
9
  }
@@ -24,15 +24,6 @@ class Recording extends voice_1.default {
24
24
  }
25
25
  };
26
26
  this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
27
- if (call.recordCall && sensitiveData?.muteStep) {
28
- await this.sendCommands(call, [{
29
- name: 'resume-record-session',
30
- params: {
31
- muteUser: sensitiveData.muteUser,
32
- muteBot: sensitiveData.muteBot
33
- }
34
- }]);
35
- }
36
27
  const url = event.params.mediaPath;
37
28
  switch (event.params.type) {
38
29
  case 'hangup':
@@ -53,6 +44,7 @@ class Recording extends voice_1.default {
53
44
  this.event.params.zombie = this.state.zombie;
54
45
  // TODO figure out Global Command compatibility
55
46
  lodash_1.default.unset(this.state.hooks, 'skipVoiceEventTypes');
47
+ await this.resumeRecording(call, sensitiveData);
56
48
  return this.exitStep('success', url);
57
49
  }
58
50
  else {
@@ -75,18 +67,7 @@ class Recording extends voice_1.default {
75
67
  action: 'Call Prompt',
76
68
  actionFromBot: true
77
69
  });
78
- await this.sendCommands(call, [
79
- ...call.recordCall && sensitiveData?.muteStep
80
- ? [{
81
- name: 'stop-record-session',
82
- params: {
83
- muteUser: sensitiveData.muteUser,
84
- muteBot: sensitiveData.muteBot
85
- }
86
- }]
87
- : [],
88
- command
89
- ]);
70
+ await this.pauseRecording(call, command, sensitiveData);
90
71
  return this.exitFlow();
91
72
  });
92
73
  }
package/dst/voice.d.ts CHANGED
@@ -2,6 +2,11 @@ import { ICallback, IVoiceReporterTranscriptEventArgs, IPromtpSection } from '@o
2
2
  import ConvStep from './step';
3
3
  import BasicError from '@onereach/flow-sdk/dst/errors/base';
4
4
  export type TODO = any;
5
+ export interface SensitiveData {
6
+ muteStep: boolean;
7
+ muteUser: boolean;
8
+ muteBot: boolean;
9
+ }
5
10
  export interface IVoiceCall {
6
11
  vv: number;
7
12
  id: string;
@@ -42,6 +47,8 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams = VoiceEve
42
47
  fileUrl: string;
43
48
  fileType: string;
44
49
  }>;
50
+ pauseRecording(call: IVoiceCall, command: any, sensitiveData?: SensitiveData): Promise<void>;
51
+ resumeRecording(call: IVoiceCall, sensitiveData?: SensitiveData): Promise<void>;
45
52
  transcript(call: IVoiceCall, data?: Partial<IVoiceReporterTranscriptEventArgs>): Promise<string>;
46
53
  throwError(error?: {
47
54
  name: string;
package/dst/voice.js CHANGED
@@ -71,6 +71,31 @@ class VoiceStep extends step_1.default {
71
71
  }))
72
72
  .value();
73
73
  }
74
+ async pauseRecording(call, command, sensitiveData) {
75
+ await this.sendCommands(call, [
76
+ ...call.recordCall && sensitiveData?.muteStep
77
+ ? [{
78
+ name: 'stop-record-session',
79
+ params: {
80
+ muteUser: sensitiveData.muteUser,
81
+ muteBot: sensitiveData.muteBot
82
+ }
83
+ }]
84
+ : [],
85
+ command
86
+ ]);
87
+ }
88
+ async resumeRecording(call, sensitiveData) {
89
+ if (call.recordCall && sensitiveData?.muteStep) {
90
+ await this.sendCommands(call, [{
91
+ name: 'resume-record-session',
92
+ params: {
93
+ muteUser: sensitiveData.muteUser,
94
+ muteBot: sensitiveData.muteBot
95
+ }
96
+ }]);
97
+ }
98
+ }
74
99
  async transcript(call, data = {}) {
75
100
  const { previousTranscriptId = call.lastTranscriptId, action, keyPress, message, voiceProcessResult, reportingSettingsKey, sections, reprompt, recording, conferenceId, actionFromBot = false } = data;
76
101
  const eventId = (0, uuid_1.v4)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -78,4 +78,4 @@
78
78
  "node_modules"
79
79
  ]
80
80
  }
81
- }
81
+ }