@onereach/step-voice 7.0.9 → 7.0.11-VOIC1604.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.
- package/dst/Initiate Call.d.ts +18 -0
- package/dst/Initiate Call.js +56 -12
- package/dst/Say Message.js +2 -1
- package/dst/Transfer.d.ts +13 -1
- package/dst/Transfer.js +22 -10
- package/dst/step.d.ts +1 -0
- package/dst/step.js +4 -0
- package/package.json +1 -1
package/dst/Initiate Call.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import VoiceStep, { CallStartEvent, TODO } from './voice';
|
|
2
|
+
declare const enum GATEWAY_SETTINGS_MODE {
|
|
3
|
+
DEFAULT = "default",
|
|
4
|
+
CUSTOM = "custom",
|
|
5
|
+
INHERIT = "inherit",
|
|
6
|
+
PROFILE = "profile"
|
|
7
|
+
}
|
|
8
|
+
declare const enum SIP_PROFILE {
|
|
9
|
+
DEFAULT = "default",
|
|
10
|
+
INTERNAL = "internal",
|
|
11
|
+
EXTERNAL = "external"
|
|
12
|
+
}
|
|
2
13
|
interface INPUT {
|
|
3
14
|
callId?: string;
|
|
4
15
|
sessionTimeout?: number | string;
|
|
@@ -8,9 +19,11 @@ interface INPUT {
|
|
|
8
19
|
tts: TODO;
|
|
9
20
|
from: string;
|
|
10
21
|
endUserNumber: string;
|
|
22
|
+
gatewaySettingsMode?: GATEWAY_SETTINGS_MODE;
|
|
11
23
|
sipHost?: string;
|
|
12
24
|
sipUser?: string;
|
|
13
25
|
sipPassword?: string;
|
|
26
|
+
sipProfile?: SIP_PROFILE;
|
|
14
27
|
timeout?: number | string;
|
|
15
28
|
headers?: Array<{
|
|
16
29
|
name: string;
|
|
@@ -19,6 +32,11 @@ interface INPUT {
|
|
|
19
32
|
enableSpoofCallerId?: boolean;
|
|
20
33
|
spoofCallerId?: string;
|
|
21
34
|
isAMD?: boolean;
|
|
35
|
+
enableWhisperTransfer?: boolean;
|
|
36
|
+
whisperAnnounceAudio?: TODO[];
|
|
37
|
+
textType?: string;
|
|
38
|
+
whisperCustomerConversation?: string;
|
|
39
|
+
whisperCustomerConversationThread?: string;
|
|
22
40
|
}
|
|
23
41
|
export default class InitiateCall extends VoiceStep<INPUT, TODO, CallStartEvent> {
|
|
24
42
|
get conversation(): string | import("@onereach/flow-sdk/types").IMergeField;
|
package/dst/Initiate Call.js
CHANGED
|
@@ -47,7 +47,7 @@ class InitiateCall extends voice_1.default {
|
|
|
47
47
|
this.exitStep('cancel');
|
|
48
48
|
}
|
|
49
49
|
async waitForCall() {
|
|
50
|
-
const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread, handleCancel } = this.data;
|
|
50
|
+
const { asr, tts, from: botNumber, endUserNumber, gatewaySettingsMode, sipHost, sipUser, sipPassword, sipProfile, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread, handleCancel, enableWhisperTransfer, whisperAnnounceAudio, textType, whisperCustomerConversation, } = this.data;
|
|
51
51
|
const call = await this.fetchData();
|
|
52
52
|
this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
|
|
53
53
|
switch (event.params.type) {
|
|
@@ -84,7 +84,7 @@ class InitiateCall extends voice_1.default {
|
|
|
84
84
|
reportingSettingsKey: 'transcript',
|
|
85
85
|
actionFromBot: true
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
const commands = [
|
|
88
88
|
...isAMD
|
|
89
89
|
? [{
|
|
90
90
|
name: 'start-avmd',
|
|
@@ -100,8 +100,39 @@ class InitiateCall extends voice_1.default {
|
|
|
100
100
|
type: asr.serverSettings.engine
|
|
101
101
|
}
|
|
102
102
|
}]
|
|
103
|
-
: []
|
|
104
|
-
]
|
|
103
|
+
: [],
|
|
104
|
+
];
|
|
105
|
+
if (enableWhisperTransfer === true) {
|
|
106
|
+
const ttsSettings = tts.getSettings(call.tts);
|
|
107
|
+
const announceSpeechSections = whisperAnnounceAudio?.map(section => ({
|
|
108
|
+
text: section.voiceTextMsg,
|
|
109
|
+
url: section.audioUrl,
|
|
110
|
+
bargeInVoice: false,
|
|
111
|
+
bargeInKeypad: false,
|
|
112
|
+
textType,
|
|
113
|
+
provider: ttsSettings.provider,
|
|
114
|
+
...ttsSettings
|
|
115
|
+
}));
|
|
116
|
+
const announceMessageCommand = {
|
|
117
|
+
name: 'speak',
|
|
118
|
+
params: {
|
|
119
|
+
sections: announceSpeechSections,
|
|
120
|
+
reporterTranscriptEventId: '',
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const customerCall = await this.getConversationByName(whisperCustomerConversation ?? '');
|
|
124
|
+
const transferCommand = {
|
|
125
|
+
name: 'defer_replaces',
|
|
126
|
+
params: {
|
|
127
|
+
callerId: customerCall['id']
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
commands.push(...[
|
|
131
|
+
announceMessageCommand,
|
|
132
|
+
transferCommand,
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
135
|
+
await this.sendCommands(newCall, commands);
|
|
105
136
|
return this.exitStep('success');
|
|
106
137
|
}
|
|
107
138
|
case 'hangup': {
|
|
@@ -160,6 +191,25 @@ class InitiateCall extends voice_1.default {
|
|
|
160
191
|
memo[header.name] = `${header.value}`;
|
|
161
192
|
return memo;
|
|
162
193
|
}, {});
|
|
194
|
+
// GET SIP PROFILE SETTINGS
|
|
195
|
+
let gateway;
|
|
196
|
+
const profile = sipProfile !== "default" /* SIP_PROFILE.DEFAULT */ ? sipProfile : undefined;
|
|
197
|
+
switch (gatewaySettingsMode) {
|
|
198
|
+
case "custom" /* GATEWAY_SETTINGS_MODE.CUSTOM */:
|
|
199
|
+
gateway = {
|
|
200
|
+
host: sipHost,
|
|
201
|
+
user: sipUser,
|
|
202
|
+
username: sipUser,
|
|
203
|
+
password: sipPassword,
|
|
204
|
+
profile
|
|
205
|
+
};
|
|
206
|
+
break;
|
|
207
|
+
case "profile" /* GATEWAY_SETTINGS_MODE.PROFILE */:
|
|
208
|
+
gateway = {
|
|
209
|
+
profile
|
|
210
|
+
};
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
163
213
|
const params = {
|
|
164
214
|
id: call.id,
|
|
165
215
|
from: botNumber,
|
|
@@ -169,16 +219,10 @@ class InitiateCall extends voice_1.default {
|
|
|
169
219
|
enableSpoofCallerId,
|
|
170
220
|
spoofCallerId
|
|
171
221
|
},
|
|
172
|
-
gateway: sipHost
|
|
173
|
-
? {
|
|
174
|
-
host: sipHost,
|
|
175
|
-
username: sipUser,
|
|
176
|
-
password: sipPassword
|
|
177
|
-
}
|
|
178
|
-
: undefined,
|
|
179
222
|
timeout: originateTimeout,
|
|
180
223
|
version: 2,
|
|
181
|
-
sessionExpireTime: this.session.expireTime
|
|
224
|
+
sessionExpireTime: this.session.expireTime,
|
|
225
|
+
gateway,
|
|
182
226
|
};
|
|
183
227
|
if (otherCallRef) {
|
|
184
228
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
package/dst/Say Message.js
CHANGED
package/dst/Transfer.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import VoiceStep, { VoiceEvent } from './voice';
|
|
2
|
+
declare const enum GATEWAY_SETTINGS_MODE {
|
|
3
|
+
DEFAULT = "default",
|
|
4
|
+
CUSTOM = "custom",
|
|
5
|
+
INHERIT = "inherit",
|
|
6
|
+
PROFILE = "profile"
|
|
7
|
+
}
|
|
8
|
+
declare const enum SIP_PROFILE {
|
|
9
|
+
DEFAULT = "default",
|
|
10
|
+
INTERNAL = "internal",
|
|
11
|
+
EXTERNAL = "external"
|
|
12
|
+
}
|
|
2
13
|
interface INPUT {
|
|
3
14
|
destination: string;
|
|
4
15
|
phoneNumber: string;
|
|
@@ -8,11 +19,12 @@ interface INPUT {
|
|
|
8
19
|
value: string;
|
|
9
20
|
}>;
|
|
10
21
|
refer: boolean;
|
|
11
|
-
gatewaySettigsMode?: string;
|
|
12
22
|
from?: string;
|
|
23
|
+
gatewaySettingsMode?: GATEWAY_SETTINGS_MODE;
|
|
13
24
|
sipHost?: string;
|
|
14
25
|
sipUser?: string;
|
|
15
26
|
sipPassword?: string;
|
|
27
|
+
sipProfile?: SIP_PROFILE;
|
|
16
28
|
muteRecording?: boolean;
|
|
17
29
|
}
|
|
18
30
|
interface EVENT extends VoiceEvent {
|
package/dst/Transfer.js
CHANGED
|
@@ -52,13 +52,32 @@ class Transfer extends voice_1.default {
|
|
|
52
52
|
return this.exitFlow();
|
|
53
53
|
});
|
|
54
54
|
this.triggers.otherwise(async () => {
|
|
55
|
-
const { phoneNumber, sessionTimeout, destination, sipHeaders = [], sipHost, sipUser, sipPassword, refer,
|
|
55
|
+
const { phoneNumber, sessionTimeout, destination, sipHeaders = [], sipHost, sipUser, sipPassword, sipProfile, refer, gatewaySettingsMode, from, muteRecording } = this.data;
|
|
56
56
|
const destinationIsSip = (/^sip:/i).test(destination);
|
|
57
57
|
const destinationIsUser = (/^user:/i).test(destination);
|
|
58
58
|
const callerID = phoneNumber;
|
|
59
59
|
const timeout = Number(sessionTimeout);
|
|
60
|
-
const inheritGatewaySetting =
|
|
60
|
+
const inheritGatewaySetting = gatewaySettingsMode === 'inherit';
|
|
61
61
|
const headers = Object.fromEntries(sipHeaders.map(({ name, value }) => [name, value]));
|
|
62
|
+
// GET SIP PROFILE SETTINGS
|
|
63
|
+
let gateway;
|
|
64
|
+
const profile = sipProfile !== "default" /* SIP_PROFILE.DEFAULT */ ? sipProfile : undefined;
|
|
65
|
+
switch (gatewaySettingsMode) {
|
|
66
|
+
case "custom" /* GATEWAY_SETTINGS_MODE.CUSTOM */:
|
|
67
|
+
gateway = {
|
|
68
|
+
host: sipHost,
|
|
69
|
+
user: sipUser,
|
|
70
|
+
username: sipUser,
|
|
71
|
+
password: sipPassword,
|
|
72
|
+
profile
|
|
73
|
+
};
|
|
74
|
+
break;
|
|
75
|
+
case "profile" /* GATEWAY_SETTINGS_MODE.PROFILE */:
|
|
76
|
+
gateway = {
|
|
77
|
+
profile
|
|
78
|
+
};
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
62
81
|
const command = {
|
|
63
82
|
name: destinationIsSip ? (refer ? 'refer' : 'bridge_sip') : (destinationIsUser ? 'bridge_user' : 'bridge'),
|
|
64
83
|
params: {
|
|
@@ -66,14 +85,7 @@ class Transfer extends voice_1.default {
|
|
|
66
85
|
transferFrom: callerID,
|
|
67
86
|
transferTo: destination,
|
|
68
87
|
headers,
|
|
69
|
-
gateway
|
|
70
|
-
? {
|
|
71
|
-
host: sipHost,
|
|
72
|
-
user: sipUser,
|
|
73
|
-
username: sipUser,
|
|
74
|
-
password: sipPassword
|
|
75
|
-
}
|
|
76
|
-
: undefined,
|
|
88
|
+
gateway,
|
|
77
89
|
timeout
|
|
78
90
|
}
|
|
79
91
|
};
|
package/dst/step.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export default class ConvStep<TData extends IConversationData, TIn = unknown, TO
|
|
|
25
25
|
get useQueue(): boolean;
|
|
26
26
|
fetchData(): Promise<TData>;
|
|
27
27
|
getConversation(): Promise<IConversation>;
|
|
28
|
+
getConversationByName(conversation: string): Promise<IConversation>;
|
|
28
29
|
updateData(): Promise<void>;
|
|
29
30
|
hasConversation(): Promise<boolean>;
|
|
30
31
|
runBefore(): Promise<void>;
|
package/dst/step.js
CHANGED
|
@@ -51,6 +51,10 @@ class ConvStep extends step_1.default {
|
|
|
51
51
|
async getConversation() {
|
|
52
52
|
return (await this.fetchData())._conv;
|
|
53
53
|
}
|
|
54
|
+
async getConversationByName(conversation) {
|
|
55
|
+
const convDataThread = this.process.getSafeThread(this.dataThreadId);
|
|
56
|
+
return await convDataThread.get(conversation);
|
|
57
|
+
}
|
|
54
58
|
async updateData() {
|
|
55
59
|
if (this.convDataCache == null)
|
|
56
60
|
throw new Error(`missing conversation cache in state ${this.state.name}`);
|