@onereach/step-voice 6.0.7 → 6.0.9

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.
@@ -37,7 +37,6 @@ export default class GlobalCommand extends VoiceStep<Partial<INPUT>, OUTPUT, EVE
37
37
  exitThread(event: ITypedEvent<EVENT>, type: string, stepExit: string): Promise<void>;
38
38
  exitToThread(): void;
39
39
  buildGrammar(call: IVoiceCall, choices: TODO[]): Promise<any>;
40
- exitFlow(): unknown;
41
40
  sleepUntilHangup(): void;
42
41
  }
43
42
  export {};
@@ -90,7 +90,6 @@ class GlobalCommand extends voice_1.default {
90
90
  this.end();
91
91
  });
92
92
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
93
- event.processed = undefined;
94
93
  switch (event.params.type) {
95
94
  case 'hangup': {
96
95
  await this.hangup(call);
@@ -153,15 +152,12 @@ class GlobalCommand extends voice_1.default {
153
152
  this.log.error('gc.error', event.params.error);
154
153
  // TODO throw it?
155
154
  }
156
- this.event.processed = true;
157
155
  break;
158
156
  }
159
157
  case 'cancel': {
160
- this.event.processed = true;
161
158
  return this.handleCancel();
162
159
  }
163
160
  case 'background': {
164
- this.event.processed = true;
165
161
  this.thread.background = event.params.background ?? false;
166
162
  await this.handleHeartbeat(call);
167
163
  break;
@@ -241,7 +237,6 @@ class GlobalCommand extends voice_1.default {
241
237
  step: this.currentStepId
242
238
  }
243
239
  });
244
- event.processed = true;
245
240
  }
246
241
  exitToThread() {
247
242
  this.thread.exitStep(this.state.exitStep, this.state.result);
@@ -254,10 +249,6 @@ class GlobalCommand extends voice_1.default {
254
249
  asr: asr.getSettings(call.asr)
255
250
  };
256
251
  }
257
- exitFlow() {
258
- this.event.processed = false;
259
- return super.exitFlow();
260
- }
261
252
  sleepUntilHangup() {
262
253
  this.triggers.local(LocalEvents.hangup, () => {
263
254
  this.end();
@@ -110,30 +110,38 @@ class InitiateCall extends voice_1.default {
110
110
  break;
111
111
  }
112
112
  case 'error': {
113
- const error = lodash_1.default.get(event, 'params.error.originateStatus');
113
+ const error = event.params.error;
114
+ const errorStatus = error?.originateStatus ?? 'UNKNOWN';
114
115
  const errorCall = {
115
116
  botNumber,
116
117
  endUserNumber
117
118
  };
118
- switch (error) {
119
+ switch (errorStatus) {
119
120
  case 'USER_BUSY':
120
- await this.transcript(errorCall, { action: 'Call Busy' });
121
+ await this.transcript(errorCall, {
122
+ action: 'Call Busy',
123
+ actionFromBot: true
124
+ });
121
125
  await this.updateData();
122
126
  return this.exitStep('busy', errorCall);
123
127
  case 'NO_ANSWER':
124
- await this.transcript(errorCall, { action: 'Call No Answer' });
125
- await this.updateData();
126
- return this.exitStep('no answer', errorCall);
127
128
  case 'NO_USER_RESPONSE':
128
- await this.transcript(errorCall, { action: 'Call No Answer' });
129
+ await this.transcript(errorCall, {
130
+ action: 'Call No Answer',
131
+ actionFromBot: true
132
+ });
129
133
  await this.updateData();
130
134
  return this.exitStep('no answer', errorCall);
135
+ default:
136
+ break;
131
137
  }
132
- await this.transcript(errorCall, { action: 'Call Error' });
133
- const errorParams = event.params.error;
138
+ await this.transcript(errorCall, {
139
+ action: 'Call Error',
140
+ actionFromBot: true
141
+ });
134
142
  return this.throwError({
135
- name: event.params.error?.name ?? 'VoiceError',
136
- message: `${errorParams.date}: ${errorParams.originateStatus}`
143
+ name: error?.name ?? 'VoiceError',
144
+ message: `${String(error?.date)}: ${errorStatus}`
137
145
  });
138
146
  }
139
147
  default:
package/dst/step.js CHANGED
@@ -157,10 +157,7 @@ class ConvStep extends step_1.default {
157
157
  async startConversation(data, { thread: _thread } = {}) {
158
158
  this.convDataCache = {
159
159
  ...data,
160
- _conv: data._conv ?? {
161
- glb: [],
162
- lcl: []
163
- }
160
+ _conv: data._conv ?? {}
164
161
  };
165
162
  await this.updateData();
166
163
  // this.state.thread = this.dataThreadId
package/dst/voice.d.ts CHANGED
@@ -28,9 +28,14 @@ export interface IVoiceCall extends IConversationData {
28
28
  export type EventType = 'hangup' | 'error' | 'cancel' | 'background' | 'avm-detected' | 'recognition' | 'digit' | 'digits' | 'conference-start' | 'conference-end' | 'playback' | 'timeout' | 'record' | 'bridge' | 'bridge/ended' | 'is_flow_ready' | 'call' | 'dtmf-sent';
29
29
  export declare class VoiceStepError extends BasicError {
30
30
  }
31
- export type VoicerError = Error | string & {
31
+ export type VoicerError = Error & {
32
+ originateStatus?: string;
33
+ date?: string;
34
+ } | string & {
32
35
  message?: never;
33
36
  name?: never;
37
+ date?: never;
38
+ originateStatus?: never;
34
39
  };
35
40
  export interface VoiceEvent {
36
41
  type: EventType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "6.0.7",
3
+ "version": "6.0.9",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",