@onereach/step-voice 7.0.2-VOIC1438.11 → 7.0.2-VOIC1438.12

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/MeetOps.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import VoiceStep, { CallStartEvent, IVoiceCall } from './voice';
1
+ import VoiceStep, { CallStartEvent, IVoiceCall, TODO } from './voice';
2
2
  interface MeetOpsInput {
3
3
  callId?: string;
4
4
  sessionTimeout?: number | string;
@@ -17,13 +17,21 @@ interface MeetOpsInput {
17
17
  enableSpoofCallerId?: boolean;
18
18
  spoofCallerId?: string;
19
19
  isAMD?: boolean;
20
+ asr: TODO;
21
+ meetOps: {
22
+ dtmfPin: string;
23
+ durationMs: number;
24
+ idleTimeoutMs: number;
25
+ };
20
26
  }
21
27
  interface MeetOpsOutput {
22
28
  }
23
29
  export default class MeetOps extends VoiceStep<MeetOpsInput, MeetOpsOutput, CallStartEvent> {
24
30
  get conversation(): string | import("@onereach/flow-sdk/dst/types").IMergeField;
25
31
  runStep(): Promise<void>;
32
+ onAwake(): Promise<void>;
26
33
  waitForJoin(): Promise<void>;
34
+ private onCall;
27
35
  originate(call: IVoiceCall): Promise<void>;
28
36
  }
29
37
  export {};
package/dst/MeetOps.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const uuid = tslib_1.__importStar(require("uuid"));
5
+ const timestring_1 = tslib_1.__importDefault(require("timestring"));
5
6
  const voice_1 = tslib_1.__importDefault(require("./voice"));
6
7
  class MeetOps extends voice_1.default {
7
8
  get conversation() {
@@ -14,27 +15,107 @@ class MeetOps extends voice_1.default {
14
15
  if (!this.session.key) {
15
16
  await this.session.start({
16
17
  key: callId,
17
- timeout: 10000,
18
+ timeout: (0, timestring_1.default)('120 min'),
18
19
  reporting: {
19
20
  settingsKey: 'session',
20
21
  startedBy: 'Bot',
21
- sessionType: 'Phone'
22
- }
22
+ sessionType: 'Phone',
23
+ },
23
24
  });
24
25
  }
25
26
  const convData = { id: callId, type: 'voicer', vv: 0 };
26
27
  await this.startConversation(convData);
27
28
  this.gotoState('waitForJoin');
28
29
  }
30
+ async onAwake() {
31
+ const { handleCancel } = this.data;
32
+ await super.onAwake();
33
+ const call = await this.fetchData();
34
+ if (!call.ended)
35
+ throw new Error('unpexpected awake');
36
+ if (handleCancel !== true)
37
+ throw new Error('hangup cancel');
38
+ this.exitStep('cancel');
39
+ }
29
40
  async waitForJoin() {
30
41
  const call = await this.fetchData();
31
- // this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
32
- // })
42
+ this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
43
+ switch (event.params.type) {
44
+ case 'is_flow_ready': {
45
+ return this.exitFlow({ is_ready: true });
46
+ }
47
+ case 'call': {
48
+ await this.onCall(event, call);
49
+ return this.exitStep('success');
50
+ }
51
+ }
52
+ });
33
53
  this.triggers.otherwise(async () => {
34
54
  await this.triggers.flush();
35
55
  await this.originate(call);
36
56
  });
37
57
  }
58
+ async onCall(event, call) {
59
+ const { endUserNumber,
60
+ // isAMD
61
+ asr } = this.data;
62
+ const newCall = {
63
+ headers: event.params.headers,
64
+ ...event.params.channel,
65
+ asr: asr.getSettings(),
66
+ // tts: tts.getVoice(),
67
+ botNumber: event.params.channel.to ?? 'unknown',
68
+ endUserNumber
69
+ };
70
+ delete newCall.from;
71
+ delete newCall.to;
72
+ newCall._conv = call._conv;
73
+ await this.startConversation(newCall);
74
+ await this.transcript(newCall, {
75
+ action: 'Call Start',
76
+ reportingSettingsKey: 'transcript',
77
+ actionFromBot: true
78
+ });
79
+ const commands = [
80
+ /* {
81
+ name: 'send-dtmf',
82
+ params: {
83
+ dtmf: '#',
84
+ afterDelay: 250,
85
+ beforeDelay: 250,
86
+ tonesDuration: 100,
87
+ }
88
+ },
89
+ {
90
+ name: 'record-session'
91
+ },
92
+ {
93
+ name: 'start-avmd',
94
+ params: {
95
+ type: 'avmd_detect'
96
+ }
97
+ } */
98
+ {
99
+ name: 'meet-ops',
100
+ params: {
101
+ meetOps: {
102
+ dtmfPin: '993 398 004 2794#'.replace(/ /g, ''),
103
+ durationMs: 10 * 60 * 1000,
104
+ idleTimeoutMs: 60 * 1000,
105
+ },
106
+ }
107
+ }
108
+ ];
109
+ /* if (asr.serverSettings.enabled) {
110
+ commands.push({
111
+ name: 'start-recognition',
112
+ params: {
113
+ type: asr.serverSettings.engine
114
+ }
115
+ })
116
+ } */
117
+ await this.sendCommands(newCall, commands);
118
+ }
38
119
  async originate(call) {
39
120
  const { id: callId } = call;
40
121
  const {
@@ -42,7 +123,7 @@ class MeetOps extends voice_1.default {
42
123
  // tts,
43
124
  from: botNumber, endUserNumber: dianInNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId,
44
125
  // isAMD,
45
- otherCallRef, otherCallRefThread,
126
+ otherCallRef, otherCallRefThread, meetOps,
46
127
  // handleCancel
47
128
  } = this.data;
48
129
  const customHeadersEntities = headers?.map(({ name, value }) => [name, `${value}`]) || [];
@@ -51,12 +132,12 @@ class MeetOps extends voice_1.default {
51
132
  ? {
52
133
  host: sipHost,
53
134
  username: sipUser,
54
- password: sipPassword
135
+ password: sipPassword,
55
136
  }
56
137
  : undefined;
57
138
  const spoofCallerIdConfig = {
58
139
  enableSpoofCallerId,
59
- spoofCallerId
140
+ spoofCallerId,
60
141
  };
61
142
  const params = {
62
143
  id: callId,
@@ -68,8 +149,14 @@ class MeetOps extends voice_1.default {
68
149
  version: 2,
69
150
  gateway,
70
151
  timeout,
152
+ meetOps,
71
153
  };
72
154
  console.log(otherCallRef, otherCallRefThread, params);
155
+ await this.thread.emitAsync({
156
+ target: 'provider',
157
+ name: 'out/voice/originate/v2',
158
+ params,
159
+ });
73
160
  // const otherThread = this.process.getSafeThread(otherCallRefThread || this.thread.id)
74
161
  // const otherCall: IVoiceCall | undefined = await otherThread.get(otherCallRef)
75
162
  // if (otherCall == null) throw new Error(`otherCall not found: ${otherCallRef}`)
@@ -38,7 +38,7 @@ class SendDTMF extends voice_1.default {
38
38
  if (validationError != null)
39
39
  throw new Error(validationError.message);
40
40
  const command = {
41
- name: 'meet-ops',
41
+ name: '-ops',
42
42
  params: {
43
43
  dtmf,
44
44
  meetOps: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.2-VOIC1438.11",
3
+ "version": "7.0.2-VOIC1438.12",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",