@onereach/step-voice 6.0.12 → 6.0.14-fixpassivegc.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.
@@ -11,7 +11,7 @@ interface INPUT {
11
11
  promptsTriggers: TODO[];
12
12
  usePromptsTriggers: boolean;
13
13
  recognitionModel?: string;
14
- resultInterpretation?: string;
14
+ resultInterpretation: string[];
15
15
  phraseList: Array<{
16
16
  phrase: string;
17
17
  }>;
@@ -41,7 +41,9 @@ const isRepromptTrigger = (recogResult, promptsTriggers) => {
41
41
  return !lodash_1.default.isEmpty(phrases.filter((e) => triggers.includes(e)));
42
42
  };
43
43
  const alterRecognitionPhrases = (phrases, interpretation) => {
44
- switch (interpretation) {
44
+ if (interpretation.length !== 1)
45
+ return;
46
+ switch (interpretation[0]) {
45
47
  case '$POSTALCODE':
46
48
  phrases.forEach(p => { p.lexical = p.lexical.replace(/\s+/g, ''); });
47
49
  break;
@@ -67,14 +67,16 @@ class GlobalCommand extends voice_1.default {
67
67
  this.triggers.otherwise(async () => {
68
68
  await this.initGrammar();
69
69
  });
70
- this.triggers.hook({ name: "waitEnd" /* ACTION.waitEnd */, thread: types_1.MAIN_THREAD_ID, sync: true }, async () => {
71
- delete this.waits['@waitEnd']; // TODO is there beter way to unsubscribe?
72
- if (!call.ended) {
73
- await this.sendCommands(call, [{ name: 'grammar', params: {} }]);
74
- }
75
- if (this.thread.background)
76
- this.end();
77
- });
70
+ if (!call.ended && !this.state.passive) {
71
+ this.triggers.hook({ name: "waitEnd" /* ACTION.waitEnd */, thread: types_1.MAIN_THREAD_ID, sync: true }, async () => {
72
+ if (!call.ended) {
73
+ this.state.passive = true;
74
+ await this.sendCommands(call, [{ name: 'grammar', params: {} }]);
75
+ }
76
+ if (this.thread.background)
77
+ this.end();
78
+ });
79
+ }
78
80
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
79
81
  switch (event.params.type) {
80
82
  case 'hangup':
@@ -99,7 +101,7 @@ class GlobalCommand extends voice_1.default {
99
101
  else {
100
102
  this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
101
103
  }
102
- return {};
104
+ break;
103
105
  }
104
106
  case 'recognition': {
105
107
  const params = event.params;
@@ -122,7 +124,7 @@ class GlobalCommand extends voice_1.default {
122
124
  else {
123
125
  this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
124
126
  }
125
- return {};
127
+ break;
126
128
  }
127
129
  case 'error': {
128
130
  if (event.params.error) {
@@ -140,18 +142,25 @@ class GlobalCommand extends voice_1.default {
140
142
  break;
141
143
  }
142
144
  default:
143
- return {};
145
+ break;
144
146
  }
145
147
  });
146
148
  }
147
149
  async hangup(call) {
148
150
  if (this.event.params.zombie) {
149
- this.log.debug('ignore zombie hangup');
150
- return this.exitFlow();
151
+ if (this.state.passive) {
152
+ this.log.debug('ignore zombie hangup waiting for full hangup');
153
+ return this.exitFlow();
154
+ }
155
+ this.log.debug('this gc was ignored because call is aleady hang up');
156
+ return this.end();
151
157
  }
152
158
  await this.handleHangup(call);
153
159
  const isHangedUpByBot = call.sessionEndedBy === 'Bot';
154
- const hangUpType = isHangedUpByBot ? 'bot hang up' : 'user hang up';
160
+ let hangUpType = isHangedUpByBot ? 'bot hang up' : 'user hang up';
161
+ if (this.event.params.error != null) {
162
+ hangUpType = 'unexpected hang up';
163
+ }
155
164
  let processHangUp = this.data.processHangUp;
156
165
  // process call recording in hangup event
157
166
  if (call.recordCall && this.event.params.callRecording != null) {
@@ -54,11 +54,14 @@ class SendDTMF extends voice_1.default {
54
54
  // );
55
55
  switch (event.params.type) {
56
56
  case 'hangup':
57
- return this.end();
57
+ await this.handleHangup(call);
58
+ return await this.waitConvEnd();
58
59
  case 'dtmf-sent':
59
60
  return this.exitStep('next');
60
61
  case 'error':
61
62
  return this.throwError(event.params.error);
63
+ case 'cancel':
64
+ return this.handleCancel();
62
65
  default:
63
66
  return this.exitFlow();
64
67
  }
package/dst/voice.js CHANGED
@@ -222,10 +222,11 @@ class VoiceStep extends step_1.default {
222
222
  async handleHangup(call) {
223
223
  if (call.ended)
224
224
  return;
225
+ const isHangedUpByBot = call.sessionEndedBy === 'Bot';
225
226
  await this.transcript(call, {
226
227
  action: 'Call End',
227
- reportingSettingsKey: 'transcript',
228
- actionFromBot: false
228
+ reportingSettingsKey: 'transcriptHangup',
229
+ actionFromBot: isHangedUpByBot
229
230
  });
230
231
  call.ended = true;
231
232
  await this.updateData();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "6.0.12",
3
+ "version": "6.0.14-fixpassivegc.0",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",