@enegelai/bot-widget 1.12.3 → 1.12.5

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/dist/index.es.js CHANGED
@@ -806,7 +806,7 @@ A.setLevel("info");
806
806
  const ee = "cb_";
807
807
  class L extends kt {
808
808
  constructor() {
809
- super(...arguments), this.actionIdCounter = 0, this.prefilledFormValues = {}, this.wsClient = null, this.replyMessage = null, this.streamingResponseInProgress = !1, this.streamingResponseLastText = null, this.streamingResponseBuffer = null, this.streamingResponseTagStartPos = 0, this.streamingResponseCurrentTag = null;
809
+ super(...arguments), this.actionIdCounter = 0, this.currentLoadContext = {}, this.prefilledFormValues = {}, this.wsClient = null, this.replyMessage = null, this.streamingResponseInProgress = !1, this.streamingResponseLastText = null, this.streamingResponseBuffer = null, this.streamingResponseTagStartPos = 0, this.streamingResponseCurrentTag = null;
810
810
  }
811
811
  // this is called at startup
812
812
  setSetting(e) {
@@ -848,7 +848,7 @@ class L extends kt {
848
848
  }, this.botSettingsRetryTimeout * 1e3), this.botSettingsRetryTimeout = this.botSettingsRetryTimeout * 2;
849
849
  return;
850
850
  }
851
- A.info("Got bot settings - bot is enabled", r), this.disabled = !1, this.setting.welcomeMessage = (r == null ? void 0 : r.welcomeMessage) || "How can I help ?", this.setting.engageMessage = (r == null ? void 0 : r.engageMessage) || "How can I help ?", this.setting.engageTimeout = (r == null ? void 0 : r.engageTimeout) || 5, this.setting.splitMessagesAtBreak = "splitMessagesAtBreak" in r ? r.splitMessagesAtBreak : !1, this.setting.feedbackEnabled = "feedbackEnabled" in r ? r.feedbackEnabled : !1, this.setting.uploadImages = "uploadImages" in r ? r.uploadImages : !1, this.setting.newConversationTimeoutInSec = (r == null ? void 0 : r.newConversationTimeoutInSec) || 86400, this.initConversation(), this.shouldEngage === "true" && setTimeout(() => {
851
+ A.info("Got bot settings - bot is enabled", r), this.disabled = !1, this.setting.welcomeMessage = (r == null ? void 0 : r.welcomeMessage) || "How can I help ?", this.setting.engageMessage = (r == null ? void 0 : r.engageMessage) || "How can I help ?", this.setting.engageTimeout = (r == null ? void 0 : r.engageTimeout) || 5, this.setting.splitMessagesAtBreak = "splitMessagesAtBreak" in r ? r.splitMessagesAtBreak : !1, this.setting.feedbackEnabled = "feedbackEnabled" in r ? r.feedbackEnabled : !1, this.setting.uploadImages = "uploadImages" in r ? r.uploadImages : !1, this.setting.newConversationTimeoutInSec = (r == null ? void 0 : r.newConversationTimeoutInSec) || 86400, this.setting.enableNotificationSound = "enableNotificationSound" in r ? r.enableNotificationSound : !0, this.initConversation(), this.shouldEngage === "true" && setTimeout(() => {
852
852
  this.showEngagePopup();
853
853
  }, this.setting.engageTimeout * 1e3);
854
854
  }
@@ -873,7 +873,7 @@ class L extends kt {
873
873
  initConversation() {
874
874
  const e = Date.now(), a = this.setting.newConversationTimeoutInSec * 1e3;
875
875
  let n = this.lastConversationUpdate;
876
- if (typeof n == "string" && (n = isNaN(n) ? 0 : parseInt(n, 10)), n > 0 && e - n > a) {
876
+ if (typeof n == "string" && (n = isNaN(n) ? 0 : parseInt(n, 10)), e - n > a) {
877
877
  this.clearConversation();
878
878
  return;
879
879
  }
@@ -881,7 +881,7 @@ class L extends kt {
881
881
  }
882
882
  clearConversation() {
883
883
  this.wsClient && (this.wsClient.stop().then(() => {
884
- }), this.wsClient = null), this.conversationId = xe(), this.lastConversationUpdate = Date.now(), this.connectWs = "false", this.shouldEngage = "true", this.messages = [], this.unreadMessages = 0, this.actions = [], this.context = {}, this.form = null, this.addMessage({
884
+ }), this.wsClient = null), this.conversationId = xe(), this.lastConversationUpdate = Date.now(), this.connectWs = "false", this.shouldEngage = "true", this.messages = [], this.unreadMessages = 0, this.actions = [], this.context = this.currentLoadContext, this.form = null, this.addMessage({
885
885
  author: "assistant",
886
886
  type: "text",
887
887
  data: {
@@ -901,7 +901,7 @@ class L extends kt {
901
901
  return;
902
902
  const a = this.context ? this.context : {};
903
903
  for (const [n, s] of Object.entries(e))
904
- a[n] = s;
904
+ a[n] = s, this.currentLoadContext[n] = s;
905
905
  this.context = a, this.wsClient && await this.sendContext();
906
906
  }
907
907
  async sendContext() {
@@ -923,7 +923,7 @@ class L extends kt {
923
923
  return this.context;
924
924
  }
925
925
  clearContext() {
926
- this.context = {};
926
+ this.context = {}, this.currentLoadContext = {};
927
927
  }
928
928
  initStartupForm() {
929
929
  const e = wt(null, ["startupForm"], this.botSettings);
@@ -966,6 +966,8 @@ class L extends kt {
966
966
  this.open || (A.info("Engaging User !"), this.engage = !0, this.playAudioNotification());
967
967
  }
968
968
  playAudioNotification() {
969
+ if (!this.setting.enableNotificationSound)
970
+ return;
969
971
  const e = (r) => {
970
972
  const f = new Uint8Array(r.length / 2);
971
973
  for (let w = 0; w < f.length; w++)
@@ -1472,7 +1474,8 @@ O([
1472
1474
  splitMessagesAtBreak: !1,
1473
1475
  feedbackEnabled: !1,
1474
1476
  uploadImages: !1,
1475
- newConversationTimeoutInSec: 86400
1477
+ newConversationTimeoutInSec: 86400,
1478
+ enableNotificationSound: !0
1476
1479
  }
1477
1480
  })
1478
1481
  ], L.prototype, "setting");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enegelai/bot-widget",
3
- "version": "1.12.3",
3
+ "version": "1.12.5",
4
4
  "description": "Enegel.ai Bot Widget",
5
5
  "scripts": {
6
6
  "dev": "vite",