@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.
@@ -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, enableWhisperTransfer, whisperAnnounceAudio, whisperCustomerConversation, } = this.data;
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
@@ -19,6 +19,9 @@ interface INPUT {
19
19
  value: string;
20
20
  }>;
21
21
  refer: boolean;
22
+ withReplaces: boolean;
23
+ replacesConversation?: string;
24
+ replacesConversationThread?: string;
22
25
  from?: string;
23
26
  gatewaySettingsMode?: GATEWAY_SETTINGS_MODE;
24
27
  sipHost?: string;
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: destination,
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.17-whispermigrate.0",
3
+ "version": "7.0.17",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",