@onereach/step-voice 4.0.31 → 4.0.34

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.
@@ -55,23 +55,6 @@ class GlobalCommand extends voice_1.default {
55
55
  }
56
56
  async globThread() {
57
57
  const channel = await this.fetchData();
58
- const findExit = (exitId) => {
59
- return lodash_1.default.find(this.step.exits, (exit) => exitId === exit.stepId);
60
- };
61
- // if (channel.autoHangup) {
62
- // this.triggers.local('thread/end/main', async () => {
63
- // delete this.thread.waits['thread/end/main']
64
- // const channel = await this.fetchData()
65
- // if (!channel.hangup) {
66
- // channel.autoHangup = false
67
- // await this.updateData()
68
- // this.local.background = undefined
69
- // await this.sendCommands(channel, [{ name: 'hangup' }])
70
- // void this.process.main.enqueueAndRun({ name: 'ending' })
71
- // this.exitFlow()
72
- // }
73
- // })
74
- // }
75
58
  this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
76
59
  event.processed = undefined;
77
60
  switch (event.params.type) {
@@ -86,8 +69,8 @@ class GlobalCommand extends voice_1.default {
86
69
  case 'digit':
87
70
  case 'digits': {
88
71
  const params = event.params;
89
- const exitId = params.exitId ?? '';
90
- if (findExit(exitId)) {
72
+ const exitId = params.exitId;
73
+ if (exitId && this.getExitStepId(exitId, false)) {
91
74
  await this.transcript(channel, {
92
75
  previousTranscriptId: channel.lastTranscriptId,
93
76
  keyPress: params.digit,
@@ -98,12 +81,15 @@ class GlobalCommand extends voice_1.default {
98
81
  });
99
82
  return await this.exitThread(event, 'digit', exitId);
100
83
  }
84
+ else {
85
+ this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
86
+ }
101
87
  return {};
102
88
  }
103
89
  case 'recognition': {
104
90
  const params = event.params;
105
- const exitId = params.exitId ?? '';
106
- if (findExit(exitId)) {
91
+ const exitId = params.exitId;
92
+ if (exitId && this.getExitStepId(exitId, false)) {
107
93
  const voiceProcessResult = lodash_1.default.chain(params.phrases)
108
94
  .map((p) => p.lexical)
109
95
  .join(' | ')
@@ -118,6 +104,9 @@ class GlobalCommand extends voice_1.default {
118
104
  });
119
105
  return await this.exitThread(event, 'voice', exitId);
120
106
  }
107
+ else {
108
+ this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
109
+ }
121
110
  return {};
122
111
  }
123
112
  case 'error':
@@ -152,7 +141,7 @@ class GlobalCommand extends voice_1.default {
152
141
  }
153
142
  }
154
143
  async exitThread(event, type, stepExit) {
155
- // this.log.warn('EXIT HOOK', type, stepExit);
144
+ this.log.debug('exitThread', type, stepExit);
156
145
  const params = event.params;
157
146
  const data = { type };
158
147
  if (!lodash_1.default.isEmpty(params.tags)) {
@@ -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;
@@ -36,7 +36,7 @@ class InitiateCall extends voice_1.default {
36
36
  this.gotoState('waitForCall');
37
37
  }
38
38
  async waitForCall() {
39
- const { autoHangup, asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD } = this.data;
39
+ const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD } = this.data;
40
40
  const { id: channelId } = await this.fetchData();
41
41
  this.triggers.once(`in/voice/${channelId}/event`, async (event) => {
42
42
  switch (event.params.type) {
@@ -57,7 +57,6 @@ class InitiateCall extends voice_1.default {
57
57
  const channel = {
58
58
  headers: event.params.headers,
59
59
  ...event.params.channel,
60
- autoHangup,
61
60
  asr: asr.getSettings(),
62
61
  tts: tts.getVoice(),
63
62
  botNumber: event.params.channel.to ?? 'unknown',
@@ -91,9 +90,6 @@ class InitiateCall extends voice_1.default {
91
90
  }]
92
91
  : []
93
92
  ]);
94
- if (this.data.autoHangup) {
95
- this.once('ending', this.autoHangup);
96
- }
97
93
  return this.exitStep('success');
98
94
  }
99
95
  case 'error': {
@@ -20,18 +20,12 @@ class WaitForCall extends voice_1.default {
20
20
  lodash_1.default.forEach(selectedNumbers, number => {
21
21
  this.triggers.on(`in/voice/${number.value}/call`, this.onCall);
22
22
  });
23
- if (this.data.autoHangup) {
24
- this.triggers.otherwise(() => {
25
- this.once('ending', this.autoHangup);
26
- });
27
- }
28
23
  }
29
24
  async onCall(event) {
30
- const { autoHangup, asr, tts, endOfInputTimeout } = this.data;
25
+ const { asr, tts, endOfInputTimeout } = this.data;
31
26
  const channel = {
32
27
  headers: event.params.headers,
33
28
  ...event.params.channel,
34
- autoHangup,
35
29
  asr: asr.getSettings(),
36
30
  tts: tts.getVoice(),
37
31
  botNumber: event.params.channel.to ?? 'unknown',
package/dst/voice.d.ts CHANGED
@@ -4,7 +4,6 @@ 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;
8
7
  hangup: boolean;
9
8
  endUserNumber: string;
10
9
  botNumber: string;
@@ -46,7 +45,6 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams = VoiceEve
46
45
  message: string;
47
46
  }): never;
48
47
  handleHangup(channel: IVoiceChannel): Promise<void>;
49
- autoHangup(): Promise<void>;
50
48
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }: TODO): TODO;
51
49
  buildReprompts({ prompts, allowKeypadBargeIn }: TODO): TODO;
52
50
  buildChoices({ choices }: TODO): TODO;
package/dst/voice.js CHANGED
@@ -113,12 +113,6 @@ class VoiceStep extends step_1.default {
113
113
  channel.hangup = true;
114
114
  await this.updateData();
115
115
  }
116
- async autoHangup() {
117
- const channel = await this.fetchData();
118
- if (!channel.hangup) {
119
- await this.sendCommands(channel, [{ name: 'hangup', reason: 'AUTO' }]);
120
- }
121
- }
122
116
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }) {
123
117
  return lodash_1.default.map(sections, section => ({
124
118
  text: section.voiceTextMsg,
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.31",
3
+ "version": "4.0.34",
4
+ "pkg_version": "4",
5
+ "dep_version": "^$[__package.pkg_version]",
4
6
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
7
  "contributors": [
6
8
  "Roman Zolotarov",