bibot 1.0.42 → 1.0.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- import React__default, { createContext, useReducer, useEffect, useState, useContext, useRef, useCallback, useDebugValue, createElement } from 'react';
1
+ import React__default, { createContext, useReducer, useContext, useState, useRef, useEffect, useDebugValue, createElement } from 'react';
2
2
 
3
3
  function _extends() {
4
4
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -3331,15 +3331,25 @@ function _finallyRethrows(body, finalizer) {
3331
3331
 
3332
3332
  var appStateEnums;
3333
3333
  (function (appStateEnums) {
3334
- appStateEnums["BIBOT"] = "BIBOT";
3334
+ appStateEnums["AI_FOLLOW_UPS"] = "AI_FOLLOW_UPS";
3335
+ appStateEnums["CHAT_BUBBLE_CONFIG"] = "CHAT_BUBBLE_CONFIG";
3336
+ appStateEnums["CHAT_BUBBLE_IS_OPENED"] = "CHAT_BUBBLE_IS_OPENED";
3337
+ appStateEnums["PRE_DEFINED_QUESTIONS"] = "PRE_DEFINED_QUESTIONS";
3335
3338
  })(appStateEnums || (appStateEnums = {}));
3336
3339
 
3337
3340
  var appReducer = function appReducer(state, action) {
3338
- console.log('This is the appReducer state', state, action);
3339
3341
  switch (action.type) {
3340
- case appStateEnums.BIBOT:
3342
+ case appStateEnums.PRE_DEFINED_QUESTIONS:
3341
3343
  return _extends({}, state, {
3342
- chatIsOpen: action.chatIsOpen
3344
+ pQuestions: action.pQuestions
3345
+ });
3346
+ case appStateEnums.CHAT_BUBBLE_CONFIG:
3347
+ return _extends({}, state, {
3348
+ chatBubbleConfig: action.chatBubbleConfig
3349
+ });
3350
+ case appStateEnums.AI_FOLLOW_UPS:
3351
+ return _extends({}, state, {
3352
+ aiFollowUpQs: action.aiFollowUp
3343
3353
  });
3344
3354
  default:
3345
3355
  return state;
@@ -3425,41 +3435,35 @@ var getSessionId = function getSessionId() {
3425
3435
  var dummyDispatch = function dummyDispatch() {};
3426
3436
  var defaultContextValue = {
3427
3437
  state: {
3428
- chatIsOpen: false,
3429
- sessionId: getSessionId()
3438
+ aiFollowUpQs: [],
3439
+ sessionId: getSessionId(),
3440
+ chatBubbleConfig: {
3441
+ bgColor: 'grey',
3442
+ color: 'dark',
3443
+ title: 'ChatBot Powered By BiBot',
3444
+ logo_url: 'https://bibot.app/static/media/bibot-high-resolution-logo-black-transparent.cf2e603c743f07663fd7.png'
3445
+ },
3446
+ pQuestions: []
3430
3447
  },
3431
3448
  dispatch: dummyDispatch
3432
3449
  };
3433
3450
  var AppContext = createContext(defaultContextValue);
3434
3451
  var AppProvider = function AppProvider(_ref) {
3435
3452
  var children = _ref.children;
3436
- var APP_STATE_KEY = 'app_states';
3437
3453
  var initialState = {
3438
- chatIsOpen: false,
3439
- sessionId: getSessionId()
3454
+ aiFollowUpQs: [],
3455
+ pQuestions: [],
3456
+ sessionId: getSessionId(),
3457
+ chatBubbleConfig: {
3458
+ bgColor: 'grey',
3459
+ color: 'dark',
3460
+ title: 'ChatBot Powered By BiBot',
3461
+ logo_url: 'https://bibot.app/static/media/bibot-high-resolution-logo-black-transparent.cf2e603c743f07663fd7.png'
3462
+ }
3440
3463
  };
3441
3464
  var _useReducer = useReducer(appReducer, initialState),
3442
3465
  state = _useReducer[0],
3443
3466
  dispatch = _useReducer[1];
3444
- useEffect(function () {
3445
- var storedStates = localStorage.getItem(APP_STATE_KEY);
3446
- if (storedStates) {
3447
- try {
3448
- var parsedStates = JSON.parse(storedStates);
3449
- var updatedStates = _extends({}, initialState, parsedStates);
3450
- console.log(initialState, parsedStates, updatedStates);
3451
- dispatch(_extends({
3452
- type: appStateEnums.BIBOT
3453
- }, updatedStates));
3454
- } catch (error) {
3455
- console.error('Failed to parse app states from local storage:', error);
3456
- }
3457
- }
3458
- }, []);
3459
- useEffect(function () {
3460
- console.log('Changes in state: ', state);
3461
- localStorage.setItem(APP_STATE_KEY, JSON.stringify(state));
3462
- }, [state]);
3463
3467
  return React__default.createElement(AppContext.Provider, {
3464
3468
  value: {
3465
3469
  state: state,
@@ -3503,7 +3507,6 @@ var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefi
3503
3507
  return Promise.resolve(pluginAxiosInstance.get(path, {
3504
3508
  params: params
3505
3509
  })).then(function (response) {
3506
- console.log(response.data.predefined_questions);
3507
3510
  return response.data.predefined_questions;
3508
3511
  });
3509
3512
  }, function () {
@@ -3521,10 +3524,10 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
3521
3524
  });
3522
3525
  }, function () {
3523
3526
  return {
3524
- bgColor: 'white',
3525
- chatColor: 'blue',
3526
- title: 'ChatBot',
3527
- userImage: 'string'
3527
+ bgColor: 'grey',
3528
+ color: 'dark',
3529
+ title: 'ChatBot Powered By BiBot',
3530
+ logo_url: 'https://bibot.app/static/media/bibot-high-resolution-logo-black-transparent.cf2e603c743f07663fd7.png'
3528
3531
  };
3529
3532
  }));
3530
3533
  } catch (e) {
@@ -3536,7 +3539,9 @@ var handleRetries = function handleRetries(pluginAxiosInstance, data, attempt) {
3536
3539
  var maxAttempts = 30;
3537
3540
  var delay = 10000;
3538
3541
  if (attempt >= maxAttempts) {
3539
- return Promise.resolve("Sorry this is taking longer than usual. Please try again later");
3542
+ return Promise.resolve({
3543
+ message: "Sorry this is taking longer than usual. Please try again later"
3544
+ });
3540
3545
  }
3541
3546
  return Promise.resolve(new Promise(function (resolve) {
3542
3547
  return setTimeout(resolve, delay);
@@ -3544,15 +3549,17 @@ var handleRetries = function handleRetries(pluginAxiosInstance, data, attempt) {
3544
3549
  return _catch(function () {
3545
3550
  return Promise.resolve(askTimedOutBiBot(pluginAxiosInstance, _extends({}, data, {
3546
3551
  tries: attempt + 1
3547
- }))).then(function (message) {
3548
- if (message === defaultSlacker) {
3552
+ }))).then(function (res) {
3553
+ if (res.message === defaultSlacker) {
3549
3554
  return Promise.resolve(handleRetries(pluginAxiosInstance, data, attempt + 1));
3550
3555
  } else {
3551
- return message;
3556
+ return res;
3552
3557
  }
3553
3558
  });
3554
3559
  }, function (error) {
3555
- return error.message;
3560
+ return {
3561
+ message: error.message
3562
+ };
3556
3563
  });
3557
3564
  });
3558
3565
  } catch (e) {
@@ -3567,12 +3574,10 @@ var askBiBot = function askBiBot(pluginAxiosInstance, data) {
3567
3574
  if (response.data.message === defaultSlacker) {
3568
3575
  return Promise.resolve(handleRetries(pluginAxiosInstance, data, 1));
3569
3576
  } else {
3570
- return response.data.message;
3577
+ return response.data;
3571
3578
  }
3572
3579
  });
3573
3580
  }, function (error1) {
3574
- console.log('This is the error1 from the endpoint on the 1st try:', error1);
3575
- console.log(error1.message);
3576
3581
  return error1.message;
3577
3582
  }));
3578
3583
  } catch (e) {
@@ -3583,13 +3588,10 @@ var recordPredefinedQ = function recordPredefinedQ(pluginAxiosInstance, data) {
3583
3588
  try {
3584
3589
  return Promise.resolve(_catch(function () {
3585
3590
  var path = "" + domain.inference + resources.predefinedQstatistics;
3586
- console.log(data, 'here');
3587
3591
  return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
3588
- console.log(response, 'here is the res');
3589
3592
  return response.data;
3590
3593
  });
3591
3594
  }, function (error) {
3592
- console.log(error.message);
3593
3595
  return error.message;
3594
3596
  }));
3595
3597
  } catch (e) {
@@ -3601,12 +3603,12 @@ var askTimedOutBiBot = function askTimedOutBiBot(pluginAxiosInstance, data) {
3601
3603
  return Promise.resolve(_catch(function () {
3602
3604
  var path = "" + domain.inference + resources.timeoutQ;
3603
3605
  return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
3604
- console.log(response);
3605
- return response.data.message;
3606
+ return response.data;
3606
3607
  });
3607
3608
  }, function (error) {
3608
- console.log(error.message);
3609
- return error.message;
3609
+ return {
3610
+ message: error.message
3611
+ };
3610
3612
  }));
3611
3613
  } catch (e) {
3612
3614
  return Promise.reject(e);
@@ -3614,7 +3616,7 @@ var askTimedOutBiBot = function askTimedOutBiBot(pluginAxiosInstance, data) {
3614
3616
  };
3615
3617
  var defaultSlacker = "BiBot_Retry_Later";
3616
3618
 
3617
- var useBiBotChatBot = function useBiBotChatBot(_ref) {
3619
+ var useBiBotChatBot = function useBiBotChatBot(bibotProps) {
3618
3620
  var sendInputInquiry = function sendInputInquiry() {
3619
3621
  try {
3620
3622
  setIsLoading(true);
@@ -3631,17 +3633,24 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3631
3633
  }]);
3632
3634
  });
3633
3635
  return Promise.resolve(askBiBot(pluginAxiosInstance, {
3634
- client_id: clientId,
3636
+ client_id: bibotProps.clientId,
3635
3637
  q: input,
3636
- session_id: client_session_id ? client_session_id : state.sessionId,
3637
- chat_id: v4()
3638
+ session_id: bibotProps.client_session_id ? bibotProps.client_session_id : state.sessionId,
3639
+ chat_id: v4(),
3640
+ chat_history: messages
3638
3641
  })).then(function (response) {
3639
3642
  setMessages(function (messages) {
3640
3643
  return [].concat(messages, [{
3641
3644
  sender: 'bot',
3642
- text: response
3645
+ text: response.message
3643
3646
  }]);
3644
3647
  });
3648
+ if (response.aiFollowUp) {
3649
+ dispatch({
3650
+ type: appStateEnums.AI_FOLLOW_UPS,
3651
+ aiFollowUp: response.aiFollowUp
3652
+ });
3653
+ }
3645
3654
  });
3646
3655
  }
3647
3656
  }();
@@ -3659,106 +3668,73 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3659
3668
  return Promise.reject(e);
3660
3669
  }
3661
3670
  };
3662
- var askPredefinedQuestion = function askPredefinedQuestion(question, client_id) {
3671
+ var askPredefinedQuestion = function askPredefinedQuestion(question) {
3663
3672
  try {
3664
3673
  setIsLoading(true);
3665
3674
  var input = question.question.trim();
3666
- recordPredefinedQ(pluginAxiosInstance, {
3667
- "client_id": clientId,
3675
+ return Promise.resolve(recordPredefinedQ(pluginAxiosInstance, {
3676
+ "client_id": bibotProps.clientId,
3668
3677
  "question": question.question,
3669
3678
  "q_n_a_id": question.q_n_a_id
3670
- });
3671
- console.log(question.question, client_id, question.q_n_a_id);
3672
- setUserInput('');
3673
- if (input === question.question) {
3674
- setMessages(function (messages) {
3675
- return [].concat(messages, [{
3676
- sender: 'user',
3677
- text: input
3678
- }]);
3679
- });
3680
- setTimeout(function () {
3679
+ })).then(function (response) {
3680
+ setUserInput('');
3681
+ if (input === question.question) {
3682
+ setMessages(function (messages) {
3683
+ return [].concat(messages, [{
3684
+ sender: 'user',
3685
+ text: input
3686
+ }]);
3687
+ });
3681
3688
  setMessages(function (messages) {
3682
3689
  return [].concat(messages, [{
3683
3690
  sender: 'bot',
3684
- text: question.answer
3691
+ text: response.message ? response.message : question.answer
3685
3692
  }]);
3686
3693
  });
3694
+ if (response.aiFollowUp) {
3695
+ dispatch({
3696
+ type: appStateEnums.AI_FOLLOW_UPS,
3697
+ aiFollowUp: response.aiFollowUp
3698
+ });
3699
+ }
3687
3700
  setIsLoading(false);
3688
- }, 1000);
3689
- }
3690
- return Promise.resolve();
3701
+ }
3702
+ });
3691
3703
  } catch (e) {
3692
3704
  return Promise.reject(e);
3693
3705
  }
3694
3706
  };
3695
- var clientId = _ref.clientId,
3696
- client_session_id = _ref.client_session_id,
3697
- test = _ref.test;
3698
- var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
3699
- var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
3700
- var _useState = useState([]),
3701
- predefinedQuestions = _useState[0],
3702
- setPredefinedQuestions = _useState[1];
3703
- var _useState2 = useState(true),
3704
- showPredefinedQuestions = _useState2[0],
3705
- setShowPredefinedQuestions = _useState2[1];
3706
3707
  var _useContext = useContext(AppContext),
3707
- state = _useContext.state;
3708
- var _useState3 = useState(false),
3709
- chatIsOpen = _useState3[0],
3710
- setChatIsOpen = _useState3[1];
3711
- var _useState4 = useState([]),
3712
- messages = _useState4[0],
3713
- setMessages = _useState4[1];
3714
- var _useState5 = useState(''),
3715
- userInput = _useState5[0],
3716
- setUserInput = _useState5[1];
3717
- var _useState6 = useState(false),
3718
- isLoading = _useState6[0],
3719
- setIsLoading = _useState6[1];
3708
+ state = _useContext.state,
3709
+ dispatch = _useContext.dispatch;
3710
+ console.log('This is the value of test and bibotProps', bibotProps.test, bibotProps);
3711
+ var baseURL = bibotProps !== null && bibotProps !== void 0 && bibotProps.test ? endpoints.getInferenceURL(bibotProps === null || bibotProps === void 0 ? void 0 : bibotProps.test) : endpoints.getInferenceURL(false);
3712
+ var pluginAxiosInstance = createPluginAxiosInstance(baseURL, {}, {
3713
+ Authorization: bibotProps.jwt
3714
+ });
3715
+ var _useState = useState(true),
3716
+ showPredefinedQuestions = _useState[0],
3717
+ setShowPredefinedQuestions = _useState[1];
3718
+ var _useState2 = useState(false),
3719
+ chatIsOpen = _useState2[0],
3720
+ setChatIsOpen = _useState2[1];
3721
+ var _useState3 = useState([]),
3722
+ messages = _useState3[0],
3723
+ setMessages = _useState3[1];
3724
+ var _useState4 = useState(''),
3725
+ userInput = _useState4[0],
3726
+ setUserInput = _useState4[1];
3727
+ var _useState5 = useState(false),
3728
+ isLoading = _useState5[0],
3729
+ setIsLoading = _useState5[1];
3720
3730
  var messageEndRef = useRef(null);
3721
- var _useState7 = useState(),
3722
- chatBubbleConfig = _useState7[0],
3723
- setChatBubbleConfig = _useState7[1];
3724
3731
  var handlePredefinedQuestionSelect = function handlePredefinedQuestionSelect(question) {
3725
3732
  sendInputInquiry();
3726
- askPredefinedQuestion(question, clientId);
3733
+ askPredefinedQuestion(question);
3727
3734
  setUserInput('');
3728
3735
  setShowPredefinedQuestions(false);
3729
3736
  };
3730
- var getChatBubbleConfig = useCallback(function () {
3731
- try {
3732
- return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
3733
- client_id: clientId
3734
- })).then(function (remotePredefinedQuestions) {
3735
- if (remotePredefinedQuestions) {
3736
- setPredefinedQuestions(remotePredefinedQuestions);
3737
- }
3738
- return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
3739
- client_id: clientId
3740
- })).then(function (remoteChatBubbleConfig) {
3741
- if (remoteChatBubbleConfig) {
3742
- setChatBubbleConfig(remoteChatBubbleConfig);
3743
- }
3744
- });
3745
- });
3746
- } catch (e) {
3747
- return Promise.reject(e);
3748
- }
3749
- }, [clientId]);
3750
- useEffect(function () {
3751
- void getChatBubbleConfig();
3752
- }, [getChatBubbleConfig]);
3753
- useEffect(function () {
3754
- if (messageEndRef !== null && messageEndRef !== void 0 && messageEndRef.current) {
3755
- messageEndRef.current.scrollIntoView({
3756
- behavior: 'smooth'
3757
- });
3758
- }
3759
- }, [messages]);
3760
3737
  var toggleChat = function toggleChat() {
3761
- console.log('This is it', chatIsOpen);
3762
3738
  setChatIsOpen(!chatIsOpen);
3763
3739
  };
3764
3740
  var handleUserInput = function handleUserInput(e) {
@@ -3776,6 +3752,37 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3776
3752
  return Promise.reject(e);
3777
3753
  }
3778
3754
  };
3755
+ useEffect(function () {
3756
+ getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
3757
+ client_id: bibotProps.clientId
3758
+ }).then(function (remoteChatBubbleConfig) {
3759
+ if (remoteChatBubbleConfig) {
3760
+ dispatch({
3761
+ type: appStateEnums.CHAT_BUBBLE_CONFIG,
3762
+ chatBubbleConfig: remoteChatBubbleConfig
3763
+ });
3764
+ }
3765
+ });
3766
+ }, [bibotProps.clientId]);
3767
+ useEffect(function () {
3768
+ getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
3769
+ client_id: bibotProps.clientId
3770
+ }).then(function (remotePredefinedQuestions) {
3771
+ if (remotePredefinedQuestions) {
3772
+ dispatch({
3773
+ type: appStateEnums.PRE_DEFINED_QUESTIONS,
3774
+ pQuestions: remotePredefinedQuestions
3775
+ });
3776
+ }
3777
+ });
3778
+ }, [bibotProps.clientId]);
3779
+ useEffect(function () {
3780
+ if (messageEndRef !== null && messageEndRef !== void 0 && messageEndRef.current) {
3781
+ messageEndRef.current.scrollIntoView({
3782
+ behavior: 'smooth'
3783
+ });
3784
+ }
3785
+ }, [messages]);
3779
3786
  return {
3780
3787
  chatIsOpen: chatIsOpen,
3781
3788
  messages: messages,
@@ -3786,9 +3793,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3786
3793
  handleKeyPress: handleKeyPress,
3787
3794
  toggleChat: toggleChat,
3788
3795
  sendInputInquiry: sendInputInquiry,
3789
- chatBubbleConfig: chatBubbleConfig,
3796
+ chatBubbleConfig: state.chatBubbleConfig,
3790
3797
  showPredefinedQuestions: showPredefinedQuestions,
3791
- predefinedQuestions: predefinedQuestions,
3798
+ predefinedQuestions: state.pQuestions,
3799
+ aiFollowUpQs: state.aiFollowUpQs,
3792
3800
  handlePredefinedQuestionSelect: handlePredefinedQuestionSelect
3793
3801
  };
3794
3802
  };
@@ -3803,11 +3811,11 @@ function SendMessageIcon(_ref) {
3803
3811
  width: '24',
3804
3812
  height: '24',
3805
3813
  viewBox: '0 0 24 24',
3806
- "stroke-width": '1.5',
3814
+ strokeWidth: '1.5',
3807
3815
  stroke: color,
3808
3816
  fill: 'none',
3809
- "stroke-linecap": 'round',
3810
- "stroke-linejoin": 'round'
3817
+ strokeLinecap: 'round',
3818
+ strokeLinejoin: 'round'
3811
3819
  }, React__default.createElement("path", {
3812
3820
  stroke: 'none',
3813
3821
  d: 'M0 0h24v24H0z',
@@ -3825,11 +3833,11 @@ function DefaultBotProfile() {
3825
3833
  width: '24',
3826
3834
  height: '24',
3827
3835
  viewBox: '0 0 24 24',
3828
- "stroke-width": '1.5',
3836
+ strokeWidth: '1.5',
3829
3837
  stroke: '#fff',
3830
3838
  fill: 'none',
3831
- "stroke-linecap": 'round',
3832
- "stroke-linejoin": 'round'
3839
+ strokeLinecap: 'round',
3840
+ strokeLinejoin: 'round'
3833
3841
  }, React__default.createElement("path", {
3834
3842
  stroke: 'none',
3835
3843
  d: 'M0 0h24v24H0z',
@@ -3855,11 +3863,11 @@ function ChatIcon() {
3855
3863
  width: '40',
3856
3864
  height: '40',
3857
3865
  viewBox: '0 0 24 24',
3858
- "stroke-width": '1.5',
3866
+ strokeWidth: '1.5',
3859
3867
  stroke: '#fff',
3860
3868
  fill: 'none',
3861
- "stroke-linecap": 'round',
3862
- "stroke-linejoin": 'round'
3869
+ strokeLinecap: 'round',
3870
+ strokeLinejoin: 'round'
3863
3871
  }, React__default.createElement("path", {
3864
3872
  stroke: 'none',
3865
3873
  d: 'M0 0h24v24H0z',
@@ -3881,11 +3889,11 @@ function CloseIcon() {
3881
3889
  width: "40",
3882
3890
  height: "40",
3883
3891
  viewBox: "0 0 24 24",
3884
- "stroke-width": "1.5",
3892
+ strokeWidth: "1.5",
3885
3893
  stroke: "#fff",
3886
3894
  fill: "none",
3887
- "stroke-linecap": "round",
3888
- "stroke-linejoin": "round"
3895
+ strokeLinecap: "round",
3896
+ strokeLinejoin: "round"
3889
3897
  }, React__default.createElement("path", {
3890
3898
  stroke: "none",
3891
3899
  d: "M0 0h24v24H0z",
@@ -4084,13 +4092,7 @@ var Loader = function Loader() {
4084
4092
  var PredefinedQuestions = function PredefinedQuestions(_ref) {
4085
4093
  var questions = _ref.questions,
4086
4094
  onSelect = _ref.onSelect,
4087
- clientId = _ref.clientId,
4088
- test = _ref.test;
4089
- var _useBiBotChatBot = useBiBotChatBot({
4090
- clientId: clientId,
4091
- test: test
4092
- }),
4093
- chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
4095
+ chatBubbleConfig = _ref.chatBubbleConfig;
4094
4096
  return createElement("div", {
4095
4097
  style: {
4096
4098
  height: '100%',
@@ -4117,7 +4119,7 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
4117
4119
  style: {
4118
4120
  marginBlock: '0.5px'
4119
4121
  }
4120
- }, "Welcome!"), createElement("p", {
4122
+ }, chatBubbleConfig !== null && chatBubbleConfig !== void 0 && chatBubbleConfig.knownUser ? "Hello " + chatBubbleConfig.knownUser : 'Welcome!'), createElement("p", {
4121
4123
  style: {
4122
4124
  fontSize: '14px'
4123
4125
  }
@@ -4141,31 +4143,70 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
4141
4143
  }, question.question);
4142
4144
  }));
4143
4145
  };
4144
- var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4145
- var _chatBubbleConfig$col2, _chatBubbleConfig$col3;
4146
- var clientId = _ref2.clientId,
4147
- client_session_id = _ref2.client_session_id,
4148
- redirect_notice = _ref2.redirect_notice,
4149
- test = _ref2.test;
4150
- var _useBiBotChatBot2 = useBiBotChatBot({
4151
- clientId: clientId,
4152
- client_session_id: client_session_id,
4153
- redirect_notice: redirect_notice,
4154
- test: test
4155
- }),
4156
- chatIsOpen = _useBiBotChatBot2.chatIsOpen,
4157
- messages = _useBiBotChatBot2.messages,
4158
- isLoading = _useBiBotChatBot2.isLoading,
4159
- messageEndRef = _useBiBotChatBot2.messageEndRef,
4160
- userInput = _useBiBotChatBot2.userInput,
4161
- handleUserInput = _useBiBotChatBot2.handleUserInput,
4162
- handleKeyPress = _useBiBotChatBot2.handleKeyPress,
4163
- sendInputInquiry = _useBiBotChatBot2.sendInputInquiry,
4164
- toggleChat = _useBiBotChatBot2.toggleChat,
4165
- chatBubbleConfig = _useBiBotChatBot2.chatBubbleConfig,
4166
- showPredefinedQuestions = _useBiBotChatBot2.showPredefinedQuestions,
4167
- predefinedQuestions = _useBiBotChatBot2.predefinedQuestions,
4168
- handlePredefinedQuestionSelect = _useBiBotChatBot2.handlePredefinedQuestionSelect;
4146
+
4147
+ var AiFollowUps = function AiFollowUps(_ref) {
4148
+ var questions = _ref.questions,
4149
+ onSelect = _ref.onSelect,
4150
+ chatBubbleConfig = _ref.chatBubbleConfig;
4151
+ return createElement("div", {
4152
+ style: {
4153
+ height: '100%',
4154
+ color: '#000',
4155
+ backgroundColor: '#fff',
4156
+ padding: 10,
4157
+ borderRadius: '6px',
4158
+ marginBottom: '20px'
4159
+ }
4160
+ }, createElement("div", {
4161
+ style: {
4162
+ display: 'flex',
4163
+ justifyContent: 'center',
4164
+ alignItems: 'center',
4165
+ flexDirection: 'column',
4166
+ textAlign: 'center'
4167
+ }
4168
+ }, createElement("p", {
4169
+ style: {
4170
+ fontSize: '14px'
4171
+ }
4172
+ }, " Related questions ")), questions.map(function (question, index) {
4173
+ var _chatBubbleConfig$col;
4174
+ return createElement("div", {
4175
+ key: index,
4176
+ style: {
4177
+ backgroundColor: 'transparent',
4178
+ border: "0.5px solid " + (chatBubbleConfig ? (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede' : '#000'),
4179
+ fontSize: '16px',
4180
+ margin: '7px',
4181
+ textAlign: 'start',
4182
+ padding: '10px',
4183
+ borderRadius: '6px',
4184
+ cursor: 'pointer'
4185
+ },
4186
+ onClick: function onClick() {
4187
+ onSelect(question);
4188
+ }
4189
+ }, question.question);
4190
+ }));
4191
+ };
4192
+
4193
+ var ChatBubbleBiBot = function ChatBubbleBiBot(bibotProps) {
4194
+ var _chatBubbleConfig$col, _chatBubbleConfig$col2;
4195
+ var _useBiBotChatBot = useBiBotChatBot(bibotProps),
4196
+ chatIsOpen = _useBiBotChatBot.chatIsOpen,
4197
+ messages = _useBiBotChatBot.messages,
4198
+ isLoading = _useBiBotChatBot.isLoading,
4199
+ messageEndRef = _useBiBotChatBot.messageEndRef,
4200
+ userInput = _useBiBotChatBot.userInput,
4201
+ handleUserInput = _useBiBotChatBot.handleUserInput,
4202
+ handleKeyPress = _useBiBotChatBot.handleKeyPress,
4203
+ sendInputInquiry = _useBiBotChatBot.sendInputInquiry,
4204
+ toggleChat = _useBiBotChatBot.toggleChat,
4205
+ chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig,
4206
+ showPredefinedQuestions = _useBiBotChatBot.showPredefinedQuestions,
4207
+ predefinedQuestions = _useBiBotChatBot.predefinedQuestions,
4208
+ aiFollowUpQs = _useBiBotChatBot.aiFollowUpQs,
4209
+ handlePredefinedQuestionSelect = _useBiBotChatBot.handlePredefinedQuestionSelect;
4169
4210
  var isOnline = useOnlineStatus();
4170
4211
  return createElement("div", {
4171
4212
  className: "chat-bubble " + (chatIsOpen ? 'open' : ''),
@@ -4193,7 +4234,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4193
4234
  }, createElement("div", {
4194
4235
  className: styles['chat-header'],
4195
4236
  style: {
4196
- backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
4237
+ backgroundColor: (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede',
4197
4238
  height: 50,
4198
4239
  borderTopLeftRadius: 8,
4199
4240
  borderTopRightRadius: 8,
@@ -4253,7 +4294,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4253
4294
  }, showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && createElement(PredefinedQuestions, {
4254
4295
  questions: predefinedQuestions.slice(0, 3),
4255
4296
  onSelect: handlePredefinedQuestionSelect,
4256
- clientId: clientId
4297
+ chatBubbleConfig: chatBubbleConfig
4257
4298
  }), messages.map(function (message, index) {
4258
4299
  return message.sender === 'user' ? createElement("div", {
4259
4300
  key: index,
@@ -4293,6 +4334,10 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4293
4334
  textAlign: 'left'
4294
4335
  }
4295
4336
  }, message.text));
4337
+ }), aiFollowUpQs && !isLoading && createElement(AiFollowUps, {
4338
+ questions: aiFollowUpQs,
4339
+ onSelect: handlePredefinedQuestionSelect,
4340
+ chatBubbleConfig: chatBubbleConfig
4296
4341
  }), isLoading && createElement("div", {
4297
4342
  style: {
4298
4343
  marginLeft: '20px'
@@ -4344,7 +4389,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4344
4389
  onClick: toggleChat,
4345
4390
  className: styles['chat-toggle'],
4346
4391
  style: {
4347
- backgroundColor: (_chatBubbleConfig$col3 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col3 : '#dedede',
4392
+ backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
4348
4393
  color: '#fff',
4349
4394
  borderRadius: '50%',
4350
4395
  cursor: 'pointer',
@@ -4358,16 +4403,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4358
4403
  }, chatIsOpen ? createElement(CloseIcon, null) : createElement(ChatIcon, null)));
4359
4404
  };
4360
4405
 
4361
- var BiBot = function BiBot(_ref) {
4362
- var clientId = _ref.clientId,
4363
- client_session_id = _ref.client_session_id,
4364
- redirect_notice = _ref.redirect_notice,
4365
- test = _ref.test;
4406
+ var BiBot = function BiBot(bibotProps) {
4366
4407
  return createElement(AppProvider, null, createElement(ChatBubbleBiBot, {
4367
- clientId: clientId,
4368
- client_session_id: client_session_id,
4369
- redirect_notice: redirect_notice,
4370
- test: test
4408
+ jwt: bibotProps.jwt,
4409
+ clientId: bibotProps.clientId,
4410
+ client_session_id: bibotProps.client_session_id,
4411
+ redirect_notice: bibotProps.redirect_notice,
4412
+ test: bibotProps.test
4371
4413
  }));
4372
4414
  };
4373
4415