nextjs-chatbot-ui 1.0.0 → 1.1.0

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.
Files changed (2) hide show
  1. package/README.md +468 -317
  2. package/package.json +68 -62
package/README.md CHANGED
@@ -1,317 +1,468 @@
1
- # Chatbot UI Component
2
-
3
- A beautiful, configurable chatbot UI component for Next.js applications with Tailwind CSS. Inspired by Sendbird's modern chat interface.
4
-
5
- ## Features
6
-
7
- - 🎨 Modern, Sendbird-inspired UI design
8
- - ⚙️ Fully configurable (labels, position, colors, backend URL)
9
- - 📱 Responsive and mobile-friendly
10
- - 🎯 TypeScript support
11
- - 🚀 Easy to integrate
12
- - 💬 Real-time messaging support
13
- - 🎭 Customizable user and bot avatars
14
- - ⏰ Optional timestamp display
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install nextjs-nextjs-chatbot-ui
20
- ```
21
-
22
- ## Usage
23
-
24
- ### Basic Setup
25
-
26
- 1. **Configure Tailwind CSS** - Make sure your `tailwind.config.js` includes the component:
27
-
28
- ```javascript
29
- // tailwind.config.js
30
- module.exports = {
31
- content: [
32
- './node_modules/nextjs-chatbot-ui/**/*.{js,ts,jsx,tsx}',
33
- './app/**/*.{js,ts,jsx,tsx,mdx}',
34
- './pages/**/*.{js,ts,jsx,tsx,mdx}',
35
- './components/**/*.{js,ts,jsx,tsx,mdx}',
36
- ],
37
- // ... rest of your config
38
- }
39
- ```
40
-
41
- 2. **Import the component and types**:
42
-
43
- ```javascript
44
- import { Chatbot } from 'nextjs-nextjs-chatbot-ui';
45
- import type { ChatbotConfig } from 'nextjs-nextjs-chatbot-ui';
46
- ```
47
-
48
- 2. Configure and use the component:
49
-
50
- ```javascript
51
- const config: ChatbotConfig = {
52
- backendUrl: 'https://your-backend-api.com/chat',
53
- labels: {
54
- title: 'Support Chat',
55
- placeholder: 'Type your message...',
56
- sendButton: 'Send',
57
- welcomeMessage: 'Hello! How can I help you?',
58
- },
59
- position: 'bottom-right',
60
- botInfo: {
61
- name: 'Support Bot',
62
- avatar: 'https://example.com/bot-avatar.png',
63
- },
64
- userInfo: {
65
- name: 'User',
66
- avatar: 'https://example.com/user-avatar.png',
67
- },
68
- primaryColor: '#0ea5e9',
69
- autoOpen: false,
70
- showTimestamp: true,
71
- };
72
-
73
- export default function Page() {
74
- return <Chatbot config={config} />;
75
- }
76
- ```
77
-
78
- ### Configuration Options
79
-
80
- #### `ChatbotConfig` Interface
81
-
82
- ```typescript
83
- interface ChatbotConfig {
84
- // Required
85
- backendUrl: string; // Your backend API endpoint for handling messages
86
-
87
- // Optional Labels
88
- labels?: {
89
- title?: string; // Chat header title (default: "Chat Support")
90
- placeholder?: string; // Input placeholder (default: "Type your message...")
91
- sendButton?: string; // Send button text (default: "Send")
92
- typingIndicator?: string; // Loading message (default: "Typing...")
93
- welcomeMessage?: string; // Initial bot message (default: "Hello! How can I help you today?")
94
- errorMessage?: string; // Error message (default: "Sorry, something went wrong. Please try again.")
95
- };
96
-
97
- // Position
98
- position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; // Default: 'bottom-right'
99
-
100
- // User Information
101
- userInfo?: {
102
- name?: string; // User name
103
- avatar?: string; // User avatar URL
104
- };
105
-
106
- // Bot Information
107
- botInfo?: {
108
- name?: string; // Bot name (default: uses title)
109
- avatar?: string; // Bot avatar URL
110
- };
111
-
112
- // Styling
113
- primaryColor?: string; // Primary color (hex code)
114
- backgroundColor?: string; // Chat background color (hex code)
115
-
116
- // Behavior
117
- autoOpen?: boolean; // Auto-open chat on load (default: false)
118
- showTimestamp?: boolean; // Show message timestamps (default: false)
119
- showDateSeparator?: boolean; // Show date separators between messages (default: false)
120
- poweredByText?: string; // Footer text (e.g., "Powered by sendbird")
121
- }
122
- ```
123
-
124
- ### Backend API Requirements
125
-
126
- Your backend should accept POST requests with the following format:
127
-
128
- **Request:**
129
- ```json
130
- {
131
- "message": "User's message text",
132
- "userInfo": {
133
- "name": "User",
134
- "avatar": "https://example.com/avatar.png"
135
- }
136
- }
137
- ```
138
-
139
- **Response:**
140
- ```json
141
- {
142
- "message": "Bot's response text",
143
- "suggestedReplies": ["Option 1", "Option 2", "Option 3"]
144
- }
145
- ```
146
-
147
- or
148
-
149
- ```json
150
- {
151
- "response": "Bot's response text",
152
- "suggestions": ["Option 1", "Option 2", "Option 3"]
153
- }
154
- ```
155
-
156
- **Note:** The `suggestedReplies` or `suggestions` field is optional and will display as clickable buttons below the bot's message, similar to Sendbird's interface.
157
-
158
- ### Example Implementation
159
-
160
- ```javascript
161
- // pages/index.js or app/page.js
162
- 'use client';
163
-
164
- import { Chatbot } from 'nextjs-nextjs-chatbot-ui';
165
- import type { ChatbotConfig } from 'nextjs-nextjs-chatbot-ui';
166
-
167
- export default function Home() {
168
- const chatbotConfig: ChatbotConfig = {
169
- backendUrl: 'https://api.example.com/chat',
170
- labels: {
171
- title: 'Customer Support',
172
- placeholder: 'Ask us anything...',
173
- sendButton: 'Send',
174
- welcomeMessage: 'Welcome! We\'re here to help.',
175
- },
176
- position: 'bottom-right',
177
- botInfo: {
178
- name: 'Support Assistant',
179
- avatar: '/bot-avatar.png',
180
- },
181
- userInfo: {
182
- name: 'Guest User',
183
- },
184
- primaryColor: '#6B46C1', // Purple like Sendbird
185
- autoOpen: false,
186
- showTimestamp: true,
187
- showDateSeparator: true,
188
- poweredByText: 'Powered by nextjs-nextjs-chatbot-ui',
189
- };
190
-
191
- return (
192
- <div>
193
- <h1>My Website</h1>
194
- <Chatbot config={chatbotConfig} />
195
- </div>
196
- );
197
- }
198
- ```
199
-
200
- ### Tailwind CSS Setup
201
-
202
- Make sure you have Tailwind CSS configured in your Next.js project. The component uses Tailwind classes, so ensure your `tailwind.config.js` includes the component:
203
-
204
- ```javascript
205
- // tailwind.config.js
206
- module.exports = {
207
- content: [
208
- './node_modules/nextjs-chatbot-ui/**/*.{js,ts,jsx,tsx}',
209
- // ... your other paths
210
- ],
211
- // ... rest of your config
212
- }
213
- ```
214
-
215
- ## Development
216
-
217
- To develop or modify this package:
218
-
219
- ```bash
220
- # Install dependencies
221
- npm install
222
-
223
- # Run development server
224
- npm run dev
225
-
226
- # Build for production
227
- npm run build
228
- ```
229
-
230
- ## Admin Setup Component
231
-
232
- The package also includes an `AdminSetup` component for configuring database connections in your admin panel.
233
-
234
- ### Usage
235
-
236
- ```javascript
237
- import { AdminSetup } from 'nextjs-nextjs-chatbot-ui';
238
- import type { DatabaseConfig, DatabaseConnection } from 'nextjs-nextjs-chatbot-ui';
239
-
240
- function AdminPanel() {
241
- const handleSave = (config: DatabaseConfig) => {
242
- // Save configuration to your backend
243
- console.log('Config:', config);
244
- };
245
-
246
- const handleTestConnection = async (connection: DatabaseConnection) => {
247
- // Test database connection
248
- const response = await fetch('/api/database/test', {
249
- method: 'POST',
250
- body: JSON.stringify(connection),
251
- });
252
- return response.ok;
253
- };
254
-
255
- const handleFetchColumns = async (connection: DatabaseConnection) => {
256
- // Fetch columns from database
257
- const response = await fetch('/api/database/columns', {
258
- method: 'POST',
259
- body: JSON.stringify(connection),
260
- });
261
- const data = await response.json();
262
- return data.columns || [];
263
- };
264
-
265
- return (
266
- <aside className="sidebar">
267
- <AdminSetup
268
- onSave={handleSave}
269
- onTestConnection={handleTestConnection}
270
- onFetchColumns={handleFetchColumns}
271
- />
272
- </aside>
273
- );
274
- }
275
- ```
276
-
277
- ### Features
278
-
279
- - **Database Selection**: Choose between MongoDB and PostgreSQL
280
- - **Connection Configuration**: Configure all necessary connection parameters
281
- - **Connection Testing**: Test database connection before proceeding
282
- - **Column Selection**: Select columns for:
283
- - Embedding processing
284
- - LLM processing
285
- - ChromaDB storage
286
- - **Modal Interface**: Clean, step-by-step modal interface
287
- - **Sidebar Integration**: Ready to integrate into admin panel sidebars
288
-
289
- ### Database Configuration
290
-
291
- The component supports:
292
- - **MongoDB**: Connection string or individual fields (host, port, database, SSL)
293
- - **PostgreSQL**: Host, port, database, username, password, SSL
294
-
295
- ### Backend API Requirements
296
-
297
- Your backend should provide:
298
-
299
- 1. **Test Connection Endpoint** (`POST /api/database/test`)
300
- - Accepts `DatabaseConnection` object
301
- - Returns success/failure status
302
-
303
- 2. **Fetch Columns Endpoint** (`POST /api/database/columns`)
304
- - Accepts `DatabaseConnection` object
305
- - Returns array of column names
306
-
307
- 3. **Save Configuration Endpoint** (your implementation)
308
- - Accepts `DatabaseConfig` object
309
- - Saves configuration to your storage
310
-
311
- ## License
312
-
313
- MIT
314
-
315
- ## Contributing
316
-
317
- Contributions are welcome! Please feel free to submit a Pull Request.
1
+ # Chatbot UI Component
2
+
3
+ A beautiful, configurable chatbot UI component for Next.js applications with Tailwind CSS. Inspired by Sendbird's modern chat interface.
4
+
5
+ ## Features
6
+
7
+ - 🎨 Modern, Sendbird-inspired UI design
8
+ - ⚙️ Fully configurable (labels, position, colors, backend URL)
9
+ - 📱 Responsive and mobile-friendly
10
+ - 🎯 TypeScript support
11
+ - 🚀 Easy to integrate
12
+ - 💬 Real-time messaging support
13
+ - 🎭 Customizable user and bot avatars
14
+ - ⏰ Optional timestamp display
15
+
16
+ ## Compatibility Requirements
17
+
18
+ This package requires:
19
+ - **Next.js 13+** (with App Router or Pages Router support)
20
+ - **React 18+**
21
+ - **TypeScript** (optional, but recommended)
22
+ - **Tailwind CSS 3+** (must be configured in your project)
23
+
24
+ **Important Notes:**
25
+ - The package exports TypeScript source files directly, which Next.js will compile automatically
26
+ - Make sure your `tailwind.config.js` includes the package path in the `content` array
27
+ - This package uses the `'use client'` directive and requires client-side rendering
28
+ - Works with both **App Router** (`app/` directory) and **Pages Router** (`pages/` directory)
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ npm install nextjs-chatbot-ui
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### Basic Setup
39
+
40
+ **Step 1: Configure Next.js** - Add the package to your `next.config.js`:
41
+
42
+ ```javascript
43
+ // next.config.js
44
+ /** @type {import('next').NextConfig} */
45
+ const nextConfig = {
46
+ transpilePackages: ['nextjs-chatbot-ui'],
47
+ // ... your other config
48
+ }
49
+
50
+ module.exports = nextConfig
51
+ ```
52
+
53
+ **Step 2: Configure Tailwind CSS** - Make sure your `tailwind.config.js` includes the component:
54
+
55
+ ```javascript
56
+ // tailwind.config.js
57
+ module.exports = {
58
+ content: [
59
+ './node_modules/nextjs-chatbot-ui/**/*.{js,ts,jsx,tsx}',
60
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
61
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
62
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
63
+ ],
64
+ // ... rest of your config
65
+ }
66
+ ```
67
+
68
+ **Step 3: Import and use the component**:
69
+
70
+ For **App Router** (app directory):
71
+ ```javascript
72
+ // app/page.tsx or app/any-page.tsx
73
+ 'use client'; // Required for App Router
74
+
75
+ import { Chatbot } from 'nextjs-chatbot-ui';
76
+ import type { ChatbotConfig } from 'nextjs-chatbot-ui';
77
+ ```
78
+
79
+ For **Pages Router** (pages directory):
80
+ ```javascript
81
+ // pages/index.js or pages/any-page.js
82
+ import { Chatbot } from 'nextjs-chatbot-ui';
83
+ import type { ChatbotConfig } from 'nextjs-chatbot-ui';
84
+ ```
85
+
86
+ **Step 4: Configure and use the component**:
87
+
88
+ ```javascript
89
+ const config: ChatbotConfig = {
90
+ backendUrl: 'https://your-backend-api.com/chat',
91
+ labels: {
92
+ title: 'Support Chat',
93
+ placeholder: 'Type your message...',
94
+ sendButton: 'Send',
95
+ welcomeMessage: 'Hello! How can I help you?',
96
+ },
97
+ position: 'bottom-right',
98
+ botInfo: {
99
+ name: 'Support Bot',
100
+ avatar: 'https://example.com/bot-avatar.png',
101
+ },
102
+ userInfo: {
103
+ name: 'User',
104
+ avatar: 'https://example.com/user-avatar.png',
105
+ },
106
+ primaryColor: '#0ea5e9',
107
+ autoOpen: false,
108
+ showTimestamp: true,
109
+ };
110
+
111
+ export default function Page() {
112
+ return (
113
+ <div>
114
+ <h1>My Website</h1>
115
+ <Chatbot config={config} />
116
+ </div>
117
+ );
118
+ }
119
+ ```
120
+
121
+ ### Complete Example (App Router)
122
+
123
+ ```javascript
124
+ // app/page.tsx
125
+ 'use client';
126
+
127
+ import { Chatbot } from 'nextjs-chatbot-ui';
128
+ import type { ChatbotConfig } from 'nextjs-chatbot-ui';
129
+
130
+ export default function Home() {
131
+ const config: ChatbotConfig = {
132
+ backendUrl: 'https://api.example.com/chat',
133
+ labels: {
134
+ title: 'Support Chat',
135
+ placeholder: 'Type your message...',
136
+ sendButton: 'Send',
137
+ welcomeMessage: 'Hello! How can I help you today?',
138
+ },
139
+ position: 'bottom-right',
140
+ botInfo: {
141
+ name: 'Support Bot',
142
+ },
143
+ userInfo: {
144
+ name: 'User',
145
+ },
146
+ primaryColor: '#6B46C1',
147
+ autoOpen: false,
148
+ showTimestamp: true,
149
+ };
150
+
151
+ return (
152
+ <main>
153
+ <h1>Welcome to My Site</h1>
154
+ <Chatbot config={config} />
155
+ </main>
156
+ );
157
+ }
158
+ ```
159
+
160
+ ### Complete Example (Pages Router)
161
+
162
+ ```javascript
163
+ // pages/index.js
164
+ import { Chatbot } from 'nextjs-chatbot-ui';
165
+
166
+ export default function Home() {
167
+ const config = {
168
+ backendUrl: 'https://api.example.com/chat',
169
+ labels: {
170
+ title: 'Support Chat',
171
+ placeholder: 'Type your message...',
172
+ },
173
+ position: 'bottom-right',
174
+ };
175
+
176
+ return (
177
+ <div>
178
+ <h1>Welcome to My Site</h1>
179
+ <Chatbot config={config} />
180
+ </div>
181
+ );
182
+ }
183
+ ```
184
+
185
+ ### Configuration Options
186
+
187
+ #### `ChatbotConfig` Interface
188
+
189
+ ```typescript
190
+ interface ChatbotConfig {
191
+ // Required
192
+ backendUrl: string; // Your backend API endpoint for handling messages
193
+
194
+ // Optional Labels
195
+ labels?: {
196
+ title?: string; // Chat header title (default: "Chat Support")
197
+ placeholder?: string; // Input placeholder (default: "Type your message...")
198
+ sendButton?: string; // Send button text (default: "Send")
199
+ typingIndicator?: string; // Loading message (default: "Typing...")
200
+ welcomeMessage?: string; // Initial bot message (default: "Hello! How can I help you today?")
201
+ errorMessage?: string; // Error message (default: "Sorry, something went wrong. Please try again.")
202
+ };
203
+
204
+ // Position
205
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; // Default: 'bottom-right'
206
+
207
+ // User Information
208
+ userInfo?: {
209
+ name?: string; // User name
210
+ avatar?: string; // User avatar URL
211
+ };
212
+
213
+ // Bot Information
214
+ botInfo?: {
215
+ name?: string; // Bot name (default: uses title)
216
+ avatar?: string; // Bot avatar URL
217
+ };
218
+
219
+ // Styling
220
+ primaryColor?: string; // Primary color (hex code)
221
+ backgroundColor?: string; // Chat background color (hex code)
222
+
223
+ // Behavior
224
+ autoOpen?: boolean; // Auto-open chat on load (default: false)
225
+ showTimestamp?: boolean; // Show message timestamps (default: false)
226
+ showDateSeparator?: boolean; // Show date separators between messages (default: false)
227
+ poweredByText?: string; // Footer text (e.g., "Powered by sendbird")
228
+ }
229
+ ```
230
+
231
+ ### Backend API Requirements
232
+
233
+ Your backend should accept POST requests with the following format:
234
+
235
+ **Request:**
236
+ ```json
237
+ {
238
+ "message": "User's message text",
239
+ "userInfo": {
240
+ "name": "User",
241
+ "avatar": "https://example.com/avatar.png"
242
+ }
243
+ }
244
+ ```
245
+
246
+ **Response:**
247
+ ```json
248
+ {
249
+ "message": "Bot's response text",
250
+ "suggestedReplies": ["Option 1", "Option 2", "Option 3"]
251
+ }
252
+ ```
253
+
254
+ or
255
+
256
+ ```json
257
+ {
258
+ "response": "Bot's response text",
259
+ "suggestions": ["Option 1", "Option 2", "Option 3"]
260
+ }
261
+ ```
262
+
263
+ **Note:** The `suggestedReplies` or `suggestions` field is optional and will display as clickable buttons below the bot's message, similar to Sendbird's interface.
264
+
265
+ ### Example Implementation
266
+
267
+ ```javascript
268
+ // pages/index.js or app/page.js
269
+ 'use client';
270
+
271
+ import { Chatbot } from 'nextjs-chatbot-ui';
272
+ import type { ChatbotConfig } from 'nextjs-chatbot-ui';
273
+
274
+ export default function Home() {
275
+ const chatbotConfig: ChatbotConfig = {
276
+ backendUrl: 'https://api.example.com/chat',
277
+ labels: {
278
+ title: 'Customer Support',
279
+ placeholder: 'Ask us anything...',
280
+ sendButton: 'Send',
281
+ welcomeMessage: 'Welcome! We\'re here to help.',
282
+ },
283
+ position: 'bottom-right',
284
+ botInfo: {
285
+ name: 'Support Assistant',
286
+ avatar: '/bot-avatar.png',
287
+ },
288
+ userInfo: {
289
+ name: 'Guest User',
290
+ },
291
+ primaryColor: '#6B46C1', // Purple like Sendbird
292
+ autoOpen: false,
293
+ showTimestamp: true,
294
+ showDateSeparator: true,
295
+ poweredByText: 'Powered by nextjs-chatbot-ui',
296
+ };
297
+
298
+ return (
299
+ <div>
300
+ <h1>My Website</h1>
301
+ <Chatbot config={chatbotConfig} />
302
+ </div>
303
+ );
304
+ }
305
+ ```
306
+
307
+ ### Tailwind CSS Setup
308
+
309
+ Make sure you have Tailwind CSS configured in your Next.js project. The component uses Tailwind classes, so ensure your `tailwind.config.js` includes the component:
310
+
311
+ ```javascript
312
+ // tailwind.config.js
313
+ module.exports = {
314
+ content: [
315
+ './node_modules/nextjs-chatbot-ui/**/*.{js,ts,jsx,tsx}',
316
+ // ... your other paths
317
+ ],
318
+ // ... rest of your config
319
+ }
320
+ ```
321
+
322
+ ## Development
323
+
324
+ To develop or modify this package:
325
+
326
+ ```bash
327
+ # Install dependencies
328
+ npm install
329
+
330
+ # Run development server
331
+ npm run dev
332
+
333
+ # Build for production
334
+ npm run build
335
+ ```
336
+
337
+ ## Admin Setup Component
338
+
339
+ The package also includes an `AdminSetup` component for configuring database connections in your admin panel.
340
+
341
+ ### Usage
342
+
343
+ ```javascript
344
+ import { AdminSetup } from 'nextjs-chatbot-ui';
345
+ import type { DatabaseConfig, DatabaseConnection } from 'nextjs-chatbot-ui';
346
+
347
+ function AdminPanel() {
348
+ const handleSave = (config: DatabaseConfig) => {
349
+ // Save configuration to your backend
350
+ console.log('Config:', config);
351
+ };
352
+
353
+ const handleTestConnection = async (connection: DatabaseConnection) => {
354
+ // Test database connection
355
+ const response = await fetch('/api/database/test', {
356
+ method: 'POST',
357
+ body: JSON.stringify(connection),
358
+ });
359
+ return response.ok;
360
+ };
361
+
362
+ const handleFetchColumns = async (connection: DatabaseConnection) => {
363
+ // Fetch columns from database
364
+ const response = await fetch('/api/database/columns', {
365
+ method: 'POST',
366
+ body: JSON.stringify(connection),
367
+ });
368
+ const data = await response.json();
369
+ return data.columns || [];
370
+ };
371
+
372
+ return (
373
+ <aside className="sidebar">
374
+ <AdminSetup
375
+ onSave={handleSave}
376
+ onTestConnection={handleTestConnection}
377
+ onFetchColumns={handleFetchColumns}
378
+ />
379
+ </aside>
380
+ );
381
+ }
382
+ ```
383
+
384
+ ### Features
385
+
386
+ - **Database Selection**: Choose between MongoDB and PostgreSQL
387
+ - **Connection Configuration**: Configure all necessary connection parameters
388
+ - **Connection Testing**: Test database connection before proceeding
389
+ - **Column Selection**: Select columns for:
390
+ - Embedding processing
391
+ - LLM processing
392
+ - ChromaDB storage
393
+ - **Modal Interface**: Clean, step-by-step modal interface
394
+ - **Sidebar Integration**: Ready to integrate into admin panel sidebars
395
+
396
+ ### Database Configuration
397
+
398
+ The component supports:
399
+ - **MongoDB**: Connection string or individual fields (host, port, database, SSL)
400
+ - **PostgreSQL**: Host, port, database, username, password, SSL
401
+
402
+ ### Backend API Requirements
403
+
404
+ Your backend should provide:
405
+
406
+ 1. **Test Connection Endpoint** (`POST /api/database/test`)
407
+ - Accepts `DatabaseConnection` object
408
+ - Returns success/failure status
409
+
410
+ 2. **Fetch Columns Endpoint** (`POST /api/database/columns`)
411
+ - Accepts `DatabaseConnection` object
412
+ - Returns array of column names
413
+
414
+ 3. **Save Configuration Endpoint** (your implementation)
415
+ - Accepts `DatabaseConfig` object
416
+ - Saves configuration to your storage
417
+
418
+ ## Troubleshooting
419
+
420
+ ### Component not rendering or styles not working
421
+
422
+ 1. **Check Tailwind Configuration**: Make sure `nextjs-chatbot-ui` is in your `tailwind.config.js` content array:
423
+ ```javascript
424
+ content: [
425
+ './node_modules/nextjs-chatbot-ui/**/*.{js,ts,jsx,tsx}',
426
+ // ... other paths
427
+ ]
428
+ ```
429
+
430
+ 2. **Check Next.js Configuration**: Ensure `transpilePackages` is set in `next.config.js`:
431
+ ```javascript
432
+ transpilePackages: ['nextjs-chatbot-ui']
433
+ ```
434
+
435
+ 3. **Restart Development Server**: After configuration changes, restart your Next.js dev server.
436
+
437
+ ### TypeScript Errors
438
+
439
+ If you see TypeScript errors:
440
+ - Make sure you're using TypeScript 5+ (optional but recommended)
441
+ - The package includes type definitions, so TypeScript should work out of the box
442
+ - If using JavaScript, you can ignore type imports: `import { Chatbot } from 'nextjs-chatbot-ui';`
443
+
444
+ ### "Module not found" or Import Errors
445
+
446
+ 1. **Verify Installation**: Run `npm install nextjs-chatbot-ui` again
447
+ 2. **Check Node Modules**: Ensure the package exists in `node_modules/nextjs-chatbot-ui`
448
+ 3. **Clear Cache**: Try deleting `.next` folder and `node_modules`, then reinstall
449
+
450
+ ### Component not appearing
451
+
452
+ - Make sure you're using `'use client'` directive in App Router
453
+ - Check that the component is not hidden by CSS (z-index, overflow, etc.)
454
+ - Verify the `position` prop is set correctly
455
+
456
+ ### Backend API Issues
457
+
458
+ - Ensure your backend URL is correct and accessible
459
+ - Check CORS settings if making cross-origin requests
460
+ - Verify the API response format matches the expected structure (see Backend API Requirements)
461
+
462
+ ## License
463
+
464
+ MIT
465
+
466
+ ## Contributing
467
+
468
+ Contributions are welcome! Please feel free to submit a Pull Request.
package/package.json CHANGED
@@ -1,62 +1,68 @@
1
- {
2
- "name": "nextjs-chatbot-ui",
3
-
4
- "version": "1.0.0",
5
- "description": "A configurable chatbot UI component for Next.js with Tailwind CSS",
6
- "main": "./index.tsx",
7
- "types": "./types/index.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./index.tsx",
11
- "require": "./index.tsx",
12
- "types": "./types/index.ts"
13
- },
14
- "./components/Chatbot": {
15
- "import": "./components/Chatbot.tsx",
16
- "require": "./components/Chatbot.tsx"
17
- },
18
- "./types": {
19
- "import": "./types/index.ts",
20
- "require": "./types/index.ts",
21
- "types": "./types/index.ts"
22
- }
23
- },
24
- "files": [
25
- "components",
26
- "types",
27
- "index.tsx",
28
- "README.md"
29
- ],
30
- "scripts": {
31
- "build": "echo 'Package is ready to use. Source files are included.'",
32
- "dev": "next dev",
33
- "prepare": "npm run build"
34
- },
35
- "keywords": [
36
- "chatbot",
37
- "ui",
38
- "component",
39
- "nextjs",
40
- "tailwind",
41
- "react"
42
- ],
43
- "author": "",
44
- "license": "MIT",
45
- "peerDependencies": {
46
- "react": "^18.0.0",
47
- "react-dom": "^18.0.0",
48
- "next": "^14.0.0"
49
- },
50
- "dependencies": {
51
- "clsx": "^2.1.0"
52
- },
53
- "devDependencies": {
54
- "@types/node": "^20.0.0",
55
- "@types/react": "^18.0.0",
56
- "@types/react-dom": "^18.0.0",
57
- "autoprefixer": "^10.4.16",
58
- "postcss": "^8.4.32",
59
- "tailwindcss": "^3.4.0",
60
- "typescript": "^5.3.3"
61
- }
62
- }
1
+ {
2
+ "name": "nextjs-chatbot-ui",
3
+
4
+ "version": "1.1.0",
5
+ "description": "A configurable chatbot UI component for Next.js with Tailwind CSS",
6
+ "main": "./index.tsx",
7
+ "module": "./index.tsx",
8
+ "types": "./types/index.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/index.ts",
12
+ "import": "./index.tsx",
13
+ "require": "./index.tsx",
14
+ "default": "./index.tsx"
15
+ },
16
+ "./components/Chatbot": {
17
+ "types": "./types/index.ts",
18
+ "import": "./components/Chatbot.tsx",
19
+ "require": "./components/Chatbot.tsx",
20
+ "default": "./components/Chatbot.tsx"
21
+ },
22
+ "./types": {
23
+ "types": "./types/index.ts",
24
+ "import": "./types/index.ts",
25
+ "require": "./types/index.ts",
26
+ "default": "./types/index.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "components",
31
+ "types",
32
+ "index.tsx",
33
+ "README.md"
34
+ ],
35
+ "scripts": {
36
+ "build": "echo 'Package is ready to use. Source files are included.'",
37
+ "dev": "next dev",
38
+ "prepare": "npm run build",
39
+ "type-check": "tsc --noEmit"
40
+ },
41
+ "keywords": [
42
+ "chatbot",
43
+ "ui",
44
+ "component",
45
+ "nextjs",
46
+ "tailwind",
47
+ "react"
48
+ ],
49
+ "author": "",
50
+ "license": "MIT",
51
+ "peerDependencies": {
52
+ "react": "^18.0.0 || ^19.0.0",
53
+ "react-dom": "^18.0.0 || ^19.0.0",
54
+ "next": "^13.0.0 || ^14.0.0 || ^15.0.0"
55
+ },
56
+ "dependencies": {
57
+ "clsx": "^2.1.0"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^20.0.0",
61
+ "@types/react": "^18.0.0",
62
+ "@types/react-dom": "^18.0.0",
63
+ "autoprefixer": "^10.4.16",
64
+ "postcss": "^8.4.32",
65
+ "tailwindcss": "^3.4.0",
66
+ "typescript": "^5.3.3"
67
+ }
68
+ }