botium-connector-voip 0.0.22 → 0.0.23
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.
|
@@ -33,6 +33,12 @@ const _info = (event, data) => {
|
|
|
33
33
|
}).filter(([, v]) => v != null && v !== '').map(([k, v]) => `${k}=${typeof v === 'string' && v.length > 80 ? `"${v.substring(0, 77)}..."` : JSON.stringify(v)}`);
|
|
34
34
|
console.info(`[botium-connector-voip] ${parts.join(' ')}`);
|
|
35
35
|
};
|
|
36
|
+
|
|
37
|
+
/** DTMF for RTP/PJSIP: 0–9, *, #, A–D. Strips spaces and other separators so the worker gets one compact string. */
|
|
38
|
+
const sanitizeDtmfDigits = raw => {
|
|
39
|
+
if (raw == null) return '';
|
|
40
|
+
return String(raw).replace(/[^0-9*#ABCDabcd]/g, '').toUpperCase();
|
|
41
|
+
};
|
|
36
42
|
const Capabilities = {
|
|
37
43
|
VOIP_STT_URL_STREAM: 'VOIP_STT_URL_STREAM',
|
|
38
44
|
VOIP_STT_PARAMS_STREAM: 'VOIP_STT_PARAMS_STREAM',
|
|
@@ -770,9 +776,15 @@ class BotiumConnectorVoip {
|
|
|
770
776
|
const skipTtsForMixedInput = preferVoice && hasText && hasVoiceMedia;
|
|
771
777
|
debug$3(`UserSays routing: hasText=${hasText} hasVoiceMedia=${hasVoiceMedia} preferVoice=${preferVoice} preferVoiceRaw=${JSON.stringify(preferVoiceCapRaw)} skipTtsForMixedInput=${skipTtsForMixedInput}`);
|
|
772
778
|
if (msg && msg.buttons && msg.buttons.length > 0) {
|
|
779
|
+
const digits = sanitizeDtmfDigits(msg.buttons[0].payload);
|
|
780
|
+
if (!digits) {
|
|
781
|
+
debug$3('sendDtmf skipped: no valid DTMF digits after sanitizing button payload');
|
|
782
|
+
return resolve();
|
|
783
|
+
}
|
|
784
|
+
debug$3(`Sending DTMF digits: ${digits}`);
|
|
773
785
|
const request = JSON.stringify({
|
|
774
786
|
METHOD: 'sendDtmf',
|
|
775
|
-
digits
|
|
787
|
+
digits,
|
|
776
788
|
sessionId: this.sessionId
|
|
777
789
|
});
|
|
778
790
|
this.ws.send(request);
|
|
@@ -780,8 +792,17 @@ class BotiumConnectorVoip {
|
|
|
780
792
|
// Check for DTMF tag in messageText: <DTMF>1234</DTMF>
|
|
781
793
|
const dtmfMatch = msg.messageText.match(/<DTMF>([^<]+)<\/DTMF>/i);
|
|
782
794
|
if (dtmfMatch && dtmfMatch[1]) {
|
|
783
|
-
const
|
|
784
|
-
|
|
795
|
+
const rawDigits = dtmfMatch[1];
|
|
796
|
+
const digits = sanitizeDtmfDigits(rawDigits);
|
|
797
|
+
if (!digits) {
|
|
798
|
+
debug$3(`sendDtmf skipped: no valid DTMF digits after sanitizing <DTMF> content (raw length=${String(rawDigits).length})`);
|
|
799
|
+
return resolve();
|
|
800
|
+
}
|
|
801
|
+
if (digits !== String(rawDigits).replace(/\s/g, '')) {
|
|
802
|
+
debug$3(`Sending DTMF from messageText (sanitized): "${rawDigits}" -> "${digits}"`);
|
|
803
|
+
} else {
|
|
804
|
+
debug$3(`Sending DTMF from messageText: ${digits}`);
|
|
805
|
+
}
|
|
785
806
|
const request = JSON.stringify({
|
|
786
807
|
METHOD: 'sendDtmf',
|
|
787
808
|
digits,
|