@aslaluroba/help-center-react 3.0.0 → 3.0.1
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/core/AblyService.d.ts +1 -0
- package/dist/index.esm.js +58 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/AblyService.ts +22 -3
- package/src/ui/chatbot-popup/chat-window-screen/index.tsx +12 -3
package/package.json
CHANGED
package/src/core/AblyService.ts
CHANGED
|
@@ -69,7 +69,7 @@ export class ClientAblyService {
|
|
|
69
69
|
throw new Error('Chat client not initialized');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const roomName = `session:${tenantId}
|
|
72
|
+
const roomName = `session:${tenantId}:${sessionId}`;
|
|
73
73
|
|
|
74
74
|
// Set up raw channel subscription for server messages
|
|
75
75
|
if (this.client) {
|
|
@@ -80,11 +80,12 @@ export class ClientAblyService {
|
|
|
80
80
|
try {
|
|
81
81
|
const messageContent =
|
|
82
82
|
typeof message.data === 'string' ? message.data : message.data?.content || message.data?.message;
|
|
83
|
-
const senderType = 3; // Assistant
|
|
83
|
+
const senderType = message.data?.senderType || 3; // Assistant
|
|
84
84
|
const needsAgent = message.data?.needsAgent || false;
|
|
85
85
|
|
|
86
86
|
onMessageReceived(messageContent, senderType, needsAgent);
|
|
87
87
|
} catch (error) {
|
|
88
|
+
// Handle error silently
|
|
88
89
|
console.error('[AblyService] Error processing ReceiveMessage:', error);
|
|
89
90
|
}
|
|
90
91
|
});
|
|
@@ -117,7 +118,6 @@ export class ClientAblyService {
|
|
|
117
118
|
this.isConnected = false;
|
|
118
119
|
this.sessionId = null;
|
|
119
120
|
} catch (error) {
|
|
120
|
-
console.error('[AblyService] Error stopping Ably connection:', error);
|
|
121
121
|
// Reset state even if there's an error
|
|
122
122
|
this.isConnected = false;
|
|
123
123
|
this.sessionId = null;
|
|
@@ -134,4 +134,23 @@ export class ClientAblyService {
|
|
|
134
134
|
static getConnectionState(): string {
|
|
135
135
|
return this.client?.connection.state || 'disconnected';
|
|
136
136
|
}
|
|
137
|
+
|
|
138
|
+
// Method to manually send a message (if needed for debugging or direct messaging)
|
|
139
|
+
static async sendMessage(messageContent: string, senderType: number = 1) {
|
|
140
|
+
if (!this.channel || !this.isConnected) {
|
|
141
|
+
throw new Error('Connection not active');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
await this.channel.publish('message', {
|
|
146
|
+
text: messageContent,
|
|
147
|
+
metadata: {
|
|
148
|
+
senderType,
|
|
149
|
+
sentAt: new Date().toISOString(),
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
} catch (error) {
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
137
156
|
}
|
|
@@ -5,6 +5,7 @@ import React, { useEffect, useRef, useState, useCallback, useMemo } from 'react'
|
|
|
5
5
|
import LoadingGif from './../../../assets/animatedLogo.gif';
|
|
6
6
|
import Seperator from './../../../assets/icons/seperator.svg';
|
|
7
7
|
import LogoIcon from './../../../assets/logo.svg';
|
|
8
|
+
import HumanIcon from './../../../assets/icons/user.svg';
|
|
8
9
|
|
|
9
10
|
interface ChatWindowProps {
|
|
10
11
|
onSendMessage: (message: string) => void;
|
|
@@ -41,10 +42,18 @@ const MessageComponent = React.memo(
|
|
|
41
42
|
</div>
|
|
42
43
|
)}
|
|
43
44
|
<div className={`babylai-mb-4 babylai-flex ${textDirection}`}>
|
|
44
|
-
{isFirstInSequence && message.senderType === 3 && (
|
|
45
|
+
{isFirstInSequence && (message.senderType === 3 || message.senderType === 2) && (
|
|
45
46
|
<div className='babylai-flex-shrink-0 babylai-me-3'>
|
|
46
|
-
<div
|
|
47
|
-
|
|
47
|
+
<div
|
|
48
|
+
className={`babylai-w-8 babylai-h-8 babylai-rounded-full babylai-flex babylai-items-center babylai-justify-center ${
|
|
49
|
+
message?.senderType === 3 ? 'babylai-bg-primary' : 'babylai-bg-black-white-50'
|
|
50
|
+
}`}
|
|
51
|
+
>
|
|
52
|
+
{message?.senderType === 3 ? (
|
|
53
|
+
<LogoIcon className='babylai-w-4 babylai-h-4 babylai-text-white' />
|
|
54
|
+
) : (
|
|
55
|
+
<HumanIcon className='babylai-w-4 babylai-h-4 babylai-text-primary' />
|
|
56
|
+
)}
|
|
48
57
|
</div>
|
|
49
58
|
</div>
|
|
50
59
|
)}
|