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/component/aiFollowUps.d.ts +4 -0
- package/dist/component/bibot.d.ts +1 -1
- package/dist/component/predefinedQuestions.d.ts +4 -0
- package/dist/config/appStateEnums.d.ts +4 -1
- package/dist/hooks/useBiBotChatBot.d.ts +6 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +217 -188
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +218 -189
- package/dist/index.modern.js.map +1 -1
- package/dist/services/plugin-api.d.ts +4 -4
- package/dist/types/coreInterfaces.d.ts +23 -15
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React__default, { createContext, useReducer,
|
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["
|
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.
|
3342
|
+
case appStateEnums.PRE_DEFINED_QUESTIONS:
|
3341
3343
|
return _extends({}, state, {
|
3342
|
-
|
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
|
-
|
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
|
-
|
3439
|
-
|
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: '
|
3525
|
-
|
3526
|
-
title: 'ChatBot',
|
3527
|
-
|
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(
|
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 (
|
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
|
3556
|
+
return res;
|
3552
3557
|
}
|
3553
3558
|
});
|
3554
3559
|
}, function (error) {
|
3555
|
-
return
|
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
|
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
|
-
|
3605
|
-
return response.data.message;
|
3606
|
+
return response.data;
|
3606
3607
|
});
|
3607
3608
|
}, function (error) {
|
3608
|
-
|
3609
|
-
|
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(
|
3619
|
+
var useBiBotChatBot = function useBiBotChatBot(bibotProps) {
|
3618
3620
|
var sendInputInquiry = function sendInputInquiry() {
|
3619
3621
|
try {
|
3620
3622
|
setIsLoading(true);
|
@@ -3631,18 +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,
|
3638
|
+
session_id: bibotProps.client_session_id ? bibotProps.client_session_id : state.sessionId,
|
3637
3639
|
chat_id: v4(),
|
3638
3640
|
chat_history: messages
|
3639
3641
|
})).then(function (response) {
|
3640
3642
|
setMessages(function (messages) {
|
3641
3643
|
return [].concat(messages, [{
|
3642
3644
|
sender: 'bot',
|
3643
|
-
text: response
|
3645
|
+
text: response.message
|
3644
3646
|
}]);
|
3645
3647
|
});
|
3648
|
+
if (response.aiFollowUp) {
|
3649
|
+
dispatch({
|
3650
|
+
type: appStateEnums.AI_FOLLOW_UPS,
|
3651
|
+
aiFollowUp: response.aiFollowUp
|
3652
|
+
});
|
3653
|
+
}
|
3646
3654
|
});
|
3647
3655
|
}
|
3648
3656
|
}();
|
@@ -3660,106 +3668,73 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3660
3668
|
return Promise.reject(e);
|
3661
3669
|
}
|
3662
3670
|
};
|
3663
|
-
var askPredefinedQuestion = function askPredefinedQuestion(question
|
3671
|
+
var askPredefinedQuestion = function askPredefinedQuestion(question) {
|
3664
3672
|
try {
|
3665
3673
|
setIsLoading(true);
|
3666
3674
|
var input = question.question.trim();
|
3667
|
-
recordPredefinedQ(pluginAxiosInstance, {
|
3668
|
-
"client_id": clientId,
|
3675
|
+
return Promise.resolve(recordPredefinedQ(pluginAxiosInstance, {
|
3676
|
+
"client_id": bibotProps.clientId,
|
3669
3677
|
"question": question.question,
|
3670
3678
|
"q_n_a_id": question.q_n_a_id
|
3671
|
-
})
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
}
|
3680
|
-
});
|
3681
|
-
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
|
+
});
|
3682
3688
|
setMessages(function (messages) {
|
3683
3689
|
return [].concat(messages, [{
|
3684
3690
|
sender: 'bot',
|
3685
|
-
text: question.answer
|
3691
|
+
text: response.message ? response.message : question.answer
|
3686
3692
|
}]);
|
3687
3693
|
});
|
3694
|
+
if (response.aiFollowUp) {
|
3695
|
+
dispatch({
|
3696
|
+
type: appStateEnums.AI_FOLLOW_UPS,
|
3697
|
+
aiFollowUp: response.aiFollowUp
|
3698
|
+
});
|
3699
|
+
}
|
3688
3700
|
setIsLoading(false);
|
3689
|
-
}
|
3690
|
-
}
|
3691
|
-
return Promise.resolve();
|
3701
|
+
}
|
3702
|
+
});
|
3692
3703
|
} catch (e) {
|
3693
3704
|
return Promise.reject(e);
|
3694
3705
|
}
|
3695
3706
|
};
|
3696
|
-
var clientId = _ref.clientId,
|
3697
|
-
client_session_id = _ref.client_session_id,
|
3698
|
-
test = _ref.test;
|
3699
|
-
var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
|
3700
|
-
var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
|
3701
|
-
var _useState = useState([]),
|
3702
|
-
predefinedQuestions = _useState[0],
|
3703
|
-
setPredefinedQuestions = _useState[1];
|
3704
|
-
var _useState2 = useState(true),
|
3705
|
-
showPredefinedQuestions = _useState2[0],
|
3706
|
-
setShowPredefinedQuestions = _useState2[1];
|
3707
3707
|
var _useContext = useContext(AppContext),
|
3708
|
-
state = _useContext.state
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
var
|
3713
|
-
|
3714
|
-
|
3715
|
-
var
|
3716
|
-
|
3717
|
-
|
3718
|
-
var
|
3719
|
-
|
3720
|
-
|
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];
|
3721
3730
|
var messageEndRef = useRef(null);
|
3722
|
-
var _useState7 = useState(),
|
3723
|
-
chatBubbleConfig = _useState7[0],
|
3724
|
-
setChatBubbleConfig = _useState7[1];
|
3725
3731
|
var handlePredefinedQuestionSelect = function handlePredefinedQuestionSelect(question) {
|
3726
3732
|
sendInputInquiry();
|
3727
|
-
askPredefinedQuestion(question
|
3733
|
+
askPredefinedQuestion(question);
|
3728
3734
|
setUserInput('');
|
3729
3735
|
setShowPredefinedQuestions(false);
|
3730
3736
|
};
|
3731
|
-
var getChatBubbleConfig = useCallback(function () {
|
3732
|
-
try {
|
3733
|
-
return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
|
3734
|
-
client_id: clientId
|
3735
|
-
})).then(function (remotePredefinedQuestions) {
|
3736
|
-
if (remotePredefinedQuestions) {
|
3737
|
-
setPredefinedQuestions(remotePredefinedQuestions);
|
3738
|
-
}
|
3739
|
-
return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
|
3740
|
-
client_id: clientId
|
3741
|
-
})).then(function (remoteChatBubbleConfig) {
|
3742
|
-
if (remoteChatBubbleConfig) {
|
3743
|
-
setChatBubbleConfig(remoteChatBubbleConfig);
|
3744
|
-
}
|
3745
|
-
});
|
3746
|
-
});
|
3747
|
-
} catch (e) {
|
3748
|
-
return Promise.reject(e);
|
3749
|
-
}
|
3750
|
-
}, [clientId]);
|
3751
|
-
useEffect(function () {
|
3752
|
-
void getChatBubbleConfig();
|
3753
|
-
}, [getChatBubbleConfig]);
|
3754
|
-
useEffect(function () {
|
3755
|
-
if (messageEndRef !== null && messageEndRef !== void 0 && messageEndRef.current) {
|
3756
|
-
messageEndRef.current.scrollIntoView({
|
3757
|
-
behavior: 'smooth'
|
3758
|
-
});
|
3759
|
-
}
|
3760
|
-
}, [messages]);
|
3761
3737
|
var toggleChat = function toggleChat() {
|
3762
|
-
console.log('This is it', chatIsOpen);
|
3763
3738
|
setChatIsOpen(!chatIsOpen);
|
3764
3739
|
};
|
3765
3740
|
var handleUserInput = function handleUserInput(e) {
|
@@ -3777,6 +3752,37 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3777
3752
|
return Promise.reject(e);
|
3778
3753
|
}
|
3779
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]);
|
3780
3786
|
return {
|
3781
3787
|
chatIsOpen: chatIsOpen,
|
3782
3788
|
messages: messages,
|
@@ -3787,9 +3793,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3787
3793
|
handleKeyPress: handleKeyPress,
|
3788
3794
|
toggleChat: toggleChat,
|
3789
3795
|
sendInputInquiry: sendInputInquiry,
|
3790
|
-
chatBubbleConfig: chatBubbleConfig,
|
3796
|
+
chatBubbleConfig: state.chatBubbleConfig,
|
3791
3797
|
showPredefinedQuestions: showPredefinedQuestions,
|
3792
|
-
predefinedQuestions:
|
3798
|
+
predefinedQuestions: state.pQuestions,
|
3799
|
+
aiFollowUpQs: state.aiFollowUpQs,
|
3793
3800
|
handlePredefinedQuestionSelect: handlePredefinedQuestionSelect
|
3794
3801
|
};
|
3795
3802
|
};
|
@@ -3804,11 +3811,11 @@ function SendMessageIcon(_ref) {
|
|
3804
3811
|
width: '24',
|
3805
3812
|
height: '24',
|
3806
3813
|
viewBox: '0 0 24 24',
|
3807
|
-
|
3814
|
+
strokeWidth: '1.5',
|
3808
3815
|
stroke: color,
|
3809
3816
|
fill: 'none',
|
3810
|
-
|
3811
|
-
|
3817
|
+
strokeLinecap: 'round',
|
3818
|
+
strokeLinejoin: 'round'
|
3812
3819
|
}, React__default.createElement("path", {
|
3813
3820
|
stroke: 'none',
|
3814
3821
|
d: 'M0 0h24v24H0z',
|
@@ -3826,11 +3833,11 @@ function DefaultBotProfile() {
|
|
3826
3833
|
width: '24',
|
3827
3834
|
height: '24',
|
3828
3835
|
viewBox: '0 0 24 24',
|
3829
|
-
|
3836
|
+
strokeWidth: '1.5',
|
3830
3837
|
stroke: '#fff',
|
3831
3838
|
fill: 'none',
|
3832
|
-
|
3833
|
-
|
3839
|
+
strokeLinecap: 'round',
|
3840
|
+
strokeLinejoin: 'round'
|
3834
3841
|
}, React__default.createElement("path", {
|
3835
3842
|
stroke: 'none',
|
3836
3843
|
d: 'M0 0h24v24H0z',
|
@@ -3856,11 +3863,11 @@ function ChatIcon() {
|
|
3856
3863
|
width: '40',
|
3857
3864
|
height: '40',
|
3858
3865
|
viewBox: '0 0 24 24',
|
3859
|
-
|
3866
|
+
strokeWidth: '1.5',
|
3860
3867
|
stroke: '#fff',
|
3861
3868
|
fill: 'none',
|
3862
|
-
|
3863
|
-
|
3869
|
+
strokeLinecap: 'round',
|
3870
|
+
strokeLinejoin: 'round'
|
3864
3871
|
}, React__default.createElement("path", {
|
3865
3872
|
stroke: 'none',
|
3866
3873
|
d: 'M0 0h24v24H0z',
|
@@ -3882,11 +3889,11 @@ function CloseIcon() {
|
|
3882
3889
|
width: "40",
|
3883
3890
|
height: "40",
|
3884
3891
|
viewBox: "0 0 24 24",
|
3885
|
-
|
3892
|
+
strokeWidth: "1.5",
|
3886
3893
|
stroke: "#fff",
|
3887
3894
|
fill: "none",
|
3888
|
-
|
3889
|
-
|
3895
|
+
strokeLinecap: "round",
|
3896
|
+
strokeLinejoin: "round"
|
3890
3897
|
}, React__default.createElement("path", {
|
3891
3898
|
stroke: "none",
|
3892
3899
|
d: "M0 0h24v24H0z",
|
@@ -4085,13 +4092,7 @@ var Loader = function Loader() {
|
|
4085
4092
|
var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
4086
4093
|
var questions = _ref.questions,
|
4087
4094
|
onSelect = _ref.onSelect,
|
4088
|
-
|
4089
|
-
test = _ref.test;
|
4090
|
-
var _useBiBotChatBot = useBiBotChatBot({
|
4091
|
-
clientId: clientId,
|
4092
|
-
test: test
|
4093
|
-
}),
|
4094
|
-
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
|
4095
|
+
chatBubbleConfig = _ref.chatBubbleConfig;
|
4095
4096
|
return createElement("div", {
|
4096
4097
|
style: {
|
4097
4098
|
height: '100%',
|
@@ -4118,7 +4119,7 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
|
4118
4119
|
style: {
|
4119
4120
|
marginBlock: '0.5px'
|
4120
4121
|
}
|
4121
|
-
}, "Welcome!
|
4122
|
+
}, chatBubbleConfig !== null && chatBubbleConfig !== void 0 && chatBubbleConfig.knownUser ? "Hello " + chatBubbleConfig.knownUser : 'Welcome!'), createElement("p", {
|
4122
4123
|
style: {
|
4123
4124
|
fontSize: '14px'
|
4124
4125
|
}
|
@@ -4142,31 +4143,58 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
|
4142
4143
|
}, question.question);
|
4143
4144
|
}));
|
4144
4145
|
};
|
4145
|
-
|
4146
|
-
|
4147
|
-
var
|
4148
|
-
|
4149
|
-
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
|
4154
|
-
|
4155
|
-
|
4156
|
-
|
4157
|
-
|
4158
|
-
|
4159
|
-
|
4160
|
-
|
4161
|
-
|
4162
|
-
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4169
|
-
|
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
|
+
}, questions.map(function (question, index) {
|
4161
|
+
var _chatBubbleConfig$col;
|
4162
|
+
return createElement("div", {
|
4163
|
+
key: index,
|
4164
|
+
style: {
|
4165
|
+
backgroundColor: 'transparent',
|
4166
|
+
border: "0.5px solid " + (chatBubbleConfig ? (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede' : '#000'),
|
4167
|
+
fontSize: '16px',
|
4168
|
+
margin: '7px',
|
4169
|
+
textAlign: 'start',
|
4170
|
+
padding: '10px',
|
4171
|
+
borderRadius: '6px',
|
4172
|
+
cursor: 'pointer'
|
4173
|
+
},
|
4174
|
+
onClick: function onClick() {
|
4175
|
+
onSelect(question);
|
4176
|
+
}
|
4177
|
+
}, question.question);
|
4178
|
+
}));
|
4179
|
+
};
|
4180
|
+
|
4181
|
+
var ChatBubbleBiBot = function ChatBubbleBiBot(bibotProps) {
|
4182
|
+
var _chatBubbleConfig$col, _chatBubbleConfig$col2;
|
4183
|
+
var _useBiBotChatBot = useBiBotChatBot(bibotProps),
|
4184
|
+
chatIsOpen = _useBiBotChatBot.chatIsOpen,
|
4185
|
+
messages = _useBiBotChatBot.messages,
|
4186
|
+
isLoading = _useBiBotChatBot.isLoading,
|
4187
|
+
messageEndRef = _useBiBotChatBot.messageEndRef,
|
4188
|
+
userInput = _useBiBotChatBot.userInput,
|
4189
|
+
handleUserInput = _useBiBotChatBot.handleUserInput,
|
4190
|
+
handleKeyPress = _useBiBotChatBot.handleKeyPress,
|
4191
|
+
sendInputInquiry = _useBiBotChatBot.sendInputInquiry,
|
4192
|
+
toggleChat = _useBiBotChatBot.toggleChat,
|
4193
|
+
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig,
|
4194
|
+
showPredefinedQuestions = _useBiBotChatBot.showPredefinedQuestions,
|
4195
|
+
predefinedQuestions = _useBiBotChatBot.predefinedQuestions,
|
4196
|
+
aiFollowUpQs = _useBiBotChatBot.aiFollowUpQs,
|
4197
|
+
handlePredefinedQuestionSelect = _useBiBotChatBot.handlePredefinedQuestionSelect;
|
4170
4198
|
var isOnline = useOnlineStatus();
|
4171
4199
|
return createElement("div", {
|
4172
4200
|
className: "chat-bubble " + (chatIsOpen ? 'open' : ''),
|
@@ -4194,7 +4222,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4194
4222
|
}, createElement("div", {
|
4195
4223
|
className: styles['chat-header'],
|
4196
4224
|
style: {
|
4197
|
-
backgroundColor: (_chatBubbleConfig$
|
4225
|
+
backgroundColor: (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede',
|
4198
4226
|
height: 50,
|
4199
4227
|
borderTopLeftRadius: 8,
|
4200
4228
|
borderTopRightRadius: 8,
|
@@ -4254,7 +4282,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4254
4282
|
}, showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && createElement(PredefinedQuestions, {
|
4255
4283
|
questions: predefinedQuestions.slice(0, 3),
|
4256
4284
|
onSelect: handlePredefinedQuestionSelect,
|
4257
|
-
|
4285
|
+
chatBubbleConfig: chatBubbleConfig
|
4258
4286
|
}), messages.map(function (message, index) {
|
4259
4287
|
return message.sender === 'user' ? createElement("div", {
|
4260
4288
|
key: index,
|
@@ -4294,6 +4322,10 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4294
4322
|
textAlign: 'left'
|
4295
4323
|
}
|
4296
4324
|
}, message.text));
|
4325
|
+
}), aiFollowUpQs && !isLoading && createElement(AiFollowUps, {
|
4326
|
+
questions: aiFollowUpQs,
|
4327
|
+
onSelect: handlePredefinedQuestionSelect,
|
4328
|
+
chatBubbleConfig: chatBubbleConfig
|
4297
4329
|
}), isLoading && createElement("div", {
|
4298
4330
|
style: {
|
4299
4331
|
marginLeft: '20px'
|
@@ -4345,7 +4377,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4345
4377
|
onClick: toggleChat,
|
4346
4378
|
className: styles['chat-toggle'],
|
4347
4379
|
style: {
|
4348
|
-
backgroundColor: (_chatBubbleConfig$
|
4380
|
+
backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
|
4349
4381
|
color: '#fff',
|
4350
4382
|
borderRadius: '50%',
|
4351
4383
|
cursor: 'pointer',
|
@@ -4359,16 +4391,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4359
4391
|
}, chatIsOpen ? createElement(CloseIcon, null) : createElement(ChatIcon, null)));
|
4360
4392
|
};
|
4361
4393
|
|
4362
|
-
var BiBot = function BiBot(
|
4363
|
-
var clientId = _ref.clientId,
|
4364
|
-
client_session_id = _ref.client_session_id,
|
4365
|
-
redirect_notice = _ref.redirect_notice,
|
4366
|
-
test = _ref.test;
|
4394
|
+
var BiBot = function BiBot(bibotProps) {
|
4367
4395
|
return createElement(AppProvider, null, createElement(ChatBubbleBiBot, {
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4396
|
+
jwt: bibotProps.jwt,
|
4397
|
+
clientId: bibotProps.clientId,
|
4398
|
+
client_session_id: bibotProps.client_session_id,
|
4399
|
+
redirect_notice: bibotProps.redirect_notice,
|
4400
|
+
test: bibotProps.test
|
4372
4401
|
}));
|
4373
4402
|
};
|
4374
4403
|
|