@aktarulrahul/floater-chatbot 1.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/README.md +338 -0
- package/dist/components/ChatWidget.d.ts +9 -0
- package/dist/components/ChatWidget.d.ts.map +1 -0
- package/dist/components/SupportChatWidget.d.ts +26 -0
- package/dist/components/SupportChatWidget.d.ts.map +1 -0
- package/dist/hooks/useChat.d.ts +9 -0
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/index.d.ts +133 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +1893 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1898 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +69 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/api.d.ts +26 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# Floater Chatbot - React NPM Package
|
|
2
|
+
|
|
3
|
+
A professional, AI-powered floating chat widget for React applications that integrates with n8n workflows for intelligent customer support.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/Soft-Loop-Studio/chat-bot)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🤖 **AI-Powered**: Integrates with your n8n workflow for intelligent responses
|
|
11
|
+
- 🎨 **Customizable**: Fully customizable appearance and positioning
|
|
12
|
+
- 🔐 **Secure**: Token-based authentication
|
|
13
|
+
- 📱 **Responsive**: Works seamlessly on desktop and mobile
|
|
14
|
+
- 🎯 **TypeScript**: Built with TypeScript for type safety
|
|
15
|
+
- ⚡ **Lightweight**: Minimal dependencies, optimized bundle size
|
|
16
|
+
- 🔄 **Conversation Context**: Maintains conversation history via conversation IDs
|
|
17
|
+
- 🎫 **Ticket Support**: Handles Zendesk ticket creation callbacks
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @aktarulrahul/floater-chatbot
|
|
23
|
+
# or
|
|
24
|
+
yarn add @aktarulrahul/floater-chatbot
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import React from "react";
|
|
31
|
+
import { ChatWidget } from "@aktarulrahul/floater-chatbot";
|
|
32
|
+
import "@aktarulrahul/floater-chatbot/dist/index.css"; // If CSS is bundled separately
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
return (
|
|
36
|
+
<ChatWidget
|
|
37
|
+
config={{
|
|
38
|
+
webhookUrl: "http://localhost:5678/webhook/chat",
|
|
39
|
+
accessToken: "your-access-token",
|
|
40
|
+
apiEndpoints: {
|
|
41
|
+
profileApi: "https://api.example.com/profile",
|
|
42
|
+
servicesApi: "https://api.example.com/services",
|
|
43
|
+
zendeskApi: "https://your-domain.zendesk.com",
|
|
44
|
+
},
|
|
45
|
+
appearance: {
|
|
46
|
+
primaryColor: "#007bff",
|
|
47
|
+
position: "bottom-right",
|
|
48
|
+
title: "Chat Support",
|
|
49
|
+
subtitle: "How can we help you?",
|
|
50
|
+
},
|
|
51
|
+
callbacks: {
|
|
52
|
+
onMessageSent: (message) => console.log("Sent:", message),
|
|
53
|
+
onMessageReceived: (response) => console.log("Received:", response),
|
|
54
|
+
onTicketCreated: (ticketId, ticketUrl) => {
|
|
55
|
+
console.log("Ticket created:", ticketId, ticketUrl);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Configuration Options
|
|
65
|
+
|
|
66
|
+
### ChatWidgetConfig
|
|
67
|
+
|
|
68
|
+
| Property | Type | Required | Description |
|
|
69
|
+
| ---------------- | -------- | -------- | --------------------------------------------------------------------- |
|
|
70
|
+
| `webhookUrl` | `string` | ✅ | n8n webhook endpoint URL (e.g., `http://localhost:5678/webhook/chat`) |
|
|
71
|
+
| `accessToken` | `string` | ✅ | User authentication token |
|
|
72
|
+
| `conversationId` | `string` | ❌ | Optional conversation ID for context |
|
|
73
|
+
| `apiEndpoints` | `object` | ❌ | API endpoints to pass to n8n |
|
|
74
|
+
| `appearance` | `object` | ❌ | Widget appearance configuration |
|
|
75
|
+
| `callbacks` | `object` | ❌ | Event callback functions |
|
|
76
|
+
| `supportConfig` | `object` | ❌ | Support-specific config (for SupportChatWidget) |
|
|
77
|
+
|
|
78
|
+
### Appearance Options
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
appearance: {
|
|
82
|
+
primaryColor?: string; // Default: '#007bff'
|
|
83
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; // Default: 'bottom-right'
|
|
84
|
+
title?: string; // Default: 'Chat Support'
|
|
85
|
+
subtitle?: string; // Default: 'How can we help you?'
|
|
86
|
+
placeholder?: string; // Default: 'Type your message...'
|
|
87
|
+
showAvatar?: boolean; // Default: true
|
|
88
|
+
avatarUrl?: string; // Default: auto-generated avatar
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### API Endpoints
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
apiEndpoints: {
|
|
96
|
+
profileApi?: string; // User profile API endpoint
|
|
97
|
+
servicesApi?: string; // Purchased services API endpoint
|
|
98
|
+
zendeskApi?: string; // Zendesk API endpoint
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Callbacks
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
callbacks: {
|
|
106
|
+
onMessageSent?: (message: string) => void;
|
|
107
|
+
onMessageReceived?: (response: ChatResponse) => void;
|
|
108
|
+
onError?: (error: Error) => void;
|
|
109
|
+
onTicketCreated?: (ticketId: string, ticketUrl: string) => void;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## SupportChatWidget Usage
|
|
114
|
+
|
|
115
|
+
For advanced support features with category selection, priority levels, and ticket management:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import React from "react";
|
|
119
|
+
import { SupportChatWidget } from "@aktarulrahul/floater-chatbot";
|
|
120
|
+
import "@aktarulrahul/floater-chatbot/dist/index.css";
|
|
121
|
+
|
|
122
|
+
function App() {
|
|
123
|
+
return (
|
|
124
|
+
<SupportChatWidget
|
|
125
|
+
config={{
|
|
126
|
+
webhookUrl: "http://localhost:5678/webhook/support-chat",
|
|
127
|
+
accessToken: "your-access-token",
|
|
128
|
+
supportConfig: {
|
|
129
|
+
custOrgId: 10556,
|
|
130
|
+
serviceItemId: 2970,
|
|
131
|
+
},
|
|
132
|
+
apiEndpoints: {
|
|
133
|
+
profileApi: "https://api.example.com/profile",
|
|
134
|
+
servicesApi: "https://api.example.com/services",
|
|
135
|
+
zendeskApi: "https://your-domain.zendesk.com",
|
|
136
|
+
},
|
|
137
|
+
appearance: {
|
|
138
|
+
title: "Support Center",
|
|
139
|
+
subtitle: "How can we help you?",
|
|
140
|
+
},
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Support Configuration
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
supportConfig: {
|
|
151
|
+
custOrgId?: number; // Customer organization ID
|
|
152
|
+
serviceItemId?: number; // Service item ID
|
|
153
|
+
category?: string; // Support category
|
|
154
|
+
priority?: string; // Priority level
|
|
155
|
+
stage?: string; // Conversation stage
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Advanced Usage
|
|
160
|
+
|
|
161
|
+
### Using the Hook Directly
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { useChat } from "@aktarulrahul/floater-chatbot";
|
|
165
|
+
|
|
166
|
+
function CustomChat() {
|
|
167
|
+
const { messages, isLoading, sendMessage } = useChat({
|
|
168
|
+
webhookUrl: "http://localhost:5678/webhook/chat",
|
|
169
|
+
accessToken: "your-token",
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div>
|
|
174
|
+
{messages.map((msg) => (
|
|
175
|
+
<div key={msg.id}>{msg.text}</div>
|
|
176
|
+
))}
|
|
177
|
+
<button onClick={() => sendMessage("Hello!")}>Send</button>
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Using the API Client
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { ChatApiClient } from "@aktarulrahul/floater-chatbot";
|
|
187
|
+
|
|
188
|
+
const client = new ChatApiClient({
|
|
189
|
+
webhookUrl: "http://localhost:5678/webhook/chat",
|
|
190
|
+
accessToken: "your-token",
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const response = await client.sendMessage("Hello!");
|
|
194
|
+
console.log(response);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Response Format
|
|
198
|
+
|
|
199
|
+
The widget expects responses in the following format from your n8n workflow:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"success": true,
|
|
204
|
+
"response": "AI-generated answer",
|
|
205
|
+
"conversation_id": "conv-123",
|
|
206
|
+
"references": [
|
|
207
|
+
{
|
|
208
|
+
"id": "doc-id",
|
|
209
|
+
"pdf_name": "document.pdf",
|
|
210
|
+
"page_number": 1
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"ticket_id": "optional-ticket-id",
|
|
214
|
+
"ticket_url": "optional-ticket-url",
|
|
215
|
+
"customer_context": {
|
|
216
|
+
"name": "Customer Name",
|
|
217
|
+
"plan": "Premium"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## n8n Integration
|
|
223
|
+
|
|
224
|
+
This widget is designed to work with the n8n workflow provided in `templates/chat.json`. The workflow expects:
|
|
225
|
+
|
|
226
|
+
**Request:**
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"token": "user-access-token",
|
|
231
|
+
"message": "user question",
|
|
232
|
+
"conversation_id": "optional-conversation-id",
|
|
233
|
+
"api_endpoints": {
|
|
234
|
+
"profileApi": "https://api.example.com/profile",
|
|
235
|
+
"servicesApi": "https://api.example.com/services",
|
|
236
|
+
"zendeskApi": "https://your-domain.zendesk.com"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Styling
|
|
242
|
+
|
|
243
|
+
The widget includes default styles, but you can override them:
|
|
244
|
+
|
|
245
|
+
```css
|
|
246
|
+
.chat-widget-container {
|
|
247
|
+
/* Your custom styles */
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.chat-widget-button {
|
|
251
|
+
/* Button styles */
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.chat-widget-window {
|
|
255
|
+
/* Window styles */
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## TypeScript Support
|
|
260
|
+
|
|
261
|
+
Full TypeScript definitions are included:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
import {
|
|
265
|
+
ChatWidgetConfig,
|
|
266
|
+
ChatResponse,
|
|
267
|
+
ChatMessage,
|
|
268
|
+
} from "@aktarulrahul/floater-chatbot";
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Development
|
|
272
|
+
|
|
273
|
+
### Building the Package
|
|
274
|
+
|
|
275
|
+
To build the npm package:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
cd chat-widget
|
|
279
|
+
npm install
|
|
280
|
+
npm run build
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
This will create the compiled files in the `dist/` directory:
|
|
284
|
+
|
|
285
|
+
- `dist/index.js` - CommonJS bundle
|
|
286
|
+
- `dist/index.esm.js` - ES Module bundle
|
|
287
|
+
- `dist/index.d.ts` - TypeScript declarations
|
|
288
|
+
|
|
289
|
+
### Development Mode
|
|
290
|
+
|
|
291
|
+
For development with watch mode (auto-rebuild on changes):
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
npm run dev
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Publishing to NPM
|
|
298
|
+
|
|
299
|
+
For detailed instructions on building and publishing, see [BUILD.md](./BUILD.md).
|
|
300
|
+
|
|
301
|
+
Quick publish steps:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# 1. Update version
|
|
305
|
+
npm version patch # or minor, major
|
|
306
|
+
|
|
307
|
+
# 2. Build (runs automatically before publish)
|
|
308
|
+
npm run build
|
|
309
|
+
|
|
310
|
+
# 3. Publish
|
|
311
|
+
npm publish --access public
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Browser Support
|
|
315
|
+
|
|
316
|
+
- Chrome (latest)
|
|
317
|
+
- Firefox (latest)
|
|
318
|
+
- Safari (latest)
|
|
319
|
+
- Edge (latest)
|
|
320
|
+
|
|
321
|
+
## Contributing
|
|
322
|
+
|
|
323
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
324
|
+
|
|
325
|
+
1. Fork the repository
|
|
326
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
327
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
328
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
329
|
+
5. Open a Pull Request
|
|
330
|
+
|
|
331
|
+
## Repository
|
|
332
|
+
|
|
333
|
+
- **GitHub**: [https://github.com/Soft-Loop-Studio/chat-bot](https://github.com/Soft-Loop-Studio/chat-bot)
|
|
334
|
+
- **Issues**: [https://github.com/Soft-Loop-Studio/chat-bot/issues](https://github.com/Soft-Loop-Studio/chat-bot/issues)
|
|
335
|
+
|
|
336
|
+
## License
|
|
337
|
+
|
|
338
|
+
MIT License - see the [LICENSE](https://github.com/Soft-Loop-Studio/chat-bot/blob/main/LICENSE) file for details.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ChatWidgetConfig } from "../types";
|
|
3
|
+
import "./ChatWidget.css";
|
|
4
|
+
interface ChatWidgetProps {
|
|
5
|
+
config: ChatWidgetConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare const ChatWidget: React.FC<ChatWidgetProps>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ChatWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/ChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAe,MAAM,UAAU,CAAC;AAEzD,OAAO,kBAAkB,CAAC;AAE1B,UAAU,eAAe;IACvB,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAkNhD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ChatWidgetConfig } from "../types";
|
|
3
|
+
import "./SupportChatWidget.css";
|
|
4
|
+
interface SupportCategory {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}
|
|
10
|
+
interface PriorityLevel {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
color: string;
|
|
14
|
+
description: string;
|
|
15
|
+
}
|
|
16
|
+
interface SupportChatWidgetProps {
|
|
17
|
+
config: ChatWidgetConfig & {
|
|
18
|
+
/** Support-specific categories (optional, uses defaults if not provided) */
|
|
19
|
+
supportCategories?: SupportCategory[];
|
|
20
|
+
/** Priority levels (optional, uses defaults if not provided) */
|
|
21
|
+
priorityLevels?: PriorityLevel[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare const SupportChatWidget: React.FC<SupportChatWidgetProps>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=SupportChatWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupportChatWidget.d.ts","sourceRoot":"","sources":["../../src/components/SupportChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,yBAAyB,CAAC;AAEjC,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AA6BD,UAAU,sBAAsB;IAC9B,MAAM,EAAE,gBAAgB,GAAG;QACzB,4EAA4E;QAC5E,iBAAiB,CAAC,EAAE,eAAe,EAAE,CAAC;QACtC,gEAAgE;QAChE,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;KAClC,CAAC;CACH;AAwDD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAimB9D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChatMessage, ChatWidgetConfig } from "../types";
|
|
2
|
+
export declare const useChat: (config: ChatWidgetConfig) => {
|
|
3
|
+
messages: ChatMessage[];
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: string | null;
|
|
6
|
+
sendMessage: (text: string) => Promise<void>;
|
|
7
|
+
clearMessages: () => void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useChat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useChat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAgB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGvE,eAAO,MAAM,OAAO,GAAI,QAAQ,gBAAgB;;;;wBAO/B,MAAM;;CAsGtB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ChatWidgetConfig {
|
|
4
|
+
/** n8n webhook endpoint URL */
|
|
5
|
+
webhookUrl: string;
|
|
6
|
+
/** User access token for authentication */
|
|
7
|
+
accessToken: string;
|
|
8
|
+
/** Optional conversation ID for maintaining context */
|
|
9
|
+
conversationId?: string;
|
|
10
|
+
/** List of API endpoints to pass to n8n */
|
|
11
|
+
apiEndpoints?: {
|
|
12
|
+
profileApi?: string;
|
|
13
|
+
servicesApi?: string;
|
|
14
|
+
zendeskApi?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Widget appearance configuration */
|
|
17
|
+
appearance?: {
|
|
18
|
+
primaryColor?: string;
|
|
19
|
+
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
20
|
+
title?: string;
|
|
21
|
+
subtitle?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
showAvatar?: boolean;
|
|
24
|
+
avatarUrl?: string;
|
|
25
|
+
};
|
|
26
|
+
/** Callback functions */
|
|
27
|
+
callbacks?: {
|
|
28
|
+
onMessageSent?: (message: string) => void;
|
|
29
|
+
onMessageReceived?: (response: ChatResponse) => void;
|
|
30
|
+
onError?: (error: Error) => void;
|
|
31
|
+
onTicketCreated?: (ticketId: string, ticketUrl: string) => void;
|
|
32
|
+
};
|
|
33
|
+
/** Support-specific configuration (optional) */
|
|
34
|
+
supportConfig?: {
|
|
35
|
+
custOrgId?: number;
|
|
36
|
+
serviceItemId?: number;
|
|
37
|
+
category?: string;
|
|
38
|
+
priority?: string;
|
|
39
|
+
stage?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface ChatMessage {
|
|
43
|
+
id: string;
|
|
44
|
+
text: string;
|
|
45
|
+
sender: "user" | "bot";
|
|
46
|
+
timestamp: Date;
|
|
47
|
+
isLoading?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface ChatResponse {
|
|
50
|
+
success: boolean;
|
|
51
|
+
response: string;
|
|
52
|
+
conversation_id: string | null;
|
|
53
|
+
references?: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
pdf_name: string;
|
|
56
|
+
page_number: number;
|
|
57
|
+
}>;
|
|
58
|
+
ticket_id?: string;
|
|
59
|
+
ticket_url?: string;
|
|
60
|
+
customer_context?: {
|
|
61
|
+
name?: string;
|
|
62
|
+
plan?: string;
|
|
63
|
+
};
|
|
64
|
+
error?: string;
|
|
65
|
+
}
|
|
66
|
+
interface ApiEndpoints {
|
|
67
|
+
profileApi?: string;
|
|
68
|
+
servicesApi?: string;
|
|
69
|
+
zendeskApi?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface ChatWidgetProps {
|
|
73
|
+
config: ChatWidgetConfig;
|
|
74
|
+
}
|
|
75
|
+
declare const ChatWidget: React.FC<ChatWidgetProps>;
|
|
76
|
+
|
|
77
|
+
interface SupportCategory {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
icon: string;
|
|
81
|
+
description: string;
|
|
82
|
+
}
|
|
83
|
+
interface PriorityLevel {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
color: string;
|
|
87
|
+
description: string;
|
|
88
|
+
}
|
|
89
|
+
interface SupportChatWidgetProps {
|
|
90
|
+
config: ChatWidgetConfig & {
|
|
91
|
+
/** Support-specific categories (optional, uses defaults if not provided) */
|
|
92
|
+
supportCategories?: SupportCategory[];
|
|
93
|
+
/** Priority levels (optional, uses defaults if not provided) */
|
|
94
|
+
priorityLevels?: PriorityLevel[];
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
declare const SupportChatWidget: React.FC<SupportChatWidgetProps>;
|
|
98
|
+
|
|
99
|
+
declare const useChat: (config: ChatWidgetConfig) => {
|
|
100
|
+
messages: ChatMessage[];
|
|
101
|
+
isLoading: boolean;
|
|
102
|
+
error: string | null;
|
|
103
|
+
sendMessage: (text: string) => Promise<void>;
|
|
104
|
+
clearMessages: () => void;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
declare class ChatApiClient {
|
|
108
|
+
private client;
|
|
109
|
+
private config;
|
|
110
|
+
private conversationId;
|
|
111
|
+
constructor(config: ChatWidgetConfig);
|
|
112
|
+
/**
|
|
113
|
+
* Send a message to the chat API
|
|
114
|
+
*/
|
|
115
|
+
sendMessage(message: string, additionalData?: {
|
|
116
|
+
custOrgId?: number;
|
|
117
|
+
serviceItemId?: number;
|
|
118
|
+
category?: string;
|
|
119
|
+
priority?: string;
|
|
120
|
+
stage?: string;
|
|
121
|
+
}): Promise<ChatResponse>;
|
|
122
|
+
/**
|
|
123
|
+
* Get current conversation ID
|
|
124
|
+
*/
|
|
125
|
+
getConversationId(): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Set conversation ID
|
|
128
|
+
*/
|
|
129
|
+
setConversationId(id: string | null): void;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { ChatApiClient, ChatWidget, SupportChatWidget, useChat };
|
|
133
|
+
export type { ApiEndpoints, ChatMessage, ChatResponse, ChatWidgetConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|