@onereach/step-voice 4.0.28 → 4.0.29

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
@@ -14,6 +14,7 @@ interface INPUT {
14
14
  noReplyDelay: number;
15
15
  promptsTriggers: TODO[];
16
16
  usePromptsTriggers: boolean;
17
+ recognitionModel?: string;
17
18
  }
18
19
  interface EVENT extends VoiceEvent {
19
20
  callRecording?: TODO;
package/dst/Choice.js CHANGED
@@ -34,7 +34,7 @@ const getPhrasesForSpeechRec = (choices) => {
34
34
  }
35
35
  return texts;
36
36
  };
37
- const getAsrSettings = (settings, choices) => {
37
+ const getAsrSettings = (settings, choices, recognitionModel) => {
38
38
  if (settings.engine === 'google' || settings.engine === 'google_beta') {
39
39
  return {
40
40
  ...settings,
@@ -43,7 +43,8 @@ const getAsrSettings = (settings, choices) => {
43
43
  {
44
44
  phrases: getPhrasesForSpeechRec(choices)
45
45
  }
46
- ]
46
+ ],
47
+ recognitionModel
47
48
  }
48
49
  };
49
50
  }
@@ -68,13 +69,13 @@ const isRepromptTrigger = (recogResult, promptsTriggers) => {
68
69
  class Choice extends voice_1.default {
69
70
  async runStep() {
70
71
  const channel = await this.fetchData();
71
- const { textType, asr, tts, sensitiveData, noReplyDelay, usePromptsTriggers } = this.data;
72
+ const { textType, asr, tts, sensitiveData, noReplyDelay, usePromptsTriggers, recognitionModel } = this.data;
72
73
  const exitExists = (exitId) => {
73
74
  return lodash_1.default.some(choices, (choice) => choice.exitId === exitId);
74
75
  };
75
76
  const choices = this.buildChoices({ choices: this.data.choices });
76
77
  const ttsSettings = tts.getSettings(channel.tts);
77
- const asrSettings = getAsrSettings(asr.getSettings(channel.asr), choices);
78
+ const asrSettings = getAsrSettings(asr.getSettings(channel.asr), choices, recognitionModel);
78
79
  const repromptsList = this.buildReprompts({ prompts: this.data.prompts });
79
80
  const speechSections = this.buildSections({ sections: this.data.audio, textType, ttsSettings });
80
81
  const grammar = {
@@ -16,6 +16,9 @@ class GlobalCommand extends voice_1.default {
16
16
  this._clearCache();
17
17
  await this.process.runThread({
18
18
  id: `G:${this.dataThreadId}`,
19
+ local: {
20
+ background: true
21
+ },
19
22
  state: {
20
23
  name: 'initThread',
21
24
  step: this.step.id,
@@ -66,20 +69,20 @@ class GlobalCommand extends voice_1.default {
66
69
  function exitExists(exitId) {
67
70
  return lodash_1.default.some(choices, (choice) => choice.exitId === exitId);
68
71
  }
69
- // if (channel.autoHangup) {
70
- // this.triggers.local('thread/end/main', async () => {
71
- // delete this.thread.waits['thread/end/main']
72
- // const channel = await this.fetchData()
73
- // if (!channel.hangup) {
74
- // channel.autoHangup = false
75
- // await this.updateData()
76
- // this.local.background = undefined
77
- // await this.sendCommands(channel, [{ name: 'hangup' }])
78
- // void this.process.main.enqueueAndRun({ name: 'ending' })
79
- // this.exitFlow()
80
- // }
81
- // })
82
- // }
72
+ if (channel.autoHangup) {
73
+ this.triggers.local('thread/end/main', async () => {
74
+ delete this.thread.waits['thread/end/main'];
75
+ const channel = await this.fetchData();
76
+ if (!channel.hangup) {
77
+ channel.autoHangup = false;
78
+ await this.updateData();
79
+ this.local.background = undefined;
80
+ await this.sendCommands(channel, [{ name: 'hangup' }]);
81
+ void this.process.main.enqueueAndRun({ name: 'ending' });
82
+ this.exitFlow();
83
+ }
84
+ });
85
+ }
83
86
  this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
84
87
  event.processed = undefined;
85
88
  switch (event.params.type) {
@@ -2,7 +2,6 @@ import VoiceStep, { CallStartEvent, TODO } from './voice';
2
2
  interface INPUT {
3
3
  channelId?: string;
4
4
  sessionTimeout?: number | string;
5
- autoHangup?: boolean;
6
5
  asr: TODO;
7
6
  tts: TODO;
8
7
  from: string;
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable
3
- @typescript-eslint/strict-boolean-expressions,
4
- @typescript-eslint/explicit-function-return-type,
5
- @typescript-eslint/no-misused-promises
6
- */
2
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/explicit-function-return-type */
7
3
  Object.defineProperty(exports, "__esModule", { value: true });
8
4
  const tslib_1 = require("tslib");
9
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
@@ -39,7 +35,7 @@ class InitiateCall extends voice_1.default {
39
35
  this.gotoState('waitForCall');
40
36
  }
41
37
  async waitForCall() {
42
- const { autoHangup, asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD } = this.data;
38
+ const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD } = this.data;
43
39
  const { id: channelId } = await this.fetchData();
44
40
  this.triggers.once(`in/voice/${channelId}/event`, async (event) => {
45
41
  switch (event.params.type) {
@@ -60,7 +56,6 @@ class InitiateCall extends voice_1.default {
60
56
  const channel = {
61
57
  headers: event.params.headers,
62
58
  ...event.params.channel,
63
- autoHangup,
64
59
  asr: asr.getSettings(),
65
60
  tts: tts.getVoice(),
66
61
  botNumber: event.params.channel.to ?? 'unknown',
@@ -94,9 +89,6 @@ class InitiateCall extends voice_1.default {
94
89
  }]
95
90
  : []
96
91
  ]);
97
- if (this.data.autoHangup) {
98
- this.once('ending', this.autoHangup);
99
- }
100
92
  return this.exitStep('success');
101
93
  }
102
94
  case 'error': {
@@ -19,6 +19,7 @@ interface INPUT {
19
19
  expectedNumberOfDigits: number;
20
20
  regExToValidate: string;
21
21
  mfVersion: string;
22
+ recognitionModel?: string;
22
23
  }
23
24
  interface EVENT extends VoiceEvent {
24
25
  callRecording?: TODO;
@@ -26,7 +26,7 @@ const validateInput = ({ input = '', type, regex, expectedLength }) => {
26
26
  class KeypadInput extends voice_1.default {
27
27
  async runStep() {
28
28
  const channel = await this.fetchData();
29
- const { interTimeout, asr, tts, noReplyDelay, textType, keypadBargeIn, endInput, terminationKey, endUserInputValidationOther, expectedNumberOfDigits, regExToValidate, mfVersion, sensitiveData } = this.data;
29
+ const { interTimeout, asr, tts, noReplyDelay, textType, keypadBargeIn, endInput, terminationKey, endUserInputValidationOther, expectedNumberOfDigits, regExToValidate, mfVersion, sensitiveData, recognitionModel } = this.data;
30
30
  const interDigitTimeout = Number(interTimeout) * 1000;
31
31
  const ttsSettings = tts.getSettings(channel.tts);
32
32
  const asrSettings = asr.getSettings(channel.asr);
@@ -35,7 +35,8 @@ class KeypadInput extends voice_1.default {
35
35
  asr: {
36
36
  ...asrSettings,
37
37
  config: {
38
- version: 'v1beta'
38
+ version: 'v1beta',
39
+ recognitionModel
39
40
  }
40
41
  }
41
42
  };
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable
3
- @typescript-eslint/strict-boolean-expressions,
4
- @typescript-eslint/explicit-function-return-type,
5
- @typescript-eslint/no-misused-promises
6
- */
2
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/explicit-function-return-type */
7
3
  Object.defineProperty(exports, "__esModule", { value: true });
8
4
  const tslib_1 = require("tslib");
9
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
@@ -21,13 +17,8 @@ class WaitForCall extends voice_1.default {
21
17
  async runStep() {
22
18
  const selectedNumbers = this.data.selectedNumbers;
23
19
  lodash_1.default.forEach(selectedNumbers, number => {
24
- this.triggers.on(`in/voice/${number.value}/call`, this.onCall);
20
+ this.triggers.on(`in/voice/${number.value}/call`, async (event) => await this.onCall(event));
25
21
  });
26
- if (this.data.autoHangup) {
27
- this.triggers.otherwise(() => {
28
- this.once('ending', this.autoHangup);
29
- });
30
- }
31
22
  }
32
23
  async onCall(event) {
33
24
  const { autoHangup, asr, tts, endOfInputTimeout } = this.data;
package/dst/step.js CHANGED
@@ -149,7 +149,6 @@ class ConvStep extends step_1.default {
149
149
  }
150
150
  }
151
151
  async waitCancelEnd() {
152
- this.local.background = true;
153
152
  this.exitFlow();
154
153
  }
155
154
  async pause() {
package/dst/voice.d.ts CHANGED
@@ -4,7 +4,7 @@ import BasicError from '@onereach/flow-sdk/dst/errors/base';
4
4
  export declare type TODO = any;
5
5
  export interface IVoiceChannel {
6
6
  id: string;
7
- autoHangup?: boolean;
7
+ autoHangup: boolean;
8
8
  hangup: boolean;
9
9
  endUserNumber: string;
10
10
  botNumber: string;
@@ -47,7 +47,6 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams = VoiceEve
47
47
  message: string;
48
48
  }): never;
49
49
  handleHangup(channel: IVoiceChannel): Promise<void>;
50
- autoHangup(): Promise<void>;
51
50
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }: TODO): TODO;
52
51
  buildReprompts({ prompts, allowKeypadBargeIn }: TODO): TODO;
53
52
  buildChoices({ choices }: TODO): TODO;
package/dst/voice.js CHANGED
@@ -116,12 +116,6 @@ class VoiceStep extends step_1.default {
116
116
  channel.hangup = true;
117
117
  await this.updateData();
118
118
  }
119
- async autoHangup() {
120
- const channel = await this.fetchData();
121
- if (!channel.hangup) {
122
- await this.sendCommands(channel, [{ name: 'hangup', reason: 'AUTO' }]);
123
- }
124
- }
125
119
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }) {
126
120
  return lodash_1.default.map(sections, section => ({
127
121
  text: section.voiceTextMsg,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.28",
3
+ "version": "4.0.29",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -18,7 +18,7 @@
18
18
  "uuid": "^8.3.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@onereach/flow-sdk": "^3.1.37",
21
+ "@onereach/flow-sdk": "^3.1.36",
22
22
  "@swc/cli": "^0.1.57",
23
23
  "@swc/core": "^1.2.205",
24
24
  "@swc/jest": "^0.2.21",