@onereach/step-voice 5.0.0 → 5.0.2-bargein.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
@@ -70,6 +70,7 @@ class Choice extends voice_1.default {
70
70
  async runStep() {
71
71
  const call = await this.fetchData();
72
72
  const { textType, asr, tts, sensitiveData, noReplyDelay, usePromptsTriggers, recognitionModel, useInterspeechTimeout, interSpeechTimeout } = this.data;
73
+ console.log({ data: this.data }, 'runStep');
73
74
  const exitExists = (exitId) => {
74
75
  return lodash_1.default.some(choices, (choice) => choice.exitId === exitId);
75
76
  };
@@ -78,6 +79,7 @@ class Choice extends voice_1.default {
78
79
  const asrSettings = getAsrSettings(asr.getSettings(call.asr), choices, recognitionModel);
79
80
  const repromptsList = this.buildReprompts({ prompts: this.data.prompts });
80
81
  const speechSections = this.buildSections({ sections: this.data.audio, textType, ttsSettings });
82
+ console.log({ speechSections }, 'speechSections');
81
83
  const grammar = {
82
84
  id: this.currentStepId,
83
85
  choices,
@@ -94,15 +96,6 @@ class Choice extends voice_1.default {
94
96
  };
95
97
  // There's a specific need to do so. There might be ${variable} section
96
98
  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
99
  const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
107
100
  switch (event.params.type) {
108
101
  case 'digit':
@@ -119,6 +112,7 @@ class Choice extends voice_1.default {
119
112
  action: 'Call DTMF',
120
113
  actionFromBot: false
121
114
  });
115
+ await this.resumeRecording(call, sensitiveData);
122
116
  return this.exitStep(exitId, this.exitChoiceData('dtmf', params));
123
117
  }
124
118
  else if (this.rptsHasMore({ repromptsList })) {
@@ -146,6 +140,7 @@ class Choice extends voice_1.default {
146
140
  action: 'Call DTMF',
147
141
  actionFromBot: false
148
142
  });
143
+ await this.resumeRecording(call, sensitiveData);
149
144
  return this.exitStep('unrecognized', this.exitChoiceData('dtmf', {
150
145
  digit
151
146
  }));
@@ -155,6 +150,7 @@ class Choice extends voice_1.default {
155
150
  const exitId = params.exitId;
156
151
  const phrases = params.phrases;
157
152
  if (lodash_1.default.isEmpty(phrases)) {
153
+ await this.resumeRecording(call, sensitiveData);
158
154
  return this.exitStep('unrecognized', {});
159
155
  }
160
156
  const voiceProcessResult = lodash_1.default.chain(phrases)
@@ -170,6 +166,7 @@ class Choice extends voice_1.default {
170
166
  action: 'Call Recognition',
171
167
  actionFromBot: false
172
168
  });
169
+ await this.resumeRecording(call, sensitiveData);
173
170
  // There might be hooks after this step which we will try to avoid
174
171
  return this.exitStep(exitId, this.exitChoiceData('voice', params));
175
172
  }
@@ -200,6 +197,7 @@ class Choice extends voice_1.default {
200
197
  action: 'Call Recognition',
201
198
  actionFromBot: false
202
199
  });
200
+ await this.resumeRecording(call, sensitiveData);
203
201
  // We might end up in same session
204
202
  return this.exitStep('unrecognized', this.exitChoiceData('voice', params));
205
203
  }
@@ -227,6 +225,7 @@ class Choice extends voice_1.default {
227
225
  action: 'Call Prompt',
228
226
  actionFromBot: false
229
227
  });
228
+ await this.resumeRecording(call, sensitiveData);
230
229
  // We might end up in same session
231
230
  return this.exitStep('no reply', {});
232
231
  }
@@ -256,18 +255,7 @@ class Choice extends voice_1.default {
256
255
  });
257
256
  command.params.sections = speechSections;
258
257
  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
- ]);
258
+ await this.pauseRecording(call, command, sensitiveData);
271
259
  return this.exitFlow();
272
260
  });
273
261
  }
@@ -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.2-bargein.1",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -44,13 +44,9 @@
44
44
  "build": "npm run clean && tsc -p ./tsconfig.build.json",
45
45
  "build-fast": "npm run clean && swc ./src -d ./dst",
46
46
  "deploy": "./scripts/deploy.sh",
47
- "download-prod": "./scripts/download.sh prod",
48
- "download-dev": "s./scripts/download.sh dev",
49
- "upload-prod": "./scripts/upload.sh prod",
50
- "upload-dev": "./scripts/upload.sh dev",
47
+ "download": "./scripts/download.sh",
48
+ "upload": "./scripts/upload.sh",
51
49
  "pub": "./scripts/publish.sh",
52
- "publish-patch": "echo use: npm run pub; exit 1",
53
- "publish-beta": "echo use: npm run pub; exit 1",
54
50
  "test": "jest"
55
51
  },
56
52
  "repository": {
@@ -78,4 +74,4 @@
78
74
  "node_modules"
79
75
  ]
80
76
  }
81
- }
77
+ }