bibot 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useBiBotChatBot.d.ts +3 -2
- package/dist/index.js +112 -40
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +112 -40
- package/dist/index.modern.js.map +1 -1
- package/dist/services/plugin-api.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
@@ -3485,16 +3485,33 @@ var AppProvider = function AppProvider(_ref) {
|
|
3485
3485
|
};
|
3486
3486
|
|
3487
3487
|
var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefinedQuestions(params) {
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3491
|
-
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3488
|
+
try {
|
3489
|
+
return Promise.resolve(_catch(function () {
|
3490
|
+
var path = "" + domain.inference + resources.predefinedQ;
|
3491
|
+
return Promise.resolve(pluginAxiosInstance.get(path, {
|
3492
|
+
params: params
|
3493
|
+
})).then(function (response) {
|
3494
|
+
console.log(response.data.predefined_questions);
|
3495
|
+
return response.data.predefined_questions;
|
3496
|
+
});
|
3497
|
+
}, function () {
|
3498
|
+
return [{
|
3499
|
+
question: 'These are placeholders',
|
3500
|
+
answer: ''
|
3501
|
+
}, {
|
3502
|
+
question: 'They will be removed in production',
|
3503
|
+
answer: ''
|
3504
|
+
}, {
|
3505
|
+
question: 'This will be empty if there are no predefined questions',
|
3506
|
+
answer: ''
|
3507
|
+
}, {
|
3508
|
+
question: 'So hide if there are no predefined questions',
|
3509
|
+
answer: ''
|
3510
|
+
}];
|
3511
|
+
}));
|
3512
|
+
} catch (e) {
|
3513
|
+
return Promise.reject(e);
|
3514
|
+
}
|
3498
3515
|
};
|
3499
3516
|
var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(params) {
|
3500
3517
|
try {
|
@@ -3588,20 +3605,21 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3588
3605
|
var sendInputInquiry = function sendInputInquiry() {
|
3589
3606
|
try {
|
3590
3607
|
setIsLoading(true);
|
3608
|
+
var input = userInput.trim();
|
3591
3609
|
setUserInput('');
|
3592
3610
|
return Promise.resolve(_finallyRethrows(function () {
|
3593
3611
|
return _catch(function () {
|
3594
3612
|
var _temp2 = function () {
|
3595
|
-
if (
|
3613
|
+
if (input) {
|
3596
3614
|
setMessages(function (messages) {
|
3597
3615
|
return [].concat(messages, [{
|
3598
3616
|
sender: 'user',
|
3599
|
-
text:
|
3617
|
+
text: input
|
3600
3618
|
}]);
|
3601
3619
|
});
|
3602
3620
|
return Promise.resolve(askBiBot({
|
3603
3621
|
client_id: clientId,
|
3604
|
-
q:
|
3622
|
+
q: input,
|
3605
3623
|
session_id: state.sessionId,
|
3606
3624
|
chat_id: v4()
|
3607
3625
|
})).then(function (response) {
|
@@ -3617,7 +3635,7 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3617
3635
|
if (_temp2 && _temp2.then) return _temp2.then(function () {});
|
3618
3636
|
}, function (error) {
|
3619
3637
|
var _error$message;
|
3620
|
-
|
3638
|
+
console.error((_error$message = error === null || error === void 0 ? void 0 : error.message) != null ? _error$message : 'Failed to get response from server');
|
3621
3639
|
});
|
3622
3640
|
}, function (_wasThrown, _result) {
|
3623
3641
|
setIsLoading(false);
|
@@ -3628,6 +3646,33 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3628
3646
|
return Promise.reject(e);
|
3629
3647
|
}
|
3630
3648
|
};
|
3649
|
+
var askPredefinedQuestion = function askPredefinedQuestion(question) {
|
3650
|
+
try {
|
3651
|
+
setIsLoading(true);
|
3652
|
+
var input = question.question.trim();
|
3653
|
+
setUserInput('');
|
3654
|
+
if (input === question.question) {
|
3655
|
+
setMessages(function (messages) {
|
3656
|
+
return [].concat(messages, [{
|
3657
|
+
sender: 'user',
|
3658
|
+
text: input
|
3659
|
+
}]);
|
3660
|
+
});
|
3661
|
+
setTimeout(function () {
|
3662
|
+
setMessages(function (messages) {
|
3663
|
+
return [].concat(messages, [{
|
3664
|
+
sender: 'bot',
|
3665
|
+
text: question.answer
|
3666
|
+
}]);
|
3667
|
+
});
|
3668
|
+
setIsLoading(false);
|
3669
|
+
}, 1000);
|
3670
|
+
}
|
3671
|
+
return Promise.resolve();
|
3672
|
+
} catch (e) {
|
3673
|
+
return Promise.reject(e);
|
3674
|
+
}
|
3675
|
+
};
|
3631
3676
|
var clientId = _ref.clientId;
|
3632
3677
|
var _useState = useState([]),
|
3633
3678
|
predefinedQuestions = _useState[0],
|
@@ -3654,9 +3699,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3654
3699
|
chatBubbleConfig = _useState7[0],
|
3655
3700
|
setChatBubbleConfig = _useState7[1];
|
3656
3701
|
var handlePredefinedQuestionSelect = function handlePredefinedQuestionSelect(question) {
|
3657
|
-
setUserInput(question);
|
3658
3702
|
sendInputInquiry();
|
3659
|
-
|
3703
|
+
askPredefinedQuestion(question);
|
3704
|
+
setUserInput('');
|
3705
|
+
setShowPredefinedQuestions(true);
|
3660
3706
|
};
|
3661
3707
|
var getChatBubbleConfig = useCallback(function () {
|
3662
3708
|
try {
|
@@ -3892,38 +3938,61 @@ var useOnlineStatus = function useOnlineStatus() {
|
|
3892
3938
|
|
3893
3939
|
var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
3894
3940
|
var questions = _ref.questions,
|
3895
|
-
onSelect = _ref.onSelect
|
3941
|
+
onSelect = _ref.onSelect,
|
3942
|
+
clientId = _ref.clientId;
|
3943
|
+
var _useBiBotChatBot = useBiBotChatBot({
|
3944
|
+
clientId: clientId
|
3945
|
+
}),
|
3946
|
+
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
|
3896
3947
|
return createElement("div", {
|
3897
|
-
className: styles['predefined-questions']
|
3948
|
+
className: styles['predefined-questions'],
|
3949
|
+
style: {
|
3950
|
+
height: '50%',
|
3951
|
+
color: '#000'
|
3952
|
+
}
|
3898
3953
|
}, questions.map(function (question, index) {
|
3954
|
+
var _chatBubbleConfig$col;
|
3899
3955
|
return createElement("div", {
|
3900
3956
|
key: index,
|
3901
3957
|
className: styles['predefined-questions'],
|
3958
|
+
style: {
|
3959
|
+
backgroundColor: '#fff',
|
3960
|
+
border: "0.5px solid " + (chatBubbleConfig ? (_chatBubbleConfig$col = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col : '#dedede' : '#000'),
|
3961
|
+
fontSize: 16,
|
3962
|
+
margin: 5,
|
3963
|
+
textAlign: 'start',
|
3964
|
+
height: 20,
|
3965
|
+
padding: 10,
|
3966
|
+
display: 'flex',
|
3967
|
+
alignItems: 'center',
|
3968
|
+
borderRadius: 6,
|
3969
|
+
cursor: 'pointer'
|
3970
|
+
},
|
3902
3971
|
onClick: function onClick() {
|
3903
|
-
|
3972
|
+
onSelect(question);
|
3904
3973
|
}
|
3905
|
-
}, question);
|
3974
|
+
}, question.question);
|
3906
3975
|
}));
|
3907
3976
|
};
|
3908
3977
|
var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
3909
|
-
var _chatBubbleConfig$
|
3978
|
+
var _chatBubbleConfig$col2, _chatBubbleConfig$col3;
|
3910
3979
|
var clientId = _ref2.clientId;
|
3911
|
-
var
|
3980
|
+
var _useBiBotChatBot2 = useBiBotChatBot({
|
3912
3981
|
clientId: clientId
|
3913
3982
|
}),
|
3914
|
-
chatIsOpen =
|
3915
|
-
messages =
|
3916
|
-
isLoading =
|
3917
|
-
messageEndRef =
|
3918
|
-
userInput =
|
3919
|
-
handleUserInput =
|
3920
|
-
handleKeyPress =
|
3921
|
-
sendInputInquiry =
|
3922
|
-
toggleChat =
|
3923
|
-
chatBubbleConfig =
|
3924
|
-
showPredefinedQuestions =
|
3925
|
-
predefinedQuestions =
|
3926
|
-
handlePredefinedQuestionSelect =
|
3983
|
+
chatIsOpen = _useBiBotChatBot2.chatIsOpen,
|
3984
|
+
messages = _useBiBotChatBot2.messages,
|
3985
|
+
isLoading = _useBiBotChatBot2.isLoading,
|
3986
|
+
messageEndRef = _useBiBotChatBot2.messageEndRef,
|
3987
|
+
userInput = _useBiBotChatBot2.userInput,
|
3988
|
+
handleUserInput = _useBiBotChatBot2.handleUserInput,
|
3989
|
+
handleKeyPress = _useBiBotChatBot2.handleKeyPress,
|
3990
|
+
sendInputInquiry = _useBiBotChatBot2.sendInputInquiry,
|
3991
|
+
toggleChat = _useBiBotChatBot2.toggleChat,
|
3992
|
+
chatBubbleConfig = _useBiBotChatBot2.chatBubbleConfig,
|
3993
|
+
showPredefinedQuestions = _useBiBotChatBot2.showPredefinedQuestions,
|
3994
|
+
predefinedQuestions = _useBiBotChatBot2.predefinedQuestions,
|
3995
|
+
handlePredefinedQuestionSelect = _useBiBotChatBot2.handlePredefinedQuestionSelect;
|
3927
3996
|
var isOnline = useOnlineStatus();
|
3928
3997
|
return createElement("div", {
|
3929
3998
|
className: "chat-bubble " + (chatIsOpen ? 'open' : ''),
|
@@ -3950,7 +4019,7 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
3950
4019
|
}, createElement("div", {
|
3951
4020
|
className: styles['chat-header'],
|
3952
4021
|
style: {
|
3953
|
-
backgroundColor: (_chatBubbleConfig$
|
4022
|
+
backgroundColor: (_chatBubbleConfig$col2 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col2 : '#dedede',
|
3954
4023
|
height: 50,
|
3955
4024
|
borderTopLeftRadius: 8,
|
3956
4025
|
borderTopRightRadius: 8,
|
@@ -4047,8 +4116,9 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4047
4116
|
}
|
4048
4117
|
}, message.text));
|
4049
4118
|
}), showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && createElement(PredefinedQuestions, {
|
4050
|
-
questions: predefinedQuestions,
|
4051
|
-
onSelect: handlePredefinedQuestionSelect
|
4119
|
+
questions: predefinedQuestions.slice(0, 5),
|
4120
|
+
onSelect: handlePredefinedQuestionSelect,
|
4121
|
+
clientId: clientId
|
4052
4122
|
}), isLoading && createElement("div", {
|
4053
4123
|
style: {
|
4054
4124
|
marginLeft: '20px'
|
@@ -4093,14 +4163,16 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4093
4163
|
border: 'none',
|
4094
4164
|
cursor: 'pointer'
|
4095
4165
|
},
|
4096
|
-
onClick:
|
4166
|
+
onClick: function onClick() {
|
4167
|
+
return sendInputInquiry();
|
4168
|
+
}
|
4097
4169
|
}, createElement(SendMessageIcon, {
|
4098
4170
|
color: isLoading ? '#fff' : chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color
|
4099
4171
|
})))), createElement("button", {
|
4100
4172
|
onClick: toggleChat,
|
4101
4173
|
className: styles['chat-toggle'],
|
4102
4174
|
style: {
|
4103
|
-
backgroundColor: (_chatBubbleConfig$
|
4175
|
+
backgroundColor: (_chatBubbleConfig$col3 = chatBubbleConfig === null || chatBubbleConfig === void 0 ? void 0 : chatBubbleConfig.color) != null ? _chatBubbleConfig$col3 : '#dedede',
|
4104
4176
|
color: '#fff',
|
4105
4177
|
borderRadius: '50%',
|
4106
4178
|
cursor: 'pointer',
|