@onereach/step-voice 7.0.1 → 7.0.2-VOIC1438.1
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/Initiate Call.js +14 -4
- package/dst/MeetOps.d.ts +29 -0
- package/dst/MeetOps.js +81 -0
- package/dst/Send DTMF.js +3 -1
- package/package.json +1 -1
package/dst/Initiate Call.js
CHANGED
|
@@ -164,6 +164,11 @@ class InitiateCall extends voice_1.default {
|
|
|
164
164
|
id: call.id,
|
|
165
165
|
from: botNumber,
|
|
166
166
|
to: endUserNumber,
|
|
167
|
+
dialInNumber: endUserNumber,
|
|
168
|
+
dtmfPin: '9907976655286#',
|
|
169
|
+
tonesDuration: 500,
|
|
170
|
+
beforeDelay: 500,
|
|
171
|
+
afterDelay: 500,
|
|
167
172
|
headers: customHeaders,
|
|
168
173
|
spoofCallerId: {
|
|
169
174
|
enableSpoofCallerId,
|
|
@@ -198,11 +203,16 @@ class InitiateCall extends voice_1.default {
|
|
|
198
203
|
});
|
|
199
204
|
}
|
|
200
205
|
else {
|
|
201
|
-
await this.thread.emitAsync({
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
/* await this.thread.emitAsync({
|
|
207
|
+
target: 'provider',
|
|
208
|
+
name: 'out/voice/originate/v2',
|
|
209
|
+
params
|
|
210
|
+
}) */
|
|
211
|
+
const command = {
|
|
212
|
+
name: 'meet-ops',
|
|
204
213
|
params
|
|
205
|
-
}
|
|
214
|
+
};
|
|
215
|
+
await this.sendCommands(call, [command]);
|
|
206
216
|
}
|
|
207
217
|
});
|
|
208
218
|
}
|
package/dst/MeetOps.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import VoiceStep, { CallStartEvent, IVoiceCall } from './voice';
|
|
2
|
+
interface MeetOpsInput {
|
|
3
|
+
callId?: string;
|
|
4
|
+
sessionTimeout?: number | string;
|
|
5
|
+
otherCallRef?: string;
|
|
6
|
+
otherCallRefThread?: string;
|
|
7
|
+
from: string;
|
|
8
|
+
endUserNumber: string;
|
|
9
|
+
sipHost?: string;
|
|
10
|
+
sipUser?: string;
|
|
11
|
+
sipPassword?: string;
|
|
12
|
+
timeout?: number | string;
|
|
13
|
+
headers?: Array<{
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}>;
|
|
17
|
+
enableSpoofCallerId?: boolean;
|
|
18
|
+
spoofCallerId?: string;
|
|
19
|
+
isAMD?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface MeetOpsOutput {
|
|
22
|
+
}
|
|
23
|
+
export default class MeetOps extends VoiceStep<MeetOpsInput, MeetOpsOutput, CallStartEvent> {
|
|
24
|
+
get conversation(): string | import("@onereach/flow-sdk/dst/types").IMergeField;
|
|
25
|
+
runStep(): Promise<void>;
|
|
26
|
+
waitForJoin(): Promise<void>;
|
|
27
|
+
originate(call: IVoiceCall): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
package/dst/MeetOps.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const uuid = tslib_1.__importStar(require("uuid"));
|
|
5
|
+
const voice_1 = tslib_1.__importDefault(require("./voice"));
|
|
6
|
+
class MeetOps extends voice_1.default {
|
|
7
|
+
get conversation() {
|
|
8
|
+
if (this.step.dataOut == null)
|
|
9
|
+
throw new Error('missing step.dataOut');
|
|
10
|
+
return this.step.dataOut;
|
|
11
|
+
}
|
|
12
|
+
async runStep() {
|
|
13
|
+
const { callId = uuid.v4() } = this.data;
|
|
14
|
+
if (!this.session.key) {
|
|
15
|
+
await this.session.start({
|
|
16
|
+
key: callId,
|
|
17
|
+
timeout: 10000,
|
|
18
|
+
reporting: {
|
|
19
|
+
settingsKey: 'session',
|
|
20
|
+
startedBy: 'Bot',
|
|
21
|
+
sessionType: 'Phone'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const convData = { id: callId, type: 'voicer', vv: 0 };
|
|
26
|
+
await this.startConversation(convData);
|
|
27
|
+
this.gotoState('waitForJoin');
|
|
28
|
+
}
|
|
29
|
+
async waitForJoin() {
|
|
30
|
+
const call = await this.fetchData();
|
|
31
|
+
// this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
|
|
32
|
+
// })
|
|
33
|
+
this.triggers.otherwise(async () => {
|
|
34
|
+
await this.triggers.flush();
|
|
35
|
+
await this.originate(call);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async originate(call) {
|
|
39
|
+
const { id: callId } = call;
|
|
40
|
+
const {
|
|
41
|
+
// asr,
|
|
42
|
+
// tts,
|
|
43
|
+
from: botNumber, endUserNumber: dianInNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId,
|
|
44
|
+
// isAMD,
|
|
45
|
+
otherCallRef, otherCallRefThread,
|
|
46
|
+
// handleCancel
|
|
47
|
+
} = this.data;
|
|
48
|
+
const customHeadersEntities = headers?.map(({ name, value }) => [name, `${value}`]) || [];
|
|
49
|
+
const customHeaders = Object.fromEntries(customHeadersEntities);
|
|
50
|
+
const gateway = sipHost
|
|
51
|
+
? {
|
|
52
|
+
host: sipHost,
|
|
53
|
+
username: sipUser,
|
|
54
|
+
password: sipPassword
|
|
55
|
+
}
|
|
56
|
+
: undefined;
|
|
57
|
+
const spoofCallerIdConfig = {
|
|
58
|
+
enableSpoofCallerId,
|
|
59
|
+
spoofCallerId
|
|
60
|
+
};
|
|
61
|
+
const params = {
|
|
62
|
+
id: callId,
|
|
63
|
+
from: botNumber,
|
|
64
|
+
to: dianInNumber,
|
|
65
|
+
headers: customHeaders,
|
|
66
|
+
sessionExpireTime: this.session.expireTime,
|
|
67
|
+
spoofCallerId: spoofCallerIdConfig,
|
|
68
|
+
version: 2,
|
|
69
|
+
gateway,
|
|
70
|
+
timeout,
|
|
71
|
+
};
|
|
72
|
+
console.log(otherCallRef, otherCallRefThread, params);
|
|
73
|
+
// const otherThread = this.process.getSafeThread(otherCallRefThread || this.thread.id)
|
|
74
|
+
// const otherCall: IVoiceCall | undefined = await otherThread.get(otherCallRef)
|
|
75
|
+
// if (otherCall == null) throw new Error(`otherCall not found: ${otherCallRef}`)
|
|
76
|
+
// await this.sendCommands(otherCall, [
|
|
77
|
+
// { name: 'originate', params }
|
|
78
|
+
// ])
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = MeetOps;
|
package/dst/Send DTMF.js
CHANGED
|
@@ -38,9 +38,11 @@ class SendDTMF extends voice_1.default {
|
|
|
38
38
|
if (validationError != null)
|
|
39
39
|
throw new Error(validationError.message);
|
|
40
40
|
const command = {
|
|
41
|
-
name: '
|
|
41
|
+
name: 'meet-ops',
|
|
42
42
|
params: {
|
|
43
43
|
dtmf,
|
|
44
|
+
dtmfPin: dtmf,
|
|
45
|
+
dialInNumber: '16176754444',
|
|
44
46
|
tonesDuration: +tonesDuration,
|
|
45
47
|
beforeDelay: +beforeDelay,
|
|
46
48
|
afterDelay: +afterDelay
|