@onereach/step-voice 6.0.13 → 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,15 +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
- this.state.passive = true;
74
- await this.sendCommands(call, [{ name: 'grammar', params: {} }]);
75
- }
76
- if (this.thread.background)
77
- this.end();
78
- });
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
+ }
79
80
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
80
81
  switch (event.params.type) {
81
82
  case 'hangup':
@@ -100,7 +101,7 @@ class GlobalCommand extends voice_1.default {
100
101
  else {
101
102
  this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
102
103
  }
103
- return {};
104
+ break;
104
105
  }
105
106
  case 'recognition': {
106
107
  const params = event.params;
@@ -123,7 +124,7 @@ class GlobalCommand extends voice_1.default {
123
124
  else {
124
125
  this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
125
126
  }
126
- return {};
127
+ break;
127
128
  }
128
129
  case 'error': {
129
130
  if (event.params.error) {
@@ -141,7 +142,7 @@ class GlobalCommand extends voice_1.default {
141
142
  break;
142
143
  }
143
144
  default:
144
- return {};
145
+ break;
145
146
  }
146
147
  });
147
148
  }
@@ -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.13",
3
+ "version": "6.0.14-fixpassivegc.0",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",