@onereach/step-voice 6.0.14 → 6.0.15-gcack.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.
@@ -32,7 +32,7 @@ export default class GlobalCommand extends VoiceStep<Partial<INPUT>, OUTPUT, EVE
32
32
  get isGlobal(): boolean;
33
33
  get useQueue(): boolean;
34
34
  runStep(): Promise<void>;
35
- initGrammar(): Promise<void>;
35
+ initGrammar(call: IVoiceCall): Promise<void>;
36
36
  worker(): Promise<void>;
37
37
  hangup(call: IVoiceCall): Promise<unknown>;
38
38
  exitThread(event: ITypedEvent<EVENT>, type: string, stepExit: string): Promise<void>;
@@ -18,9 +18,11 @@ class GlobalCommand extends voice_1.default {
18
18
  thread.state = {
19
19
  name: this.worker.name,
20
20
  step: this.step.id,
21
- thread: this.dataThreadId
21
+ thread: this.dataThreadId,
22
+ main: this.thread.id
22
23
  };
23
24
  });
25
+ const call = await this.fetchData();
24
26
  if (worker.isNewThread) {
25
27
  worker.activate();
26
28
  await worker.run();
@@ -28,12 +30,18 @@ class GlobalCommand extends voice_1.default {
28
30
  }
29
31
  else {
30
32
  worker.state.step = this.step.id;
31
- await this.initGrammar();
33
+ await this.initGrammar(call);
34
+ }
35
+ if (call.vv >= 2) {
36
+ this.triggers.local('ack', () => {
37
+ this.exitStep('no commands');
38
+ });
39
+ }
40
+ else {
41
+ this.exitStep('no commands');
32
42
  }
33
- this.exitStep('no commands');
34
43
  }
35
- async initGrammar() {
36
- const call = await this.fetchData();
44
+ async initGrammar(call) {
37
45
  const choices = this.buildChoices({ choices: this.data.choices });
38
46
  const grammar = await this.buildGrammar(call, choices);
39
47
  // set grammar into voice conversation
@@ -57,6 +65,7 @@ class GlobalCommand extends voice_1.default {
57
65
  {
58
66
  name: 'grammar',
59
67
  params: {
68
+ ack: call.vv >= 2,
60
69
  grammar
61
70
  }
62
71
  }
@@ -65,7 +74,7 @@ class GlobalCommand extends voice_1.default {
65
74
  async worker() {
66
75
  const call = await this.fetchData();
67
76
  this.triggers.otherwise(async () => {
68
- await this.initGrammar();
77
+ await this.initGrammar(call);
69
78
  });
70
79
  this.triggers.hook({ name: "waitEnd" /* ACTION.waitEnd */, thread: types_1.MAIN_THREAD_ID, sync: true }, async () => {
71
80
  // todo: hook once
@@ -80,6 +89,12 @@ class GlobalCommand extends voice_1.default {
80
89
  });
81
90
  this.triggers.local(`in/voice/${call.id}`, async (event) => {
82
91
  switch (event.params.type) {
92
+ case 'ack':
93
+ this.process.enqueue({
94
+ thread: this.state.main,
95
+ name: 'ack'
96
+ });
97
+ return;
83
98
  case 'hangup':
84
99
  return await this.hangup(call);
85
100
  case 'avm-detected':
@@ -148,12 +163,11 @@ class GlobalCommand extends voice_1.default {
148
163
  });
149
164
  }
150
165
  async hangup(call) {
151
- if (this.event.params.zombie) {
166
+ if (this.event.params.zombie && !this.data.handleZombie) {
152
167
  if (this.state.passive) {
153
168
  this.log.debug('ignore zombie hangup waiting for full hangup');
154
169
  return this.exitFlow();
155
170
  }
156
- this.log.debug('this gc was ignored because call is aleady hang up');
157
171
  return this.end();
158
172
  }
159
173
  await this.handleHangup(call);
@@ -184,7 +198,8 @@ class GlobalCommand extends voice_1.default {
184
198
  }
185
199
  return this.exitStep('hang up', {
186
200
  type: hangUpType,
187
- callRecording: this.event.params?.callRecording,
201
+ zombie: this.event.params.zombie,
202
+ callRecording: this.event.params.callRecording,
188
203
  conversation: this.conversation,
189
204
  conversationThreadId: this.dataThreadId
190
205
  });
package/dst/voice.d.ts CHANGED
@@ -25,7 +25,7 @@ export interface IVoiceCall extends IConversationData {
25
25
  from?: string;
26
26
  headers?: Record<string, string>;
27
27
  }
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';
28
+ export type EventType = 'hangup' | 'ack' | '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
31
  export type VoicerError = Error & {
@@ -48,6 +48,7 @@ export interface CallStartEvent extends VoiceEvent {
48
48
  }
49
49
  export default class VoiceStep<TIn = unknown, TOut = unknown, TParams extends VoiceEvent = VoiceEvent> extends ConvStep<IVoiceCall, TIn & {
50
50
  handleCancel?: boolean;
51
+ handleZombie?: boolean;
51
52
  }, TOut, TParams> {
52
53
  runBefore(): Promise<void>;
53
54
  exitStep(step: string, data?: any): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "6.0.14",
3
+ "version": "6.0.15-gcack.0",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",