@onereach/step-voice 4.0.16 → 4.0.19

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.
package/dst/Choice.js CHANGED
@@ -106,12 +106,12 @@ class Choice extends voice_1.default {
106
106
  case 'digits': {
107
107
  const params = event.params;
108
108
  const digit = params.digit ?? params.digits;
109
- const exitId = params.exitId ?? '';
109
+ const exitId = params.exitId;
110
110
  // On bargeIn, we should stop playback
111
111
  if (exitExists(exitId)) {
112
112
  await this.transcript(channel, {
113
113
  keyPress: digit,
114
- message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
114
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId) ?? '', /^(\d+\. )?(~ )?/, ''),
115
115
  reportingSettingsKey,
116
116
  action: 'Call DTMF',
117
117
  actionFromBot: false
@@ -149,7 +149,7 @@ class Choice extends voice_1.default {
149
149
  }
150
150
  case 'recognition': {
151
151
  const params = event.params;
152
- const exitId = params.exitId ?? '';
152
+ const exitId = params.exitId;
153
153
  const phrases = params.phrases;
154
154
  if (lodash_1.default.isEmpty(phrases)) {
155
155
  return this.exitStep('unrecognized', {});
@@ -161,7 +161,7 @@ class Choice extends voice_1.default {
161
161
  // On bargeIn, we should stop playback
162
162
  if (exitExists(exitId)) {
163
163
  await this.transcript(channel, {
164
- message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
164
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId) ?? '', /^(\d+\. )?(~ )?/, ''),
165
165
  voiceProcessResult,
166
166
  reportingSettingsKey,
167
167
  action: 'Call Recognition',
@@ -83,6 +83,7 @@ class GlobalCommand extends voice_1.default {
83
83
  switch (event.params.type) {
84
84
  case 'hangup': {
85
85
  await this.hangup(channel);
86
+ await this.sendEventToStep({ toGlobal: false, event: { ...this.event, processed: undefined, action: 'local' } });
86
87
  return this.end();
87
88
  }
88
89
  case 'avm-detected':
@@ -96,7 +97,7 @@ class GlobalCommand extends voice_1.default {
96
97
  await this.transcript(channel, {
97
98
  previousTranscriptId: channel.lastTranscriptId,
98
99
  keyPress: params.digit,
99
- message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
100
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId) ?? '', /^(\d+\. )?(~ )?/, ''),
100
101
  action: 'Call DTMF',
101
102
  reportingSettingsKey: 'transcript',
102
103
  actionFromBot: false
@@ -115,7 +116,7 @@ class GlobalCommand extends voice_1.default {
115
116
  .value();
116
117
  await this.transcript(channel, {
117
118
  previousTranscriptId: channel.lastTranscriptId,
118
- message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
119
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId) ?? '', /^(\d+\. )?(~ )?/, ''),
119
120
  action: 'Call Recognition',
120
121
  voiceProcessResult,
121
122
  reportingSettingsKey: 'transcript',
package/dst/Hangup.js CHANGED
@@ -20,6 +20,8 @@ class Hangup extends voice_1.default {
20
20
  }
21
21
  });
22
22
  this.triggers.otherwise(async () => {
23
+ if (channel.hangup)
24
+ return this.exitStep('next');
23
25
  try {
24
26
  await this.sendCommands(channel, [{ name: 'hangup' }]);
25
27
  }
@@ -1,7 +1,7 @@
1
1
  import VoiceStep, { CallStartEvent, TODO } from './voice';
2
2
  interface INPUT {
3
3
  channelId?: string;
4
- sessionTimeout?: number;
4
+ sessionTimeout?: number | string;
5
5
  asr: TODO;
6
6
  tts: TODO;
7
7
  from: string;
@@ -9,7 +9,7 @@ interface INPUT {
9
9
  sipHost?: string;
10
10
  sipUser?: string;
11
11
  sipPassword?: string;
12
- timeout?: number;
12
+ timeout?: number | string;
13
13
  headers?: Array<{
14
14
  name: string;
15
15
  value: string;
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
6
6
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const timestring_1 = tslib_1.__importDefault(require("timestring"));
8
- const uuid_1 = tslib_1.__importDefault(require("uuid"));
8
+ const uuid = tslib_1.__importStar(require("uuid"));
9
9
  const defaultSessionTimeoutMin = 5;
10
10
  class InitiateCall extends voice_1.default {
11
11
  get conversation() {
@@ -17,7 +17,7 @@ class InitiateCall extends voice_1.default {
17
17
  return undefined;
18
18
  }
19
19
  async runStep() {
20
- const { channelId = uuid_1.default.v4() } = this.data;
20
+ const { channelId = uuid.v4() } = this.data;
21
21
  if (!this.session.key) {
22
22
  const sessionTimeoutMs = (0, timestring_1.default)(`${this.data.sessionTimeout ?? defaultSessionTimeoutMin} min`, 'ms');
23
23
  await this.session.start({
package/dst/step.d.ts CHANGED
@@ -19,7 +19,7 @@ export default class ConvStep<TData = unknown, TIn = unknown, TOut = unknown, TP
19
19
  runBefore(): Promise<void>;
20
20
  runAfter(): Promise<void>;
21
21
  hasActiveGlobal(): Promise<boolean>;
22
- setTriggerType(): Promise<void>;
22
+ setLocalTriggers(): Promise<void>;
23
23
  waitForConversation(): Promise<void>;
24
24
  onSkipEvent(): Promise<void>;
25
25
  cancel(): Promise<void>;
package/dst/step.js CHANGED
@@ -70,9 +70,7 @@ class ConvStep extends step_1.default {
70
70
  if (this.isGlobal && this.event.action === 'global') {
71
71
  return; // it was redirected from (1)
72
72
  }
73
- if (!this.isGlobal && (this.convDataCache?._conv?.glb?.length ?? 0) > 0) {
74
- this.triggers.config({ params: { type: 'local' } });
75
- }
73
+ await this.setLocalTriggers();
76
74
  }
77
75
  async runAfter() {
78
76
  if (!await this.hasConversation())
@@ -91,9 +89,9 @@ class ConvStep extends step_1.default {
91
89
  const globalLength = (await this._getConversation())?.glb?.length ?? 0;
92
90
  return globalLength > 0;
93
91
  }
94
- async setTriggerType() {
95
- if (!this.isGlobal && !await this.hasActiveGlobal()) {
96
- this.triggers.config({ params: { type: 'local' } });
92
+ async setLocalTriggers() {
93
+ if (!this.isGlobal && await this.hasActiveGlobal()) {
94
+ this.triggers.config({ target: 'session' });
97
95
  }
98
96
  }
99
97
  async waitForConversation() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.16",
3
+ "version": "4.0.19",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -18,15 +18,15 @@
18
18
  "uuid": "^8.3.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@onereach/flow-sdk": "^3.1.3",
21
+ "@onereach/flow-sdk": "^3.1.12",
22
22
  "@swc/cli": "^0.1.57",
23
- "@swc/core": "^1.2.197",
23
+ "@swc/core": "^1.2.198",
24
24
  "@swc/jest": "^0.2.21",
25
25
  "@types/jest": "^28.1.1",
26
26
  "@types/lodash": "^4.14.182",
27
27
  "@types/timestring": "^6.0.2",
28
28
  "@types/uuid": "^8.3.4",
29
- "aws-sdk": "^2.1151.0",
29
+ "aws-sdk": "^2.1153.0",
30
30
  "babel-runtime": "^6.26.0",
31
31
  "docdash": "^1.2.0",
32
32
  "husky": "^8.0.1",