impact-chatbot 2.3.15 → 2.3.17
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/index.cjs.js +48 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +48 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chatbot-services.d.ts +1 -0
- package/dist/utils/coreUtils.d.ts +7 -0
- package/dist/utlis.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -127,6 +127,20 @@ const likeDislikeComment = async (payload) => {
|
|
|
127
127
|
return false;
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
+
// Like/Dislike Messages for agent
|
|
131
|
+
const likeDislikeCommentForAgent = async (payload, baseUrl) => {
|
|
132
|
+
try {
|
|
133
|
+
return axiosInstance({
|
|
134
|
+
url: `${baseUrl}/chatbot/agent/analytics/like`,
|
|
135
|
+
data: payload,
|
|
136
|
+
method: "POST",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.error("likeDislikeComment error", error);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
130
144
|
const fetchIntentApiResponse = async (input = "@apply_filter What is sales discount in cabezon mtd?") => {
|
|
131
145
|
try {
|
|
132
146
|
return axiosInstance({
|
|
@@ -558,7 +572,7 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
558
572
|
* @param {object} templateData
|
|
559
573
|
* @returns
|
|
560
574
|
*/
|
|
561
|
-
const handleMessageLike = async (question, liked, setLoadingState, displaySnackMessages, templateData, activeConversationId, answer, chatDataInfoRef, chatIndex, setChatDataState) => {
|
|
575
|
+
const handleMessageLike = async (question, liked, setLoadingState, displaySnackMessages, templateData, activeConversationId, answer, chatDataInfoRef, chatIndex, setChatDataState, baseUrl, sessionId) => {
|
|
562
576
|
let answerData;
|
|
563
577
|
let questionData;
|
|
564
578
|
answer?.forEach((item) => {
|
|
@@ -583,7 +597,17 @@ const handleMessageLike = async (question, liked, setLoadingState, displaySnackM
|
|
|
583
597
|
const activeMessage = chatDataInfoRef?.[currentMode]?.conversations?.[1]?.messages?.[chatIndex];
|
|
584
598
|
// const activeMessage = chats?.[currentMode].conversations[activeConversationId].messages[activeMessageIndex];
|
|
585
599
|
try {
|
|
586
|
-
|
|
600
|
+
let request;
|
|
601
|
+
if (currentMode === "agent") {
|
|
602
|
+
const agentPayload = {
|
|
603
|
+
session_id: sessionId,
|
|
604
|
+
liked,
|
|
605
|
+
};
|
|
606
|
+
request = await likeDislikeCommentForAgent(agentPayload, baseUrl);
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
request = await likeDislikeComment(payload);
|
|
610
|
+
}
|
|
587
611
|
if (request?.status) {
|
|
588
612
|
let updatedMessage = {
|
|
589
613
|
...activeMessage,
|
|
@@ -891,6 +915,25 @@ const replaceSpecialCharacter = (str) => {
|
|
|
891
915
|
return result;
|
|
892
916
|
}
|
|
893
917
|
};
|
|
918
|
+
/**
|
|
919
|
+
* @function
|
|
920
|
+
* @description Function is used to return string by replacing the special characters with respective key mapped to SPECIAL_CHARACTER_MAPPING
|
|
921
|
+
* @param {String} str
|
|
922
|
+
* @returns {String} key of mapped special character used in the string
|
|
923
|
+
*/
|
|
924
|
+
const replaceSpecialCharToCharCode = (str) => {
|
|
925
|
+
let re = new RegExp(`[${Object.values(SPECIAL_CHARACTER_MAPPING).join("")}]`, "g");
|
|
926
|
+
return str.replace(re, function (matched) {
|
|
927
|
+
let code;
|
|
928
|
+
for (const [key, value] of Object.entries(SPECIAL_CHARACTER_MAPPING)) {
|
|
929
|
+
if (value === matched) {
|
|
930
|
+
code = key;
|
|
931
|
+
return code;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return code;
|
|
935
|
+
});
|
|
936
|
+
};
|
|
894
937
|
|
|
895
938
|
/**
|
|
896
939
|
* Utility functions extracted from core/Utils/functions/utils.js
|
|
@@ -6774,7 +6817,7 @@ const InputContent = ({ bodyText }) => {
|
|
|
6774
6817
|
setValue(newValue);
|
|
6775
6818
|
chatbotContext[bodyText?.paramName] = {
|
|
6776
6819
|
...chatbotContext?.[bodyText?.paramName],
|
|
6777
|
-
[bodyText?.paramName]: newValue,
|
|
6820
|
+
[bodyText?.paramName]: replaceSpecialCharToCharCode(newValue),
|
|
6778
6821
|
updated: true,
|
|
6779
6822
|
type: inputType,
|
|
6780
6823
|
};
|
|
@@ -9957,8 +10000,8 @@ const SmartBot = (props) => {
|
|
|
9957
10000
|
...loadingState,
|
|
9958
10001
|
[isLike ? "like" : "dislike"]: key,
|
|
9959
10002
|
});
|
|
9960
|
-
handleMessageLike(key, isLike, setLoadingState, displaySnackMessages, templateData, activeConversationId, answer, chatDataInfoRef.current, chatIndex, setChatDataState);
|
|
9961
|
-
}, 5000, { trailing: false }), [loadingState, templateData, displaySnackMessages]);
|
|
10003
|
+
handleMessageLike(key, isLike, setLoadingState, displaySnackMessages, templateData, activeConversationId, answer, chatDataInfoRef.current, chatIndex, setChatDataState, baseUrl, sessionId);
|
|
10004
|
+
}, 5000, { trailing: false }), [loadingState, templateData, displaySnackMessages, sessionId, baseUrl]);
|
|
9962
10005
|
React.useEffect(() => {
|
|
9963
10006
|
handleUploadAccess();
|
|
9964
10007
|
}, []);
|