@ihoomanai/chat-widget 3.0.18 → 3.0.20
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 +6 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +6 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.js +6 -44
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/widget.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/widget.ts +4 -42
package/src/widget.ts
CHANGED
|
@@ -684,23 +684,11 @@ function addMessage(content: string, sender: 'user' | 'bot' = 'bot', metadata: M
|
|
|
684
684
|
`<button class="ihooman-quick-reply" data-text="${escapeHtml(qr.text)}">${escapeHtml(qr.text)}</button>`
|
|
685
685
|
).join('')}</div>`;
|
|
686
686
|
}
|
|
687
|
-
|
|
688
|
-
// Feedback buttons for bot messages
|
|
689
|
-
let feedbackHtml = '';
|
|
690
|
-
if (sender === 'bot' && !metadata?.is_system_message) {
|
|
691
|
-
feedbackHtml = `
|
|
692
|
-
<div class="ihooman-feedback-btns">
|
|
693
|
-
<button class="ihooman-feedback-btn" data-feedback="up" title="Helpful">${icons.thumbUp}</button>
|
|
694
|
-
<button class="ihooman-feedback-btn" data-feedback="down" title="Not helpful">${icons.thumbDown}</button>
|
|
695
|
-
</div>
|
|
696
|
-
`;
|
|
697
|
-
}
|
|
698
687
|
|
|
699
688
|
el.innerHTML = `
|
|
700
689
|
<div class="ihooman-message-content">${parseMarkdown(content)}</div>
|
|
701
690
|
${escalationButtonsHtml}
|
|
702
691
|
${quickRepliesHtml}
|
|
703
|
-
${feedbackHtml}
|
|
704
692
|
${config.showTimestamps ? `<div class="ihooman-message-time">${formatTime(message.timestamp)}</div>` : ''}
|
|
705
693
|
`;
|
|
706
694
|
|
|
@@ -723,16 +711,6 @@ function addMessage(content: string, sender: 'user' | 'bot' = 'bot', metadata: M
|
|
|
723
711
|
});
|
|
724
712
|
});
|
|
725
713
|
|
|
726
|
-
// Feedback listeners
|
|
727
|
-
el.querySelectorAll('.ihooman-feedback-btn').forEach(btn => {
|
|
728
|
-
btn.addEventListener('click', () => {
|
|
729
|
-
const feedback = (btn as HTMLElement).dataset.feedback;
|
|
730
|
-
el.querySelectorAll('.ihooman-feedback-btn').forEach(b => b.classList.remove('active'));
|
|
731
|
-
btn.classList.add('active');
|
|
732
|
-
submitFeedback(message.id, feedback === 'up' ? 'positive' : 'negative');
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
|
|
736
714
|
const typing = elements.messages.querySelector('.ihooman-typing');
|
|
737
715
|
if (typing) typing.remove();
|
|
738
716
|
|
|
@@ -1049,22 +1027,6 @@ function stopLiveAgentPolling(): void {
|
|
|
1049
1027
|
}
|
|
1050
1028
|
}
|
|
1051
1029
|
|
|
1052
|
-
async function submitFeedback(messageId: string, feedbackType: 'positive' | 'negative'): Promise<void> {
|
|
1053
|
-
try {
|
|
1054
|
-
await fetch(`${config.serverUrl}/api/v1/feedback/submit?widget_id=${encodeURIComponent(config.widgetId)}`, {
|
|
1055
|
-
method: 'POST',
|
|
1056
|
-
headers: { 'Content-Type': 'application/json' },
|
|
1057
|
-
body: JSON.stringify({
|
|
1058
|
-
message_id: messageId,
|
|
1059
|
-
session_id: state.sessionId,
|
|
1060
|
-
feedback_type: feedbackType,
|
|
1061
|
-
}),
|
|
1062
|
-
});
|
|
1063
|
-
} catch (error) {
|
|
1064
|
-
console.error('Error submitting feedback:', error);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
1030
|
async function handleSurveySubmit(): Promise<void> {
|
|
1069
1031
|
const starsContainer = elements.surveyView?.querySelector('.ihooman-survey-stars');
|
|
1070
1032
|
const activeStars = starsContainer?.querySelectorAll('.ihooman-survey-star.active');
|
|
@@ -1077,15 +1039,15 @@ async function handleSurveySubmit(): Promise<void> {
|
|
|
1077
1039
|
}
|
|
1078
1040
|
|
|
1079
1041
|
try {
|
|
1080
|
-
await fetch(`${config.serverUrl}/api/widget/survey-response`, {
|
|
1042
|
+
await fetch(`${config.serverUrl}/api/widget/public/survey-response?widget_id=${encodeURIComponent(config.widgetId)}`, {
|
|
1081
1043
|
method: 'POST',
|
|
1082
1044
|
headers: { 'Content-Type': 'application/json' },
|
|
1083
1045
|
body: JSON.stringify({
|
|
1084
|
-
|
|
1085
|
-
survey_id: config.surveyConfig?.id,
|
|
1046
|
+
survey_config_id: config.surveyConfig?.id,
|
|
1086
1047
|
session_id: state.sessionId,
|
|
1048
|
+
visitor_id: state.visitorId,
|
|
1087
1049
|
rating,
|
|
1088
|
-
comment,
|
|
1050
|
+
comment: comment || null,
|
|
1089
1051
|
}),
|
|
1090
1052
|
});
|
|
1091
1053
|
|