@onereach/step-voice 7.0.17-whispermigrate.0 → 7.0.17
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 +1 -31
- package/dst/Transfer.d.ts +3 -0
- package/dst/Transfer.js +11 -2
- package/package.json +1 -1
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, gatewaySettingsMode, sipHost, sipUser, sipPassword, sipProfile, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread, handleCancel,
|
|
50
|
+
const { asr, tts, from: botNumber, endUserNumber, gatewaySettingsMode, sipHost, sipUser, sipPassword, sipProfile, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread, handleCancel, } = 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) {
|
|
@@ -102,36 +102,6 @@ class InitiateCall extends voice_1.default {
|
|
|
102
102
|
}]
|
|
103
103
|
: [],
|
|
104
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: 'ssml',
|
|
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
105
|
await this.sendCommands(newCall, commands);
|
|
136
106
|
return this.exitStep('success');
|
|
137
107
|
}
|
package/dst/Transfer.d.ts
CHANGED
package/dst/Transfer.js
CHANGED
|
@@ -52,13 +52,21 @@ 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, sipProfile, refer, gatewaySettingsMode, from, muteRecording } = this.data;
|
|
55
|
+
const { phoneNumber, sessionTimeout, destination, sipHeaders = [], sipHost, sipUser, sipPassword, sipProfile, refer, withReplaces, replacesConversation, replacesConversationThread, 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
60
|
const inheritGatewaySetting = gatewaySettingsMode === 'inherit';
|
|
61
61
|
const headers = Object.fromEntries(sipHeaders.map(({ name, value }) => [name, value]));
|
|
62
|
+
// When replaces is enabled, fetch the customer call and use its ID as transferTo
|
|
63
|
+
let finalTransferTo = destination;
|
|
64
|
+
if (refer && withReplaces && replacesConversation) {
|
|
65
|
+
const customerCall = replacesConversationThread
|
|
66
|
+
? await this.process.getSafeThread(replacesConversationThread).get(replacesConversation)
|
|
67
|
+
: await this.getConversationByName(replacesConversation);
|
|
68
|
+
finalTransferTo = customerCall['id'];
|
|
69
|
+
}
|
|
62
70
|
// GET SIP PROFILE SETTINGS
|
|
63
71
|
let gateway;
|
|
64
72
|
const profile = sipProfile !== "default" /* SIP_PROFILE.DEFAULT */ ? sipProfile : undefined;
|
|
@@ -81,11 +89,12 @@ class Transfer extends voice_1.default {
|
|
|
81
89
|
params: {
|
|
82
90
|
botNumber: inheritGatewaySetting ? from : call.botNumber,
|
|
83
91
|
transferFrom: callerID,
|
|
84
|
-
transferTo:
|
|
92
|
+
transferTo: finalTransferTo,
|
|
85
93
|
headers,
|
|
86
94
|
gateway,
|
|
87
95
|
timeout,
|
|
88
96
|
maxLoops: this.session.data?.loopPrevention?.enabled ? this.session.data.loopPrevention.maxLoops : undefined,
|
|
97
|
+
withReplaces
|
|
89
98
|
}
|
|
90
99
|
};
|
|
91
100
|
const muteAfterTransfer = !!muteRecording;
|