@eshal-bot/chat-widget 0.1.66 → 0.1.68

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.
@@ -8791,17 +8791,17 @@
8791
8791
  * @param {string} apiBaseUrl - Frontend base URL, e.g. https://demo.eshal.ai
8792
8792
  * @returns {string} Voice WS base, e.g. wss://demo.eshal.ai/voice/ws
8793
8793
  */
8794
- const getWebSocketUrl = apiBaseUrl => {
8794
+ const getWebSocketUrl = (apiBaseUrl, wsBaseUrl) => {
8795
+ // If the backend returned a wsBaseUrl in agentConfig (or customer passed one
8796
+ // explicitly), use it directly — it already points at the correct host.
8797
+ if (wsBaseUrl) return wsBaseUrl.replace(/\/$/, '');
8795
8798
  if (!apiBaseUrl) {
8796
- // No base URL yet (config still loading) — safe public default.
8797
8799
  return 'wss://dev.eshal.ai/voice/ws';
8798
8800
  }
8799
8801
  try {
8800
8802
  const url = new URL(apiBaseUrl);
8801
- // http→ws, https→wss; point at the frontend voice-proxy path.
8802
8803
  url.protocol = url.protocol.replace(/^http/, 'ws');
8803
8804
  url.pathname = '/voice/ws';
8804
- // Clean URL without a trailing slash.
8805
8805
  return url.toString().replace(/\/$/, '');
8806
8806
  } catch (error) {
8807
8807
  console.error("Invalid API base URL provided for WebSocket:", error);
@@ -9145,6 +9145,7 @@
9145
9145
  welcomeMessage,
9146
9146
  quickQuestions = [],
9147
9147
  apiBaseUrl,
9148
+ wsBaseUrl,
9148
9149
  apiKey,
9149
9150
  organizationId,
9150
9151
  getAuthToken,
@@ -9315,11 +9316,9 @@
9315
9316
  const visitorProfileRef = reactExports.useRef(null);
9316
9317
  const websocketUrl = reactExports.useMemo(() => {
9317
9318
  if (!organizationId) return null;
9318
- // Voice WS base is always derived from apiBaseUrl (the frontend origin
9319
- // the widget is embedded with) → wss://{host}/voice/ws. No override.
9320
- const resolvedWsBaseUrl = getWebSocketUrl(apiBaseUrl);
9319
+ const resolvedWsBaseUrl = getWebSocketUrl(apiBaseUrl, wsBaseUrl);
9321
9320
  return "".concat(resolvedWsBaseUrl, "/").concat(organizationId, "/").concat(bidiSessionId);
9322
- }, [apiBaseUrl, organizationId, bidiSessionId]);
9321
+ }, [apiBaseUrl, wsBaseUrl, organizationId, bidiSessionId]);
9323
9322
  const getNextMessageId = reactExports.useCallback(() => {
9324
9323
  const id = "msg-".concat(messageIdRef.current);
9325
9324
  messageIdRef.current += 1;
@@ -100731,7 +100730,7 @@
100731
100730
 
100732
100731
  // Map API response to widget props (use props as overrides if provided)
100733
100732
  const widgetConfig = reactExports.useMemo(() => {
100734
- var _agentConfig$config, _cfg$identity, _cfg$branding, _cfg$typography, _cfg$messages, _cfg$voice, _cfg$onboarding, _cfg$disclaimer, _cfg$csat, _cfg$inactivity, _cfg$behavior, _cfg$security, _cfg$layout, _ref2, _messages$bundles$loc, _messages$bundles, _messages$bundles$en, _messages$bundles2, _ref3, _ref4, _ref5, _ref6, _branding$chatbotAvat, _branding$chatbotAvat2, _ref7, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _typography$headerTex, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _inactivity$timeoutVa, _inactivity$timeoutUn, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _csat$enabled, _csat$format, _csat$prompt, _csat$triggerType, _csat$idleTimeoutMins, _csat$followUpEnabled, _csat$followUpPrompt, _behavior$autoPromptE, _behavior$allowFeedba, _behavior$provideCita, _agentConfig$organiza;
100733
+ var _agentConfig$config, _cfg$identity, _cfg$branding, _cfg$typography, _cfg$messages, _cfg$voice, _cfg$onboarding, _cfg$disclaimer, _cfg$csat, _cfg$inactivity, _cfg$behavior, _cfg$security, _cfg$layout, _ref2, _messages$bundles$loc, _messages$bundles, _messages$bundles$en, _messages$bundles2, _ref3, _ref4, _ref5, _ref6, _branding$chatbotAvat, _branding$chatbotAvat2, _ref7, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _typography$headerTex, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _inactivity$timeoutVa, _inactivity$timeoutUn, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _csat$enabled, _csat$format, _csat$prompt, _csat$triggerType, _csat$idleTimeoutMins, _csat$followUpEnabled, _csat$followUpPrompt, _behavior$autoPromptE, _behavior$allowFeedba, _behavior$provideCita, _agentConfig$organiza, _agentConfig$wsBaseUr;
100735
100734
  if (!agentConfig) {
100736
100735
  return null;
100737
100736
  }
@@ -100829,7 +100828,8 @@
100829
100828
  provideCitations: (_behavior$provideCita = behavior.provideCitations) !== null && _behavior$provideCita !== void 0 ? _behavior$provideCita : true,
100830
100829
  // organizationId from the backend response — used internally for
100831
100830
  // session isolation (localStorage keys) and WS paths. Not a user prop.
100832
- organizationId: (_agentConfig$organiza = agentConfig.organizationId) !== null && _agentConfig$organiza !== void 0 ? _agentConfig$organiza : null
100831
+ organizationId: (_agentConfig$organiza = agentConfig.organizationId) !== null && _agentConfig$organiza !== void 0 ? _agentConfig$organiza : null,
100832
+ wsBaseUrl: (_agentConfig$wsBaseUr = agentConfig.wsBaseUrl) !== null && _agentConfig$wsBaseUr !== void 0 ? _agentConfig$wsBaseUr : null
100833
100833
  };
100834
100834
  }, [agentConfig, darkMode, primaryColor, position, companyName, conciergeName, companyLogo, welcomeMessage, quickQuestions, quickQuestionsEnabled, textColor, agentMessageBubbleColor, userMessageBoxColor, assistantTextColor, userTextColor, fontFamily, fontSize, defaultLanguage, headerTextBold, headerTextItalic, enableVoiceInteraction, disclaimerEnabled, disclaimerText, disclaimerPosition, disclaimerLinkLabel, disclaimerLinkUrl, showPoweredBy, onboardingQuestions, onboardingEnabled, collectionPrompt, allowedDomains, agentMessageBubbleFontFamily, agentMessageBubbleFontSize, userMessageBubbleFontFamily, userMessageBubbleFontSize
100835
100835
  // CSAT dependencies
@@ -100900,11 +100900,7 @@
100900
100900
  welcomeMessage: widgetConfig.welcomeMessage,
100901
100901
  quickQuestions: widgetConfig.quickQuestions,
100902
100902
  apiBaseUrl,
100903
- // Voice WS endpoint is derived entirely from apiBaseUrl inside
100904
- // useChatState (→ wss://{host}/voice/ws, the frontend voice proxy).
100905
- // Nothing is forwarded/overridable here, so a stale backend or embed
100906
- // wsBaseUrl can't point voice at the old (now non-public)
100907
- // knowledge-api LoadBalancer.
100903
+ wsBaseUrl: widgetConfig.wsBaseUrl,
100908
100904
  apiKey,
100909
100905
  organizationId: widgetConfig.organizationId,
100910
100906
  getAuthToken,