@onereach/step-voice 6.0.20-refdata.0 → 6.1.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.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
  });
@@ -38,6 +38,6 @@ export default class GlobalCommand extends VoiceStep<Partial<INPUT>, OUTPUT, EVE
38
38
  hangup(call: IVoiceCall): Promise<unknown>;
39
39
  exitThread(event: ITypedEvent<EVENT>, type: string, stepExit: string): Promise<void>;
40
40
  buildGrammar(call: IVoiceCall, choices: TODO[]): Promise<any>;
41
- replyAck(eventParams: any): void;
41
+ acceptAck(eventParams: any): void;
42
42
  }
43
43
  export {};
@@ -15,6 +15,9 @@ class GlobalCommand extends voice_1.default {
15
15
  async runStep() {
16
16
  const call = await this.fetchData();
17
17
  const allowAck = this.canVoicerAck(call);
18
+ if (this.thread.id === this.workerThreadId) {
19
+ throw new Error('gc worker should not use runStep, is another gc on hangup leg?');
20
+ }
18
21
  const worker = this.process.newThread(this.workerThreadId, thread => {
19
22
  thread.state = {
20
23
  name: this.worker.name,
@@ -35,6 +38,7 @@ class GlobalCommand extends voice_1.default {
35
38
  }
36
39
  if (allowAck) {
37
40
  this.triggers.local('ack', ({ params: { ack } }) => {
41
+ delete worker.state.acktrd;
38
42
  if (ack)
39
43
  this.exitStep('no commands');
40
44
  else
@@ -97,14 +101,16 @@ class GlobalCommand extends voice_1.default {
97
101
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
98
102
  switch (event.params.type) {
99
103
  case 'ack': {
100
- this.replyAck({ ack: true });
104
+ this.acceptAck({ ack: true });
101
105
  return;
102
106
  }
103
107
  case 'hangup':
104
- this.replyAck({ ack: false });
105
- return await this.hangup(call);
108
+ this.acceptAck({ ack: false });
109
+ await this.hangup(call);
110
+ return;
106
111
  case 'avm-detected':
107
- return await this.exitThread(event, 'AMD', 'AMD');
112
+ await this.exitThread(event, 'AMD', 'AMD');
113
+ return;
108
114
  case 'digit':
109
115
  case 'digits': {
110
116
  const params = event.params;
@@ -245,14 +251,13 @@ class GlobalCommand extends voice_1.default {
245
251
  asr: asr.getSettings(call.asr)
246
252
  };
247
253
  }
248
- replyAck(eventParams) {
254
+ acceptAck(eventParams) {
249
255
  if (this.state.acktrd) {
250
256
  this.process.enqueue({
251
257
  thread: this.state.acktrd,
252
258
  name: 'ack',
253
259
  params: eventParams
254
260
  });
255
- delete this.state.acktrd;
256
261
  }
257
262
  }
258
263
  }
@@ -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 {};
@@ -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',
@@ -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
- const { room, user } = this.data;
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 {
@@ -74,7 +78,7 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends Vo
74
78
  buildChoice(choice: TODO): TODO;
75
79
  exitChoiceData(type: string, params?: TODO): TODO;
76
80
  rptsSend(call: IVoiceCall, { command, reporting, repromptsList, noReplyDelay, speechSections, textType, ttsSettings, sensitiveData }: TODO): Promise<void>;
77
- rptsTimeout({ noReplyDelay, repromptsList }: TODO): number;
81
+ rptsTimeout({ noReplyDelay, repromptsList, initial }: TODO): number;
78
82
  rptsRestart(): void;
79
83
  rptsHasMore({ repromptsList }: TODO): boolean;
80
84
  get rptsIndex(): number;
package/dst/voice.js CHANGED
@@ -207,13 +207,13 @@ class VoiceStep extends step_1.default {
207
207
  if (call.ended)
208
208
  return;
209
209
  const isHangedUpByBot = call.sessionEndedBy === 'Bot';
210
+ call.conference = undefined;
211
+ call.ended = true;
210
212
  await this.transcript(call, {
211
213
  action: 'Call End',
212
214
  reportingSettingsKey: 'transcriptHangup',
213
215
  actionFromBot: isHangedUpByBot
214
216
  });
215
- call.ended = true;
216
- await this.updateData();
217
217
  }
218
218
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }) {
219
219
  return lodash_1.default.map(sections, section => ({
@@ -329,9 +329,9 @@ class VoiceStep extends step_1.default {
329
329
  else
330
330
  await this.sendCommands(call, [command]);
331
331
  }
332
- rptsTimeout({ noReplyDelay, repromptsList }) {
333
- const current = repromptsList[this.rptsIndex];
334
- return Number(lodash_1.default.get(current, 'time', noReplyDelay)) * 1000 || 60000;
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;
335
335
  }
336
336
  rptsRestart() {
337
337
  this.state.repIdx = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "6.0.20-refdata.0",
3
+ "version": "6.1.1",
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": "^3.2.46",
23
- "@onereach/orbes": "^3.1.51",
22
+ "@onereach/flow-sdk": "^3.2.50",
23
+ "@onereach/orbes": "^3.1.57",
24
24
  "@onereach/step-voice": "./test",
25
25
  "@swc/cli": "^0.1.62",
26
26
  "@swc/core": "^1.3.57",