@onereach/step-voice 6.0.20-refdata.0 → 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 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
  });
@@ -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.0",
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",
@@ -81,4 +81,4 @@
81
81
  "node_modules"
82
82
  ]
83
83
  }
84
- }
84
+ }