bibot 1.0.42 → 1.0.50
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 +7 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +231 -189
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +232 -190
- package/dist/index.modern.js.map +1 -1
- package/dist/services/plugin-api.d.ts +4 -4
- package/dist/types/coreInterfaces.d.ts +29 -15
- package/package.json +1 -1
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["
|
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.
|
3345
|
+
case appStateEnums.PRE_DEFINED_QUESTIONS:
|
3344
3346
|
return _extends({}, state, {
|
3345
|
-
|
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
|
-
|
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
|
-
|
3442
|
-
|
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: '
|
3528
|
-
|
3529
|
-
title: 'ChatBot',
|
3530
|
-
|
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(
|
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 (
|
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
|
3559
|
+
return res;
|
3555
3560
|
}
|
3556
3561
|
});
|
3557
3562
|
}, function (error) {
|
3558
|
-
return
|
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
|
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
|
-
|
3608
|
-
return response.data.message;
|
3609
|
+
return response.data;
|
3609
3610
|
});
|
3610
3611
|
}, function (error) {
|
3611
|
-
|
3612
|
-
|
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(
|
3622
|
+
var useBiBotChatBot = function useBiBotChatBot(bibotProps) {
|
3621
3623
|
var sendInputInquiry = function sendInputInquiry() {
|
3622
3624
|
try {
|
3623
3625
|
setIsLoading(true);
|
@@ -3634,17 +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,
|
3640
|
-
chat_id: v4()
|
3641
|
+
session_id: bibotProps.client_session_id ? bibotProps.client_session_id : state.sessionId,
|
3642
|
+
chat_id: v4(),
|
3643
|
+
chat_history: messages
|
3641
3644
|
})).then(function (response) {
|
3642
3645
|
setMessages(function (messages) {
|
3643
3646
|
return [].concat(messages, [{
|
3644
3647
|
sender: 'bot',
|
3645
|
-
text: response
|
3648
|
+
text: response.message
|
3646
3649
|
}]);
|
3647
3650
|
});
|
3651
|
+
if (response.aiFollowUp) {
|
3652
|
+
dispatch({
|
3653
|
+
type: appStateEnums.AI_FOLLOW_UPS,
|
3654
|
+
aiFollowUp: response.aiFollowUp
|
3655
|
+
});
|
3656
|
+
}
|
3648
3657
|
});
|
3649
3658
|
}
|
3650
3659
|
}();
|
@@ -3662,106 +3671,73 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3662
3671
|
return Promise.reject(e);
|
3663
3672
|
}
|
3664
3673
|
};
|
3665
|
-
var askPredefinedQuestion = function askPredefinedQuestion(question
|
3674
|
+
var askPredefinedQuestion = function askPredefinedQuestion(question) {
|
3666
3675
|
try {
|
3667
3676
|
setIsLoading(true);
|
3668
3677
|
var input = question.question.trim();
|
3669
|
-
recordPredefinedQ(pluginAxiosInstance, {
|
3670
|
-
"client_id": clientId,
|
3678
|
+
return Promise.resolve(recordPredefinedQ(pluginAxiosInstance, {
|
3679
|
+
"client_id": bibotProps.clientId,
|
3671
3680
|
"question": question.question,
|
3672
3681
|
"q_n_a_id": question.q_n_a_id
|
3673
|
-
})
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
}
|
3682
|
-
});
|
3683
|
-
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
|
+
});
|
3684
3691
|
setMessages(function (messages) {
|
3685
3692
|
return [].concat(messages, [{
|
3686
3693
|
sender: 'bot',
|
3687
|
-
text: question.answer
|
3694
|
+
text: response.message ? response.message : question.answer
|
3688
3695
|
}]);
|
3689
3696
|
});
|
3697
|
+
if (response.aiFollowUp) {
|
3698
|
+
dispatch({
|
3699
|
+
type: appStateEnums.AI_FOLLOW_UPS,
|
3700
|
+
aiFollowUp: response.aiFollowUp
|
3701
|
+
});
|
3702
|
+
}
|
3690
3703
|
setIsLoading(false);
|
3691
|
-
}
|
3692
|
-
}
|
3693
|
-
return Promise.resolve();
|
3704
|
+
}
|
3705
|
+
});
|
3694
3706
|
} catch (e) {
|
3695
3707
|
return Promise.reject(e);
|
3696
3708
|
}
|
3697
3709
|
};
|
3698
|
-
var clientId = _ref.clientId,
|
3699
|
-
client_session_id = _ref.client_session_id,
|
3700
|
-
test = _ref.test;
|
3701
|
-
var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
|
3702
|
-
var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
|
3703
|
-
var _useState = React.useState([]),
|
3704
|
-
predefinedQuestions = _useState[0],
|
3705
|
-
setPredefinedQuestions = _useState[1];
|
3706
|
-
var _useState2 = React.useState(true),
|
3707
|
-
showPredefinedQuestions = _useState2[0],
|
3708
|
-
setShowPredefinedQuestions = _useState2[1];
|
3709
3710
|
var _useContext = React.useContext(AppContext),
|
3710
|
-
state = _useContext.state
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
var
|
3715
|
-
|
3716
|
-
|
3717
|
-
var
|
3718
|
-
|
3719
|
-
|
3720
|
-
var
|
3721
|
-
|
3722
|
-
|
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];
|
3723
3733
|
var messageEndRef = React.useRef(null);
|
3724
|
-
var _useState7 = React.useState(),
|
3725
|
-
chatBubbleConfig = _useState7[0],
|
3726
|
-
setChatBubbleConfig = _useState7[1];
|
3727
3734
|
var handlePredefinedQuestionSelect = function handlePredefinedQuestionSelect(question) {
|
3728
3735
|
sendInputInquiry();
|
3729
|
-
askPredefinedQuestion(question
|
3736
|
+
askPredefinedQuestion(question);
|
3730
3737
|
setUserInput('');
|
3731
3738
|
setShowPredefinedQuestions(false);
|
3732
3739
|
};
|
3733
|
-
var getChatBubbleConfig = React.useCallback(function () {
|
3734
|
-
try {
|
3735
|
-
return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
|
3736
|
-
client_id: clientId
|
3737
|
-
})).then(function (remotePredefinedQuestions) {
|
3738
|
-
if (remotePredefinedQuestions) {
|
3739
|
-
setPredefinedQuestions(remotePredefinedQuestions);
|
3740
|
-
}
|
3741
|
-
return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
|
3742
|
-
client_id: clientId
|
3743
|
-
})).then(function (remoteChatBubbleConfig) {
|
3744
|
-
if (remoteChatBubbleConfig) {
|
3745
|
-
setChatBubbleConfig(remoteChatBubbleConfig);
|
3746
|
-
}
|
3747
|
-
});
|
3748
|
-
});
|
3749
|
-
} catch (e) {
|
3750
|
-
return Promise.reject(e);
|
3751
|
-
}
|
3752
|
-
}, [clientId]);
|
3753
|
-
React.useEffect(function () {
|
3754
|
-
void getChatBubbleConfig();
|
3755
|
-
}, [getChatBubbleConfig]);
|
3756
|
-
React.useEffect(function () {
|
3757
|
-
if (messageEndRef !== null && messageEndRef !== void 0 && messageEndRef.current) {
|
3758
|
-
messageEndRef.current.scrollIntoView({
|
3759
|
-
behavior: 'smooth'
|
3760
|
-
});
|
3761
|
-
}
|
3762
|
-
}, [messages]);
|
3763
3740
|
var toggleChat = function toggleChat() {
|
3764
|
-
console.log('This is it', chatIsOpen);
|
3765
3741
|
setChatIsOpen(!chatIsOpen);
|
3766
3742
|
};
|
3767
3743
|
var handleUserInput = function handleUserInput(e) {
|
@@ -3779,6 +3755,37 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3779
3755
|
return Promise.reject(e);
|
3780
3756
|
}
|
3781
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]);
|
3782
3789
|
return {
|
3783
3790
|
chatIsOpen: chatIsOpen,
|
3784
3791
|
messages: messages,
|
@@ -3789,9 +3796,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3789
3796
|
handleKeyPress: handleKeyPress,
|
3790
3797
|
toggleChat: toggleChat,
|
3791
3798
|
sendInputInquiry: sendInputInquiry,
|
3792
|
-
chatBubbleConfig: chatBubbleConfig,
|
3799
|
+
chatBubbleConfig: state.chatBubbleConfig,
|
3793
3800
|
showPredefinedQuestions: showPredefinedQuestions,
|
3794
|
-
predefinedQuestions:
|
3801
|
+
predefinedQuestions: state.pQuestions,
|
3802
|
+
aiFollowUpQs: state.aiFollowUpQs,
|
3795
3803
|
handlePredefinedQuestionSelect: handlePredefinedQuestionSelect
|
3796
3804
|
};
|
3797
3805
|
};
|
@@ -3806,11 +3814,11 @@ function SendMessageIcon(_ref) {
|
|
3806
3814
|
width: '24',
|
3807
3815
|
height: '24',
|
3808
3816
|
viewBox: '0 0 24 24',
|
3809
|
-
|
3817
|
+
strokeWidth: '1.5',
|
3810
3818
|
stroke: color,
|
3811
3819
|
fill: 'none',
|
3812
|
-
|
3813
|
-
|
3820
|
+
strokeLinecap: 'round',
|
3821
|
+
strokeLinejoin: 'round'
|
3814
3822
|
}, React__default.createElement("path", {
|
3815
3823
|
stroke: 'none',
|
3816
3824
|
d: 'M0 0h24v24H0z',
|
@@ -3828,11 +3836,11 @@ function DefaultBotProfile() {
|
|
3828
3836
|
width: '24',
|
3829
3837
|
height: '24',
|
3830
3838
|
viewBox: '0 0 24 24',
|
3831
|
-
|
3839
|
+
strokeWidth: '1.5',
|
3832
3840
|
stroke: '#fff',
|
3833
3841
|
fill: 'none',
|
3834
|
-
|
3835
|
-
|
3842
|
+
strokeLinecap: 'round',
|
3843
|
+
strokeLinejoin: 'round'
|
3836
3844
|
}, React__default.createElement("path", {
|
3837
3845
|
stroke: 'none',
|
3838
3846
|
d: 'M0 0h24v24H0z',
|
@@ -3858,11 +3866,11 @@ function ChatIcon() {
|
|
3858
3866
|
width: '40',
|
3859
3867
|
height: '40',
|
3860
3868
|
viewBox: '0 0 24 24',
|
3861
|
-
|
3869
|
+
strokeWidth: '1.5',
|
3862
3870
|
stroke: '#fff',
|
3863
3871
|
fill: 'none',
|
3864
|
-
|
3865
|
-
|
3872
|
+
strokeLinecap: 'round',
|
3873
|
+
strokeLinejoin: 'round'
|
3866
3874
|
}, React__default.createElement("path", {
|
3867
3875
|
stroke: 'none',
|
3868
3876
|
d: 'M0 0h24v24H0z',
|
@@ -3884,11 +3892,11 @@ function CloseIcon() {
|
|
3884
3892
|
width: "40",
|
3885
3893
|
height: "40",
|
3886
3894
|
viewBox: "0 0 24 24",
|
3887
|
-
|
3895
|
+
strokeWidth: "1.5",
|
3888
3896
|
stroke: "#fff",
|
3889
3897
|
fill: "none",
|
3890
|
-
|
3891
|
-
|
3898
|
+
strokeLinecap: "round",
|
3899
|
+
strokeLinejoin: "round"
|
3892
3900
|
}, React__default.createElement("path", {
|
3893
3901
|
stroke: "none",
|
3894
3902
|
d: "M0 0h24v24H0z",
|
@@ -4087,13 +4095,7 @@ var Loader = function Loader() {
|
|
4087
4095
|
var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
4088
4096
|
var questions = _ref.questions,
|
4089
4097
|
onSelect = _ref.onSelect,
|
4090
|
-
|
4091
|
-
test = _ref.test;
|
4092
|
-
var _useBiBotChatBot = useBiBotChatBot({
|
4093
|
-
clientId: clientId,
|
4094
|
-
test: test
|
4095
|
-
}),
|
4096
|
-
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
|
4098
|
+
chatBubbleConfig = _ref.chatBubbleConfig;
|
4097
4099
|
return React.createElement("div", {
|
4098
4100
|
style: {
|
4099
4101
|
height: '100%',
|
@@ -4120,7 +4122,7 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
|
4120
4122
|
style: {
|
4121
4123
|
marginBlock: '0.5px'
|
4122
4124
|
}
|
4123
|
-
}, "Welcome!
|
4125
|
+
}, chatBubbleConfig !== null && chatBubbleConfig !== void 0 && chatBubbleConfig.knownUser ? "Hello " + chatBubbleConfig.knownUser : 'Welcome!'), React.createElement("p", {
|
4124
4126
|
style: {
|
4125
4127
|
fontSize: '14px'
|
4126
4128
|
}
|
@@ -4144,31 +4146,70 @@ var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
|
4144
4146
|
}, question.question);
|
4145
4147
|
}));
|
4146
4148
|
};
|
4147
|
-
|
4148
|
-
|
4149
|
-
var
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
|
4154
|
-
|
4155
|
-
|
4156
|
-
|
4157
|
-
|
4158
|
-
|
4159
|
-
|
4160
|
-
|
4161
|
-
|
4162
|
-
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4169
|
-
|
4170
|
-
|
4171
|
-
|
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
|
+
}, React.createElement("div", {
|
4164
|
+
style: {
|
4165
|
+
display: 'flex',
|
4166
|
+
justifyContent: 'center',
|
4167
|
+
alignItems: 'center',
|
4168
|
+
flexDirection: 'column',
|
4169
|
+
textAlign: 'center'
|
4170
|
+
}
|
4171
|
+
}, React.createElement("p", {
|
4172
|
+
style: {
|
4173
|
+
fontSize: '14px'
|
4174
|
+
}
|
4175
|
+
}, " Related questions ")), questions.map(function (question, index) {
|
4176
|
+
var _chatBubbleConfig$col;
|
4177
|
+
return React.createElement("div", {
|
4178
|
+
key: index,
|
4179
|
+
style: {
|
4180
|
+
backgroundColor: 'transparent',
|
4181
|
+
border: "0.5px solid " + (chatBubbleConfig ? (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede' : '#000'),
|
4182
|
+
fontSize: '16px',
|
4183
|
+
margin: '7px',
|
4184
|
+
textAlign: 'start',
|
4185
|
+
padding: '10px',
|
4186
|
+
borderRadius: '6px',
|
4187
|
+
cursor: 'pointer'
|
4188
|
+
},
|
4189
|
+
onClick: function onClick() {
|
4190
|
+
onSelect(question);
|
4191
|
+
}
|
4192
|
+
}, question.question);
|
4193
|
+
}));
|
4194
|
+
};
|
4195
|
+
|
4196
|
+
var ChatBubbleBiBot = function ChatBubbleBiBot(bibotProps) {
|
4197
|
+
var _chatBubbleConfig$col, _chatBubbleConfig$col2;
|
4198
|
+
var _useBiBotChatBot = useBiBotChatBot(bibotProps),
|
4199
|
+
chatIsOpen = _useBiBotChatBot.chatIsOpen,
|
4200
|
+
messages = _useBiBotChatBot.messages,
|
4201
|
+
isLoading = _useBiBotChatBot.isLoading,
|
4202
|
+
messageEndRef = _useBiBotChatBot.messageEndRef,
|
4203
|
+
userInput = _useBiBotChatBot.userInput,
|
4204
|
+
handleUserInput = _useBiBotChatBot.handleUserInput,
|
4205
|
+
handleKeyPress = _useBiBotChatBot.handleKeyPress,
|
4206
|
+
sendInputInquiry = _useBiBotChatBot.sendInputInquiry,
|
4207
|
+
toggleChat = _useBiBotChatBot.toggleChat,
|
4208
|
+
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig,
|
4209
|
+
showPredefinedQuestions = _useBiBotChatBot.showPredefinedQuestions,
|
4210
|
+
predefinedQuestions = _useBiBotChatBot.predefinedQuestions,
|
4211
|
+
aiFollowUpQs = _useBiBotChatBot.aiFollowUpQs,
|
4212
|
+
handlePredefinedQuestionSelect = _useBiBotChatBot.handlePredefinedQuestionSelect;
|
4172
4213
|
var isOnline = useOnlineStatus();
|
4173
4214
|
return React.createElement("div", {
|
4174
4215
|
className: "chat-bubble " + (chatIsOpen ? 'open' : ''),
|
@@ -4196,7 +4237,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4196
4237
|
}, React.createElement("div", {
|
4197
4238
|
className: styles['chat-header'],
|
4198
4239
|
style: {
|
4199
|
-
backgroundColor: (_chatBubbleConfig$
|
4240
|
+
backgroundColor: (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede',
|
4200
4241
|
height: 50,
|
4201
4242
|
borderTopLeftRadius: 8,
|
4202
4243
|
borderTopRightRadius: 8,
|
@@ -4256,7 +4297,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4256
4297
|
}, showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && React.createElement(PredefinedQuestions, {
|
4257
4298
|
questions: predefinedQuestions.slice(0, 3),
|
4258
4299
|
onSelect: handlePredefinedQuestionSelect,
|
4259
|
-
|
4300
|
+
chatBubbleConfig: chatBubbleConfig
|
4260
4301
|
}), messages.map(function (message, index) {
|
4261
4302
|
return message.sender === 'user' ? React.createElement("div", {
|
4262
4303
|
key: index,
|
@@ -4296,6 +4337,10 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4296
4337
|
textAlign: 'left'
|
4297
4338
|
}
|
4298
4339
|
}, message.text));
|
4340
|
+
}), aiFollowUpQs && !isLoading && React.createElement(AiFollowUps, {
|
4341
|
+
questions: aiFollowUpQs,
|
4342
|
+
onSelect: handlePredefinedQuestionSelect,
|
4343
|
+
chatBubbleConfig: chatBubbleConfig
|
4299
4344
|
}), isLoading && React.createElement("div", {
|
4300
4345
|
style: {
|
4301
4346
|
marginLeft: '20px'
|
@@ -4347,7 +4392,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4347
4392
|
onClick: toggleChat,
|
4348
4393
|
className: styles['chat-toggle'],
|
4349
4394
|
style: {
|
4350
|
-
backgroundColor: (_chatBubbleConfig$
|
4395
|
+
backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
|
4351
4396
|
color: '#fff',
|
4352
4397
|
borderRadius: '50%',
|
4353
4398
|
cursor: 'pointer',
|
@@ -4361,16 +4406,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4361
4406
|
}, chatIsOpen ? React.createElement(CloseIcon, null) : React.createElement(ChatIcon, null)));
|
4362
4407
|
};
|
4363
4408
|
|
4364
|
-
var BiBot = function BiBot(
|
4365
|
-
var clientId = _ref.clientId,
|
4366
|
-
client_session_id = _ref.client_session_id,
|
4367
|
-
redirect_notice = _ref.redirect_notice,
|
4368
|
-
test = _ref.test;
|
4409
|
+
var BiBot = function BiBot(bibotProps) {
|
4369
4410
|
return React.createElement(AppProvider, null, React.createElement(ChatBubbleBiBot, {
|
4370
|
-
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4411
|
+
jwt: bibotProps.jwt,
|
4412
|
+
clientId: bibotProps.clientId,
|
4413
|
+
client_session_id: bibotProps.client_session_id,
|
4414
|
+
redirect_notice: bibotProps.redirect_notice,
|
4415
|
+
test: bibotProps.test
|
4374
4416
|
}));
|
4375
4417
|
};
|
4376
4418
|
|