bibot 1.0.45 → 1.0.51

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -3334,15 +3334,25 @@ function _finallyRethrows(body, finalizer) {
3334
3334
 
3335
3335
  var appStateEnums;
3336
3336
  (function (appStateEnums) {
3337
- appStateEnums["BIBOT"] = "BIBOT";
3337
+ appStateEnums["AI_FOLLOW_UPS"] = "AI_FOLLOW_UPS";
3338
+ appStateEnums["CHAT_BUBBLE_CONFIG"] = "CHAT_BUBBLE_CONFIG";
3339
+ appStateEnums["CHAT_BUBBLE_IS_OPENED"] = "CHAT_BUBBLE_IS_OPENED";
3340
+ appStateEnums["PRE_DEFINED_QUESTIONS"] = "PRE_DEFINED_QUESTIONS";
3338
3341
  })(appStateEnums || (appStateEnums = {}));
3339
3342
 
3340
3343
  var appReducer = function appReducer(state, action) {
3341
- console.log('This is the appReducer state', state, action);
3342
3344
  switch (action.type) {
3343
- case appStateEnums.BIBOT:
3345
+ case appStateEnums.PRE_DEFINED_QUESTIONS:
3344
3346
  return _extends({}, state, {
3345
- chatIsOpen: action.chatIsOpen
3347
+ pQuestions: action.pQuestions
3348
+ });
3349
+ case appStateEnums.CHAT_BUBBLE_CONFIG:
3350
+ return _extends({}, state, {
3351
+ chatBubbleConfig: action.chatBubbleConfig
3352
+ });
3353
+ case appStateEnums.AI_FOLLOW_UPS:
3354
+ return _extends({}, state, {
3355
+ aiFollowUpQs: action.aiFollowUp
3346
3356
  });
3347
3357
  default:
3348
3358
  return state;
@@ -3428,41 +3438,35 @@ var getSessionId = function getSessionId() {
3428
3438
  var dummyDispatch = function dummyDispatch() {};
3429
3439
  var defaultContextValue = {
3430
3440
  state: {
3431
- chatIsOpen: false,
3432
- sessionId: getSessionId()
3441
+ aiFollowUpQs: [],
3442
+ sessionId: getSessionId(),
3443
+ chatBubbleConfig: {
3444
+ bgColor: 'grey',
3445
+ color: 'dark',
3446
+ title: 'ChatBot Powered By BiBot',
3447
+ logo_url: 'https://bibot.app/static/media/bibot-high-resolution-logo-black-transparent.cf2e603c743f07663fd7.png'
3448
+ },
3449
+ pQuestions: []
3433
3450
  },
3434
3451
  dispatch: dummyDispatch
3435
3452
  };
3436
3453
  var AppContext = React.createContext(defaultContextValue);
3437
3454
  var AppProvider = function AppProvider(_ref) {
3438
3455
  var children = _ref.children;
3439
- var APP_STATE_KEY = 'app_states';
3440
3456
  var initialState = {
3441
- chatIsOpen: false,
3442
- sessionId: getSessionId()
3457
+ aiFollowUpQs: [],
3458
+ pQuestions: [],
3459
+ sessionId: getSessionId(),
3460
+ chatBubbleConfig: {
3461
+ bgColor: 'grey',
3462
+ color: 'dark',
3463
+ title: 'ChatBot Powered By BiBot',
3464
+ logo_url: 'https://bibot.app/static/media/bibot-high-resolution-logo-black-transparent.cf2e603c743f07663fd7.png'
3465
+ }
3443
3466
  };
3444
3467
  var _useReducer = React.useReducer(appReducer, initialState),
3445
3468
  state = _useReducer[0],
3446
3469
  dispatch = _useReducer[1];
3447
- React.useEffect(function () {
3448
- var storedStates = localStorage.getItem(APP_STATE_KEY);
3449
- if (storedStates) {
3450
- try {
3451
- var parsedStates = JSON.parse(storedStates);
3452
- var updatedStates = _extends({}, initialState, parsedStates);
3453
- console.log(initialState, parsedStates, updatedStates);
3454
- dispatch(_extends({
3455
- type: appStateEnums.BIBOT
3456
- }, updatedStates));
3457
- } catch (error) {
3458
- console.error('Failed to parse app states from local storage:', error);
3459
- }
3460
- }
3461
- }, []);
3462
- React.useEffect(function () {
3463
- console.log('Changes in state: ', state);
3464
- localStorage.setItem(APP_STATE_KEY, JSON.stringify(state));
3465
- }, [state]);
3466
3470
  return React__default.createElement(AppContext.Provider, {
3467
3471
  value: {
3468
3472
  state: state,
@@ -3506,7 +3510,6 @@ var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefi
3506
3510
  return Promise.resolve(pluginAxiosInstance.get(path, {
3507
3511
  params: params
3508
3512
  })).then(function (response) {
3509
- console.log(response.data.predefined_questions);
3510
3513
  return response.data.predefined_questions;
3511
3514
  });
3512
3515
  }, function () {
@@ -3524,10 +3527,10 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
3524
3527
  });
3525
3528
  }, function () {
3526
3529
  return {
3527
- bgColor: 'white',
3528
- chatColor: 'blue',
3529
- title: 'ChatBot',
3530
- userImage: 'string'
3530
+ bgColor: 'grey',
3531
+ color: 'dark',
3532
+ title: 'ChatBot Powered By BiBot',
3533
+ logo_url: 'https://bibot.app/static/media/bibot-high-resolution-logo-black-transparent.cf2e603c743f07663fd7.png'
3531
3534
  };
3532
3535
  }));
3533
3536
  } catch (e) {
@@ -3539,7 +3542,9 @@ var handleRetries = function handleRetries(pluginAxiosInstance, data, attempt) {
3539
3542
  var maxAttempts = 30;
3540
3543
  var delay = 10000;
3541
3544
  if (attempt >= maxAttempts) {
3542
- return Promise.resolve("Sorry this is taking longer than usual. Please try again later");
3545
+ return Promise.resolve({
3546
+ message: "Sorry this is taking longer than usual. Please try again later"
3547
+ });
3543
3548
  }
3544
3549
  return Promise.resolve(new Promise(function (resolve) {
3545
3550
  return setTimeout(resolve, delay);
@@ -3547,15 +3552,17 @@ var handleRetries = function handleRetries(pluginAxiosInstance, data, attempt) {
3547
3552
  return _catch(function () {
3548
3553
  return Promise.resolve(askTimedOutBiBot(pluginAxiosInstance, _extends({}, data, {
3549
3554
  tries: attempt + 1
3550
- }))).then(function (message) {
3551
- if (message === defaultSlacker) {
3555
+ }))).then(function (res) {
3556
+ if (res.message === defaultSlacker) {
3552
3557
  return Promise.resolve(handleRetries(pluginAxiosInstance, data, attempt + 1));
3553
3558
  } else {
3554
- return message;
3559
+ return res;
3555
3560
  }
3556
3561
  });
3557
3562
  }, function (error) {
3558
- return error.message;
3563
+ return {
3564
+ message: error.message
3565
+ };
3559
3566
  });
3560
3567
  });
3561
3568
  } catch (e) {
@@ -3570,12 +3577,10 @@ var askBiBot = function askBiBot(pluginAxiosInstance, data) {
3570
3577
  if (response.data.message === defaultSlacker) {
3571
3578
  return Promise.resolve(handleRetries(pluginAxiosInstance, data, 1));
3572
3579
  } else {
3573
- return response.data.message;
3580
+ return response.data;
3574
3581
  }
3575
3582
  });
3576
3583
  }, function (error1) {
3577
- console.log('This is the error1 from the endpoint on the 1st try:', error1);
3578
- console.log(error1.message);
3579
3584
  return error1.message;
3580
3585
  }));
3581
3586
  } catch (e) {
@@ -3586,13 +3591,10 @@ var recordPredefinedQ = function recordPredefinedQ(pluginAxiosInstance, data) {
3586
3591
  try {
3587
3592
  return Promise.resolve(_catch(function () {
3588
3593
  var path = "" + domain.inference + resources.predefinedQstatistics;
3589
- console.log(data, 'here');
3590
3594
  return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
3591
- console.log(response, 'here is the res');
3592
3595
  return response.data;
3593
3596
  });
3594
3597
  }, function (error) {
3595
- console.log(error.message);
3596
3598
  return error.message;
3597
3599
  }));
3598
3600
  } catch (e) {
@@ -3604,12 +3606,12 @@ var askTimedOutBiBot = function askTimedOutBiBot(pluginAxiosInstance, data) {
3604
3606
  return Promise.resolve(_catch(function () {
3605
3607
  var path = "" + domain.inference + resources.timeoutQ;
3606
3608
  return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
3607
- console.log(response);
3608
- return response.data.message;
3609
+ return response.data;
3609
3610
  });
3610
3611
  }, function (error) {
3611
- console.log(error.message);
3612
- return error.message;
3612
+ return {
3613
+ message: error.message
3614
+ };
3613
3615
  }));
3614
3616
  } catch (e) {
3615
3617
  return Promise.reject(e);
@@ -3617,7 +3619,7 @@ var askTimedOutBiBot = function askTimedOutBiBot(pluginAxiosInstance, data) {
3617
3619
  };
3618
3620
  var defaultSlacker = "BiBot_Retry_Later";
3619
3621
 
3620
- var useBiBotChatBot = function useBiBotChatBot(_ref) {
3622
+ var useBiBotChatBot = function useBiBotChatBot(bibotProps) {
3621
3623
  var sendInputInquiry = function sendInputInquiry() {
3622
3624
  try {
3623
3625
  setIsLoading(true);
@@ -3634,18 +3636,24 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3634
3636
  }]);
3635
3637
  });
3636
3638
  return Promise.resolve(askBiBot(pluginAxiosInstance, {
3637
- client_id: clientId,
3639
+ client_id: bibotProps.clientId,
3638
3640
  q: input,
3639
- session_id: client_session_id ? client_session_id : state.sessionId,
3641
+ session_id: bibotProps.client_session_id ? bibotProps.client_session_id : state.sessionId,
3640
3642
  chat_id: v4(),
3641
3643
  chat_history: messages
3642
3644
  })).then(function (response) {
3643
3645
  setMessages(function (messages) {
3644
3646
  return [].concat(messages, [{
3645
3647
  sender: 'bot',
3646
- text: response
3648
+ text: response.message
3647
3649
  }]);
3648
3650
  });
3651
+ if (response.aiFollowUp) {
3652
+ dispatch({
3653
+ type: appStateEnums.AI_FOLLOW_UPS,
3654
+ aiFollowUp: response.aiFollowUp
3655
+ });
3656
+ }
3649
3657
  });
3650
3658
  }
3651
3659
  }();
@@ -3663,106 +3671,73 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3663
3671
  return Promise.reject(e);
3664
3672
  }
3665
3673
  };
3666
- var askPredefinedQuestion = function askPredefinedQuestion(question, client_id) {
3674
+ var askPredefinedQuestion = function askPredefinedQuestion(question) {
3667
3675
  try {
3668
3676
  setIsLoading(true);
3669
3677
  var input = question.question.trim();
3670
- recordPredefinedQ(pluginAxiosInstance, {
3671
- "client_id": clientId,
3678
+ return Promise.resolve(recordPredefinedQ(pluginAxiosInstance, {
3679
+ "client_id": bibotProps.clientId,
3672
3680
  "question": question.question,
3673
3681
  "q_n_a_id": question.q_n_a_id
3674
- });
3675
- console.log(question.question, client_id, question.q_n_a_id);
3676
- setUserInput('');
3677
- if (input === question.question) {
3678
- setMessages(function (messages) {
3679
- return [].concat(messages, [{
3680
- sender: 'user',
3681
- text: input
3682
- }]);
3683
- });
3684
- setTimeout(function () {
3682
+ })).then(function (response) {
3683
+ setUserInput('');
3684
+ if (input === question.question) {
3685
+ setMessages(function (messages) {
3686
+ return [].concat(messages, [{
3687
+ sender: 'user',
3688
+ text: input
3689
+ }]);
3690
+ });
3685
3691
  setMessages(function (messages) {
3686
3692
  return [].concat(messages, [{
3687
3693
  sender: 'bot',
3688
- text: question.answer
3694
+ text: response.message ? response.message : question.answer
3689
3695
  }]);
3690
3696
  });
3697
+ if (response.aiFollowUp) {
3698
+ dispatch({
3699
+ type: appStateEnums.AI_FOLLOW_UPS,
3700
+ aiFollowUp: response.aiFollowUp
3701
+ });
3702
+ }
3691
3703
  setIsLoading(false);
3692
- }, 1000);
3693
- }
3694
- return Promise.resolve();
3704
+ }
3705
+ });
3695
3706
  } catch (e) {
3696
3707
  return Promise.reject(e);
3697
3708
  }
3698
3709
  };
3699
- var clientId = _ref.clientId,
3700
- client_session_id = _ref.client_session_id,
3701
- test = _ref.test;
3702
- var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
3703
- var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
3704
- var _useState = React.useState([]),
3705
- predefinedQuestions = _useState[0],
3706
- setPredefinedQuestions = _useState[1];
3707
- var _useState2 = React.useState(true),
3708
- showPredefinedQuestions = _useState2[0],
3709
- setShowPredefinedQuestions = _useState2[1];
3710
3710
  var _useContext = React.useContext(AppContext),
3711
- state = _useContext.state;
3712
- var _useState3 = React.useState(false),
3713
- chatIsOpen = _useState3[0],
3714
- setChatIsOpen = _useState3[1];
3715
- var _useState4 = React.useState([]),
3716
- messages = _useState4[0],
3717
- setMessages = _useState4[1];
3718
- var _useState5 = React.useState(''),
3719
- userInput = _useState5[0],
3720
- setUserInput = _useState5[1];
3721
- var _useState6 = React.useState(false),
3722
- isLoading = _useState6[0],
3723
- setIsLoading = _useState6[1];
3711
+ state = _useContext.state,
3712
+ dispatch = _useContext.dispatch;
3713
+ console.log('This is the value of test and bibotProps', bibotProps.test, bibotProps);
3714
+ var baseURL = bibotProps !== null && bibotProps !== void 0 && bibotProps.test ? endpoints.getInferenceURL(bibotProps === null || bibotProps === void 0 ? void 0 : bibotProps.test) : endpoints.getInferenceURL(false);
3715
+ var pluginAxiosInstance = createPluginAxiosInstance(baseURL, {}, {
3716
+ Authorization: bibotProps.jwt
3717
+ });
3718
+ var _useState = React.useState(true),
3719
+ showPredefinedQuestions = _useState[0],
3720
+ setShowPredefinedQuestions = _useState[1];
3721
+ var _useState2 = React.useState(false),
3722
+ chatIsOpen = _useState2[0],
3723
+ setChatIsOpen = _useState2[1];
3724
+ var _useState3 = React.useState([]),
3725
+ messages = _useState3[0],
3726
+ setMessages = _useState3[1];
3727
+ var _useState4 = React.useState(''),
3728
+ userInput = _useState4[0],
3729
+ setUserInput = _useState4[1];
3730
+ var _useState5 = React.useState(false),
3731
+ isLoading = _useState5[0],
3732
+ setIsLoading = _useState5[1];
3724
3733
  var messageEndRef = React.useRef(null);
3725
- var _useState7 = React.useState(),
3726
- chatBubbleConfig = _useState7[0],
3727
- setChatBubbleConfig = _useState7[1];
3728
3734
  var handlePredefinedQuestionSelect = function handlePredefinedQuestionSelect(question) {
3729
3735
  sendInputInquiry();
3730
- askPredefinedQuestion(question, clientId);
3736
+ askPredefinedQuestion(question);
3731
3737
  setUserInput('');
3732
3738
  setShowPredefinedQuestions(false);
3733
3739
  };
3734
- var getChatBubbleConfig = React.useCallback(function () {
3735
- try {
3736
- return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
3737
- client_id: clientId
3738
- })).then(function (remotePredefinedQuestions) {
3739
- if (remotePredefinedQuestions) {
3740
- setPredefinedQuestions(remotePredefinedQuestions);
3741
- }
3742
- return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
3743
- client_id: clientId
3744
- })).then(function (remoteChatBubbleConfig) {
3745
- if (remoteChatBubbleConfig) {
3746
- setChatBubbleConfig(remoteChatBubbleConfig);
3747
- }
3748
- });
3749
- });
3750
- } catch (e) {
3751
- return Promise.reject(e);
3752
- }
3753
- }, [clientId]);
3754
- React.useEffect(function () {
3755
- void getChatBubbleConfig();
3756
- }, [getChatBubbleConfig]);
3757
- React.useEffect(function () {
3758
- if (messageEndRef !== null && messageEndRef !== void 0 && messageEndRef.current) {
3759
- messageEndRef.current.scrollIntoView({
3760
- behavior: 'smooth'
3761
- });
3762
- }
3763
- }, [messages]);
3764
3740
  var toggleChat = function toggleChat() {
3765
- console.log('This is it', chatIsOpen);
3766
3741
  setChatIsOpen(!chatIsOpen);
3767
3742
  };
3768
3743
  var handleUserInput = function handleUserInput(e) {
@@ -3780,6 +3755,37 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3780
3755
  return Promise.reject(e);
3781
3756
  }
3782
3757
  };
3758
+ React.useEffect(function () {
3759
+ getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
3760
+ client_id: bibotProps.clientId
3761
+ }).then(function (remoteChatBubbleConfig) {
3762
+ if (remoteChatBubbleConfig) {
3763
+ dispatch({
3764
+ type: appStateEnums.CHAT_BUBBLE_CONFIG,
3765
+ chatBubbleConfig: remoteChatBubbleConfig
3766
+ });
3767
+ }
3768
+ });
3769
+ }, [bibotProps.clientId]);
3770
+ React.useEffect(function () {
3771
+ getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
3772
+ client_id: bibotProps.clientId
3773
+ }).then(function (remotePredefinedQuestions) {
3774
+ if (remotePredefinedQuestions) {
3775
+ dispatch({
3776
+ type: appStateEnums.PRE_DEFINED_QUESTIONS,
3777
+ pQuestions: remotePredefinedQuestions
3778
+ });
3779
+ }
3780
+ });
3781
+ }, [bibotProps.clientId]);
3782
+ React.useEffect(function () {
3783
+ if (messageEndRef !== null && messageEndRef !== void 0 && messageEndRef.current) {
3784
+ messageEndRef.current.scrollIntoView({
3785
+ behavior: 'smooth'
3786
+ });
3787
+ }
3788
+ }, [messages]);
3783
3789
  return {
3784
3790
  chatIsOpen: chatIsOpen,
3785
3791
  messages: messages,
@@ -3790,9 +3796,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
3790
3796
  handleKeyPress: handleKeyPress,
3791
3797
  toggleChat: toggleChat,
3792
3798
  sendInputInquiry: sendInputInquiry,
3793
- chatBubbleConfig: chatBubbleConfig,
3799
+ chatBubbleConfig: state.chatBubbleConfig,
3794
3800
  showPredefinedQuestions: showPredefinedQuestions,
3795
- predefinedQuestions: predefinedQuestions,
3801
+ predefinedQuestions: state.pQuestions,
3802
+ aiFollowUpQs: state.aiFollowUpQs,
3796
3803
  handlePredefinedQuestionSelect: handlePredefinedQuestionSelect
3797
3804
  };
3798
3805
  };
@@ -3807,11 +3814,11 @@ function SendMessageIcon(_ref) {
3807
3814
  width: '24',
3808
3815
  height: '24',
3809
3816
  viewBox: '0 0 24 24',
3810
- "stroke-width": '1.5',
3817
+ strokeWidth: '1.5',
3811
3818
  stroke: color,
3812
3819
  fill: 'none',
3813
- "stroke-linecap": 'round',
3814
- "stroke-linejoin": 'round'
3820
+ strokeLinecap: 'round',
3821
+ strokeLinejoin: 'round'
3815
3822
  }, React__default.createElement("path", {
3816
3823
  stroke: 'none',
3817
3824
  d: 'M0 0h24v24H0z',
@@ -3829,11 +3836,11 @@ function DefaultBotProfile() {
3829
3836
  width: '24',
3830
3837
  height: '24',
3831
3838
  viewBox: '0 0 24 24',
3832
- "stroke-width": '1.5',
3839
+ strokeWidth: '1.5',
3833
3840
  stroke: '#fff',
3834
3841
  fill: 'none',
3835
- "stroke-linecap": 'round',
3836
- "stroke-linejoin": 'round'
3842
+ strokeLinecap: 'round',
3843
+ strokeLinejoin: 'round'
3837
3844
  }, React__default.createElement("path", {
3838
3845
  stroke: 'none',
3839
3846
  d: 'M0 0h24v24H0z',
@@ -3859,11 +3866,11 @@ function ChatIcon() {
3859
3866
  width: '40',
3860
3867
  height: '40',
3861
3868
  viewBox: '0 0 24 24',
3862
- "stroke-width": '1.5',
3869
+ strokeWidth: '1.5',
3863
3870
  stroke: '#fff',
3864
3871
  fill: 'none',
3865
- "stroke-linecap": 'round',
3866
- "stroke-linejoin": 'round'
3872
+ strokeLinecap: 'round',
3873
+ strokeLinejoin: 'round'
3867
3874
  }, React__default.createElement("path", {
3868
3875
  stroke: 'none',
3869
3876
  d: 'M0 0h24v24H0z',
@@ -3885,11 +3892,11 @@ function CloseIcon() {
3885
3892
  width: "40",
3886
3893
  height: "40",
3887
3894
  viewBox: "0 0 24 24",
3888
- "stroke-width": "1.5",
3895
+ strokeWidth: "1.5",
3889
3896
  stroke: "#fff",
3890
3897
  fill: "none",
3891
- "stroke-linecap": "round",
3892
- "stroke-linejoin": "round"
3898
+ strokeLinecap: "round",
3899
+ strokeLinejoin: "round"
3893
3900
  }, React__default.createElement("path", {
3894
3901
  stroke: "none",
3895
3902
  d: "M0 0h24v24H0z",
@@ -4088,13 +4095,7 @@ var Loader = function Loader() {
4088
4095
  var PredefinedQuestions = function PredefinedQuestions(_ref) {
4089
4096
  var questions = _ref.questions,
4090
4097
  onSelect = _ref.onSelect,
4091
- clientId = _ref.clientId,
4092
- test = _ref.test;
4093
- var _useBiBotChatBot = useBiBotChatBot({
4094
- clientId: clientId,
4095
- test: test
4096
- }),
4097
- chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
4098
+ chatBubbleConfig = _ref.chatBubbleConfig;
4098
4099
  return React.createElement("div", {
4099
4100
  style: {
4100
4101
  height: '100%',
@@ -4121,7 +4122,7 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
4121
4122
  style: {
4122
4123
  marginBlock: '0.5px'
4123
4124
  }
4124
- }, "Welcome!"), React.createElement("p", {
4125
+ }, chatBubbleConfig !== null && chatBubbleConfig !== void 0 && chatBubbleConfig.knownUser ? "Hello " + chatBubbleConfig.knownUser : 'Welcome!'), React.createElement("p", {
4125
4126
  style: {
4126
4127
  fontSize: '14px'
4127
4128
  }
@@ -4145,31 +4146,58 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
4145
4146
  }, question.question);
4146
4147
  }));
4147
4148
  };
4148
- var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4149
- var _chatBubbleConfig$col2, _chatBubbleConfig$col3;
4150
- var clientId = _ref2.clientId,
4151
- client_session_id = _ref2.client_session_id,
4152
- redirect_notice = _ref2.redirect_notice,
4153
- test = _ref2.test;
4154
- var _useBiBotChatBot2 = useBiBotChatBot({
4155
- clientId: clientId,
4156
- client_session_id: client_session_id,
4157
- redirect_notice: redirect_notice,
4158
- test: test
4159
- }),
4160
- chatIsOpen = _useBiBotChatBot2.chatIsOpen,
4161
- messages = _useBiBotChatBot2.messages,
4162
- isLoading = _useBiBotChatBot2.isLoading,
4163
- messageEndRef = _useBiBotChatBot2.messageEndRef,
4164
- userInput = _useBiBotChatBot2.userInput,
4165
- handleUserInput = _useBiBotChatBot2.handleUserInput,
4166
- handleKeyPress = _useBiBotChatBot2.handleKeyPress,
4167
- sendInputInquiry = _useBiBotChatBot2.sendInputInquiry,
4168
- toggleChat = _useBiBotChatBot2.toggleChat,
4169
- chatBubbleConfig = _useBiBotChatBot2.chatBubbleConfig,
4170
- showPredefinedQuestions = _useBiBotChatBot2.showPredefinedQuestions,
4171
- predefinedQuestions = _useBiBotChatBot2.predefinedQuestions,
4172
- handlePredefinedQuestionSelect = _useBiBotChatBot2.handlePredefinedQuestionSelect;
4149
+
4150
+ var AiFollowUps = function AiFollowUps(_ref) {
4151
+ var questions = _ref.questions,
4152
+ onSelect = _ref.onSelect,
4153
+ chatBubbleConfig = _ref.chatBubbleConfig;
4154
+ return React.createElement("div", {
4155
+ style: {
4156
+ height: '100%',
4157
+ color: '#000',
4158
+ backgroundColor: '#fff',
4159
+ padding: 10,
4160
+ borderRadius: '6px',
4161
+ marginBottom: '20px'
4162
+ }
4163
+ }, questions.map(function (question, index) {
4164
+ var _chatBubbleConfig$col;
4165
+ return React.createElement("div", {
4166
+ key: index,
4167
+ style: {
4168
+ backgroundColor: 'transparent',
4169
+ border: "0.5px solid " + (chatBubbleConfig ? (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede' : '#000'),
4170
+ fontSize: '16px',
4171
+ margin: '7px',
4172
+ textAlign: 'start',
4173
+ padding: '10px',
4174
+ borderRadius: '6px',
4175
+ cursor: 'pointer'
4176
+ },
4177
+ onClick: function onClick() {
4178
+ onSelect(question);
4179
+ }
4180
+ }, question.question);
4181
+ }));
4182
+ };
4183
+
4184
+ var ChatBubbleBiBot = function ChatBubbleBiBot(bibotProps) {
4185
+ var _chatBubbleConfig$col, _chatBubbleConfig$col2;
4186
+ var _useBiBotChatBot = useBiBotChatBot(bibotProps),
4187
+ chatIsOpen = _useBiBotChatBot.chatIsOpen,
4188
+ messages = _useBiBotChatBot.messages,
4189
+ isLoading = _useBiBotChatBot.isLoading,
4190
+ messageEndRef = _useBiBotChatBot.messageEndRef,
4191
+ userInput = _useBiBotChatBot.userInput,
4192
+ handleUserInput = _useBiBotChatBot.handleUserInput,
4193
+ handleKeyPress = _useBiBotChatBot.handleKeyPress,
4194
+ sendInputInquiry = _useBiBotChatBot.sendInputInquiry,
4195
+ toggleChat = _useBiBotChatBot.toggleChat,
4196
+ chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig,
4197
+ showPredefinedQuestions = _useBiBotChatBot.showPredefinedQuestions,
4198
+ predefinedQuestions = _useBiBotChatBot.predefinedQuestions,
4199
+ aiFollowUpQs = _useBiBotChatBot.aiFollowUpQs,
4200
+ handlePredefinedQuestionSelect = _useBiBotChatBot.handlePredefinedQuestionSelect;
4173
4201
  var isOnline = useOnlineStatus();
4174
4202
  return React.createElement("div", {
4175
4203
  className: "chat-bubble " + (chatIsOpen ? 'open' : ''),
@@ -4197,7 +4225,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4197
4225
  }, React.createElement("div", {
4198
4226
  className: styles['chat-header'],
4199
4227
  style: {
4200
- backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
4228
+ backgroundColor: (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede',
4201
4229
  height: 50,
4202
4230
  borderTopLeftRadius: 8,
4203
4231
  borderTopRightRadius: 8,
@@ -4257,7 +4285,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4257
4285
  }, showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && React.createElement(PredefinedQuestions, {
4258
4286
  questions: predefinedQuestions.slice(0, 3),
4259
4287
  onSelect: handlePredefinedQuestionSelect,
4260
- clientId: clientId
4288
+ chatBubbleConfig: chatBubbleConfig
4261
4289
  }), messages.map(function (message, index) {
4262
4290
  return message.sender === 'user' ? React.createElement("div", {
4263
4291
  key: index,
@@ -4297,6 +4325,10 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4297
4325
  textAlign: 'left'
4298
4326
  }
4299
4327
  }, message.text));
4328
+ }), aiFollowUpQs && !isLoading && React.createElement(AiFollowUps, {
4329
+ questions: aiFollowUpQs,
4330
+ onSelect: handlePredefinedQuestionSelect,
4331
+ chatBubbleConfig: chatBubbleConfig
4300
4332
  }), isLoading && React.createElement("div", {
4301
4333
  style: {
4302
4334
  marginLeft: '20px'
@@ -4348,7 +4380,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4348
4380
  onClick: toggleChat,
4349
4381
  className: styles['chat-toggle'],
4350
4382
  style: {
4351
- backgroundColor: (_chatBubbleConfig$col3 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col3 : '#dedede',
4383
+ backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
4352
4384
  color: '#fff',
4353
4385
  borderRadius: '50%',
4354
4386
  cursor: 'pointer',
@@ -4362,16 +4394,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
4362
4394
  }, chatIsOpen ? React.createElement(CloseIcon, null) : React.createElement(ChatIcon, null)));
4363
4395
  };
4364
4396
 
4365
- var BiBot = function BiBot(_ref) {
4366
- var clientId = _ref.clientId,
4367
- client_session_id = _ref.client_session_id,
4368
- redirect_notice = _ref.redirect_notice,
4369
- test = _ref.test;
4397
+ var BiBot = function BiBot(bibotProps) {
4370
4398
  return React.createElement(AppProvider, null, React.createElement(ChatBubbleBiBot, {
4371
- clientId: clientId,
4372
- client_session_id: client_session_id,
4373
- redirect_notice: redirect_notice,
4374
- test: test
4399
+ jwt: bibotProps.jwt,
4400
+ clientId: bibotProps.clientId,
4401
+ client_session_id: bibotProps.client_session_id,
4402
+ redirect_notice: bibotProps.redirect_notice,
4403
+ test: bibotProps.test
4375
4404
  }));
4376
4405
  };
4377
4406