@onereach/step-voice 4.0.33 → 4.0.36

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,9 +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.id);
60
- };
61
58
  this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
62
59
  event.processed = undefined;
63
60
  switch (event.params.type) {
@@ -72,8 +69,8 @@ class GlobalCommand extends voice_1.default {
72
69
  case 'digit':
73
70
  case 'digits': {
74
71
  const params = event.params;
75
- const exitId = params.exitId ?? '';
76
- if (findExit(exitId)) {
72
+ const exitId = params.exitId;
73
+ if (exitId && this.getExitStepId(exitId, false)) {
77
74
  await this.transcript(channel, {
78
75
  previousTranscriptId: channel.lastTranscriptId,
79
76
  keyPress: params.digit,
@@ -84,12 +81,15 @@ class GlobalCommand extends voice_1.default {
84
81
  });
85
82
  return await this.exitThread(event, 'digit', exitId);
86
83
  }
84
+ else {
85
+ this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
86
+ }
87
87
  return {};
88
88
  }
89
89
  case 'recognition': {
90
90
  const params = event.params;
91
- const exitId = params.exitId ?? '';
92
- if (findExit(exitId)) {
91
+ const exitId = params.exitId;
92
+ if (exitId && this.getExitStepId(exitId, false)) {
93
93
  const voiceProcessResult = lodash_1.default.chain(params.phrases)
94
94
  .map((p) => p.lexical)
95
95
  .join(' | ')
@@ -104,6 +104,9 @@ class GlobalCommand extends voice_1.default {
104
104
  });
105
105
  return await this.exitThread(event, 'voice', exitId);
106
106
  }
107
+ else {
108
+ this.log.debug('exitId missmatch', { exitId, exits: this.step.exits });
109
+ }
107
110
  return {};
108
111
  }
109
112
  case 'error':
@@ -138,36 +141,30 @@ class GlobalCommand extends voice_1.default {
138
141
  }
139
142
  }
140
143
  async exitThread(event, type, stepExit) {
141
- // this.log.warn('EXIT HOOK', type, stepExit);
144
+ this.log.debug('exitThread', type, stepExit);
142
145
  const params = event.params;
143
- const data = { type };
146
+ const result = { type };
144
147
  if (!lodash_1.default.isEmpty(params.tags)) {
145
- data.tags = params.tags;
148
+ result.tags = params.tags;
146
149
  }
147
150
  if (!lodash_1.default.isEmpty(params.out)) {
148
- data.out = params.out;
151
+ result.out = params.out;
149
152
  }
150
153
  const digits = params.digits ?? params.digit;
151
154
  if (!lodash_1.default.isEmpty(digits)) {
152
- data.digit = digits;
153
- data.value = digits;
155
+ result.digit = digits;
156
+ result.value = digits;
154
157
  }
155
158
  if (!lodash_1.default.isEmpty(params.phrases)) {
156
159
  const phrases = params.phrases;
157
- data.value = phrases[0].text;
158
- data.interpretation = phrases;
160
+ result.value = phrases[0].text;
161
+ result.interpretation = phrases;
159
162
  }
160
163
  // add information about call recording to a merge field
161
164
  if (!lodash_1.default.isEmpty(params.callRecording)) {
162
- data.callRecording = params.callRecording;
165
+ result.callRecording = params.callRecording;
163
166
  }
164
- // await this.sendCommands(channel, [{
165
- // name: 'grammar',
166
- // params: {}
167
- // }])
168
- // channel.global = null;
169
- // await this.updateData()
170
- const exitLabel = this.getExitStepLabel(stepExit) ?? stepExit;
167
+ const exitLabel = lodash_1.default.replace(this.getExitStepLabel(stepExit) ?? stepExit, /\W+/g, '');
171
168
  await this.process.runThread({
172
169
  id: `${exitLabel}_${(0, nanoid_1.nanoid)(8)}`,
173
170
  state: {
@@ -175,7 +172,8 @@ class GlobalCommand extends voice_1.default {
175
172
  direct: true,
176
173
  result: {
177
174
  conversation: this.conversation,
178
- conversationThreadId: this.dataThreadId
175
+ conversationThreadId: this.dataThreadId,
176
+ ...result
179
177
  },
180
178
  exitStep: stepExit,
181
179
  step: this.currentStepId
package/package.json CHANGED
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.33",
4
- "dev_version": "4.1.0",
5
- "prod_version": "TODO: 4.1.0 ?",
3
+ "version": "4.0.36",
6
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
7
5
  "contributors": [
8
6
  "Roman Zolotarov",