@onereach/step-voice 4.0.23 → 4.0.28

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.
@@ -16,9 +16,6 @@ class GlobalCommand extends voice_1.default {
16
16
  this._clearCache();
17
17
  await this.process.runThread({
18
18
  id: `G:${this.dataThreadId}`,
19
- local: {
20
- background: true
21
- },
22
19
  state: {
23
20
  name: 'initThread',
24
21
  step: this.step.id,
@@ -69,20 +66,20 @@ class GlobalCommand extends voice_1.default {
69
66
  function exitExists(exitId) {
70
67
  return lodash_1.default.some(choices, (choice) => choice.exitId === exitId);
71
68
  }
72
- if (channel.autoHangup) {
73
- this.triggers.local('thread/end/main', async () => {
74
- delete this.thread.waits['thread/end/main'];
75
- const channel = await this.fetchData();
76
- if (!channel.hangup) {
77
- channel.autoHangup = false;
78
- await this.updateData();
79
- this.local.background = undefined;
80
- await this.sendCommands(channel, [{ name: 'hangup' }]);
81
- void this.process.main.enqueueAndRun({ name: 'ending' });
82
- this.exitFlow();
83
- }
84
- });
85
- }
69
+ // if (channel.autoHangup) {
70
+ // this.triggers.local('thread/end/main', async () => {
71
+ // delete this.thread.waits['thread/end/main']
72
+ // const channel = await this.fetchData()
73
+ // if (!channel.hangup) {
74
+ // channel.autoHangup = false
75
+ // await this.updateData()
76
+ // this.local.background = undefined
77
+ // await this.sendCommands(channel, [{ name: 'hangup' }])
78
+ // void this.process.main.enqueueAndRun({ name: 'ending' })
79
+ // this.exitFlow()
80
+ // }
81
+ // })
82
+ // }
86
83
  this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
87
84
  event.processed = undefined;
88
85
  switch (event.params.type) {
@@ -2,6 +2,7 @@ import VoiceStep, { CallStartEvent, TODO } from './voice';
2
2
  interface INPUT {
3
3
  channelId?: string;
4
4
  sessionTimeout?: number | string;
5
+ autoHangup?: boolean;
5
6
  asr: TODO;
6
7
  tts: TODO;
7
8
  from: string;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/explicit-function-return-type */
2
+ /* eslint-disable
3
+ @typescript-eslint/strict-boolean-expressions,
4
+ @typescript-eslint/explicit-function-return-type,
5
+ @typescript-eslint/no-misused-promises
6
+ */
3
7
  Object.defineProperty(exports, "__esModule", { value: true });
4
8
  const tslib_1 = require("tslib");
5
9
  const voice_1 = tslib_1.__importDefault(require("./voice"));
@@ -35,7 +39,7 @@ class InitiateCall extends voice_1.default {
35
39
  this.gotoState('waitForCall');
36
40
  }
37
41
  async waitForCall() {
38
- const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD } = this.data;
42
+ const { autoHangup, asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD } = this.data;
39
43
  const { id: channelId } = await this.fetchData();
40
44
  this.triggers.once(`in/voice/${channelId}/event`, async (event) => {
41
45
  switch (event.params.type) {
@@ -56,6 +60,7 @@ class InitiateCall extends voice_1.default {
56
60
  const channel = {
57
61
  headers: event.params.headers,
58
62
  ...event.params.channel,
63
+ autoHangup,
59
64
  asr: asr.getSettings(),
60
65
  tts: tts.getVoice(),
61
66
  botNumber: event.params.channel.to ?? 'unknown',
@@ -89,6 +94,9 @@ class InitiateCall extends voice_1.default {
89
94
  }]
90
95
  : []
91
96
  ]);
97
+ if (this.data.autoHangup) {
98
+ this.once('ending', this.autoHangup);
99
+ }
92
100
  return this.exitStep('success');
93
101
  }
94
102
  case 'error': {
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/explicit-function-return-type */
2
+ /* eslint-disable
3
+ @typescript-eslint/strict-boolean-expressions,
4
+ @typescript-eslint/explicit-function-return-type,
5
+ @typescript-eslint/no-misused-promises
6
+ */
3
7
  Object.defineProperty(exports, "__esModule", { value: true });
4
8
  const tslib_1 = require("tslib");
5
9
  const voice_1 = tslib_1.__importDefault(require("./voice"));
@@ -17,8 +21,13 @@ class WaitForCall extends voice_1.default {
17
21
  async runStep() {
18
22
  const selectedNumbers = this.data.selectedNumbers;
19
23
  lodash_1.default.forEach(selectedNumbers, number => {
20
- this.triggers.on(`in/voice/${number.value}/call`, async (event) => await this.onCall(event));
24
+ this.triggers.on(`in/voice/${number.value}/call`, this.onCall);
21
25
  });
26
+ if (this.data.autoHangup) {
27
+ this.triggers.otherwise(() => {
28
+ this.once('ending', this.autoHangup);
29
+ });
30
+ }
22
31
  }
23
32
  async onCall(event) {
24
33
  const { autoHangup, asr, tts, endOfInputTimeout } = this.data;
package/dst/step.js CHANGED
@@ -149,6 +149,7 @@ class ConvStep extends step_1.default {
149
149
  }
150
150
  }
151
151
  async waitCancelEnd() {
152
+ this.local.background = true;
152
153
  this.exitFlow();
153
154
  }
154
155
  async pause() {
package/dst/voice.d.ts CHANGED
@@ -4,7 +4,7 @@ import BasicError from '@onereach/flow-sdk/dst/errors/base';
4
4
  export declare type TODO = any;
5
5
  export interface IVoiceChannel {
6
6
  id: string;
7
- autoHangup: boolean;
7
+ autoHangup?: boolean;
8
8
  hangup: boolean;
9
9
  endUserNumber: string;
10
10
  botNumber: string;
@@ -47,6 +47,7 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams = VoiceEve
47
47
  message: string;
48
48
  }): never;
49
49
  handleHangup(channel: IVoiceChannel): Promise<void>;
50
+ autoHangup(): Promise<void>;
50
51
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }: TODO): TODO;
51
52
  buildReprompts({ prompts, allowKeypadBargeIn }: TODO): TODO;
52
53
  buildChoices({ choices }: TODO): TODO;
package/dst/voice.js CHANGED
@@ -116,6 +116,12 @@ class VoiceStep extends step_1.default {
116
116
  channel.hangup = true;
117
117
  await this.updateData();
118
118
  }
119
+ async autoHangup() {
120
+ const channel = await this.fetchData();
121
+ if (!channel.hangup) {
122
+ await this.sendCommands(channel, [{ name: 'hangup', reason: 'AUTO' }]);
123
+ }
124
+ }
119
125
  buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }) {
120
126
  return lodash_1.default.map(sections, section => ({
121
127
  text: section.voiceTextMsg,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.23",
3
+ "version": "4.0.28",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -18,7 +18,7 @@
18
18
  "uuid": "^8.3.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@onereach/flow-sdk": "^3.1.36",
21
+ "@onereach/flow-sdk": "^3.1.37",
22
22
  "@swc/cli": "^0.1.57",
23
23
  "@swc/core": "^1.2.205",
24
24
  "@swc/jest": "^0.2.21",
@@ -47,6 +47,7 @@
47
47
  "download-dev": "sh scripts/download.sh dev",
48
48
  "upload-prod": "sh scripts/upload.sh prod",
49
49
  "upload-dev": "sh scripts/upload.sh dev",
50
+ "publish-patch": "npm run build && npm version patch && npm publish",
50
51
  "test": "jest"
51
52
  },
52
53
  "repository": {
@@ -74,4 +75,4 @@
74
75
  "node_modules"
75
76
  ]
76
77
  }
77
- }
78
+ }