@developer.notchatbot/webchat 1.0.1 → 1.0.3

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 CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  A beautiful, embeddable chatbot widget built with **React**, **TypeScript**, **Vite**, **pnpm** and **Tailwind CSS** that can be easily integrated into any website with **just one file**.
4
4
 
5
- ![WebChat Widget Demo](https://via.placeholder.com/600x400/667eea/ffffff?text=TypeScript+React+WebChat+Widget)
6
-
7
5
  ## ✨ Features
8
6
 
9
7
  - **📦 Single File Bundle**: Everything in one file - no separate CSS needed!
@@ -31,7 +29,6 @@ A beautiful, embeddable chatbot widget built with **React**, **TypeScript**, **V
31
29
  <script src="https://your-cdn.com/webchat-bundle.min.umd.cjs"></script>
32
30
  <script>
33
31
  WebChat.initialize({
34
- elementId: "webchat-component",
35
32
  title: "Customer Support",
36
33
  placeholder: "Ask us anything...",
37
34
  primaryColor: "#667eea"
@@ -47,12 +44,10 @@ The chatbot button will appear in the bottom-right corner of your page. CSS is a
47
44
 
48
45
  ```typescript
49
46
  interface WebChatConfig {
50
- elementId: string; // Required: ID of the container element
51
47
  title?: string; // Chat window title
52
48
  placeholder?: string; // Input placeholder text
53
49
  primaryColor?: string; // Primary theme color
54
50
  apiKey?: string; // Your chatbot UID (required for API)
55
- chatbotId?: number; // Your chatbot ID
56
51
  position?: 'bottom-right' | 'bottom-left'; // Widget position
57
52
  initialMessage?: string; // Custom initial bot message
58
53
  closeButtonIcon?: 'default' | 'text' | 'custom'; // Close button type
@@ -60,7 +55,6 @@ interface WebChatConfig {
60
55
  closeButtonCustomIcon?: string; // Custom icon SVG or URL (when type is 'custom')
61
56
  marginBottom?: number; // Distance from bottom edge in pixels (default: 16)
62
57
  marginSide?: number; // Distance from left/right edge in pixels (default: 16)
63
- aiEnabled?: boolean; // Enable/disable AI responses (default: true)
64
58
  mobile?: WebChatPositionConfig; // Mobile-specific position settings
65
59
  desktop?: WebChatPositionConfig; // Desktop-specific position settings
66
60
  }
@@ -72,18 +66,15 @@ interface WebChatPositionConfig {
72
66
  }
73
67
 
74
68
  WebChat.initialize({
75
- elementId: "webchat-component",
76
69
  title: "Chat Assistant",
77
70
  placeholder: "Type your message...",
78
71
  primaryColor: "#007bff",
79
72
  apiKey: "your-chatbot-uid", // Chatbot UID from admin panel
80
- chatbotId: 123, // Chatbot ID from admin panel
81
73
  position: "bottom-right",
82
74
  initialMessage: "¡Hola! 👋 Soy tu asistente virtual. ¿En qué puedo ayudarte hoy?",
83
75
  closeButtonIcon: "default", // or "text" or "custom"
84
76
  marginBottom: 20, // Distance from bottom edge (default: 16px)
85
77
  marginSide: 20, // Distance from side edge (default: 16px)
86
- aiEnabled: true, // Enable AI responses (default: true)
87
78
  // Device-specific overrides
88
79
  mobile: {
89
80
  position: "bottom-left",
@@ -103,7 +94,6 @@ WebChat.initialize({
103
94
  ### Colors
104
95
  ```javascript
105
96
  WebChat.initialize({
106
- elementId: "webchat-component",
107
97
  primaryColor: "#ff6b6b", // Custom brand color
108
98
  // ... other options
109
99
  });
@@ -118,9 +108,7 @@ The WebChat widget automatically detects the environment and uses the appropriat
118
108
 
119
109
  ```javascript
120
110
  WebChat.initialize({
121
- elementId: "webchat-component",
122
111
  apiKey: "your-chatbot-uid", // Chatbot UID from your Next.js admin panel
123
- chatbotId: 123, // Chatbot ID from your Next.js admin panel
124
112
  // Endpoints are automatically configured based on environment
125
113
  // No need to specify apiEndpoint manually
126
114
  });
@@ -142,7 +130,6 @@ Customize the first message your users see when they open the chat:
142
130
 
143
131
  ```javascript
144
132
  WebChat.initialize({
145
- elementId: "webchat-component",
146
133
  title: "MiTienda Support",
147
134
  // Custom welcome message with your brand's personality
148
135
  initialMessage: "¡Hola! 👋 Soy el asistente de MiTienda.\n\n¿Buscas algún producto específico? ¡Estoy aquí para ayudarte!\n\nPuedes preguntarme sobre:\n• Productos disponibles\n• Precios y ofertas\n• Envíos y devoluciones\n• Soporte técnico\n\n¿En qué puedo ayudarte hoy? 😊",
@@ -156,7 +143,6 @@ Customize the appearance of the close button in the chat header:
156
143
  #### Option 1: Default X Icon (SVG)
157
144
  ```javascript
158
145
  WebChat.initialize({
159
- elementId: "webchat-component",
160
146
  closeButtonIcon: "default" // Standard X icon
161
147
  });
162
148
  ```
@@ -164,7 +150,6 @@ WebChat.initialize({
164
150
  #### Option 2: Custom Text
165
151
  ```javascript
166
152
  WebChat.initialize({
167
- elementId: "webchat-component",
168
153
  closeButtonIcon: "text",
169
154
  closeButtonText: "CERRAR" // or "✕", "CLOSE", etc.
170
155
  });
@@ -173,7 +158,6 @@ WebChat.initialize({
173
158
  #### Option 3: Custom SVG Icon
174
159
  ```javascript
175
160
  WebChat.initialize({
176
- elementId: "webchat-component",
177
161
  closeButtonIcon: "custom",
178
162
  closeButtonCustomIcon: '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>'
179
163
  });
@@ -182,7 +166,6 @@ WebChat.initialize({
182
166
  #### Option 4: Custom Icon from URL
183
167
  ```javascript
184
168
  WebChat.initialize({
185
- elementId: "webchat-component",
186
169
  closeButtonIcon: "custom",
187
170
  closeButtonCustomIcon: "https://yoursite.com/icons/close-icon.svg"
188
171
  });
@@ -194,7 +177,6 @@ Control where the chat widget appears on the screen and how much space it has fr
194
177
  #### Bottom Right Position (Default)
195
178
  ```javascript
196
179
  WebChat.initialize({
197
- elementId: "webchat-component",
198
180
  position: "bottom-right",
199
181
  marginBottom: 20, // 20px from bottom edge
200
182
  marginSide: 25, // 25px from right edge
@@ -205,7 +187,6 @@ WebChat.initialize({
205
187
  #### Bottom Left Position
206
188
  ```javascript
207
189
  WebChat.initialize({
208
- elementId: "webchat-component",
209
190
  position: "bottom-left",
210
191
  marginBottom: 30, // 30px from bottom edge
211
192
  marginSide: 20, // 20px from left edge
@@ -218,7 +199,6 @@ WebChat.initialize({
218
199
  **E-commerce Site (avoid cart button)**
219
200
  ```javascript
220
201
  WebChat.initialize({
221
- elementId: "webchat-component",
222
202
  position: "bottom-left",
223
203
  marginBottom: 20,
224
204
  marginSide: 20,
@@ -229,7 +209,6 @@ WebChat.initialize({
229
209
  **Corporate Website (professional look)**
230
210
  ```javascript
231
211
  WebChat.initialize({
232
- elementId: "webchat-component",
233
212
  position: "bottom-right",
234
213
  marginBottom: 40, // More space from bottom
235
214
  marginSide: 30, // More space from side
@@ -240,7 +219,6 @@ WebChat.initialize({
240
219
  **Mobile-First Design (more accessible)**
241
220
  ```javascript
242
221
  WebChat.initialize({
243
- elementId: "webchat-component",
244
222
  position: "bottom-right",
245
223
  marginBottom: 80, // Avoid mobile navigation
246
224
  marginSide: 15, // Less space on mobile
@@ -257,35 +235,12 @@ The WebChat widget is optimized to minimize API costs:
257
235
 
258
236
  This ensures users can visit your e-commerce site without triggering unnecessary API calls.
259
237
 
260
- ### 🤖 AI Configuration
261
- Control whether the chat uses AI responses or just collects messages:
262
-
263
- #### AI Enabled (Default)
264
- ```javascript
265
- WebChat.initialize({
266
- elementId: "webchat-component",
267
- aiEnabled: true, // AI will respond to user messages
268
- apiKey: "your-api-key"
269
- });
270
- ```
271
-
272
- #### AI Disabled (Message Collection Only)
273
- ```javascript
274
- WebChat.initialize({
275
- elementId: "webchat-component",
276
- aiEnabled: false, // Only collect messages, no AI responses
277
- apiKey: "your-api-key"
278
- // When disabled, users get: "Gracias por tu mensaje. Un miembro de nuestro equipo se pondrá en contacto contigo pronto."
279
- });
280
- ```
281
-
282
238
  ### 📱💻 Device-Specific Configurations
283
239
  Configure different positions and margins for mobile and desktop devices:
284
240
 
285
241
  #### Complete Device-Specific Setup
286
242
  ```javascript
287
243
  WebChat.initialize({
288
- elementId: "webchat-component",
289
244
  title: "Customer Support",
290
245
  apiKey: "your-api-key",
291
246
 
@@ -313,10 +268,8 @@ WebChat.initialize({
313
268
  #### E-commerce Site Example
314
269
  ```javascript
315
270
  WebChat.initialize({
316
- elementId: "webchat-component",
317
271
  title: "Shopping Assistant",
318
272
  apiKey: "your-api-key",
319
- aiEnabled: true,
320
273
 
321
274
  // Desktop: bottom-right (standard)
322
275
  desktop: {
@@ -337,10 +290,8 @@ WebChat.initialize({
337
290
  #### Corporate Website Example
338
291
  ```javascript
339
292
  WebChat.initialize({
340
- elementId: "webchat-component",
341
293
  title: "Business Support",
342
294
  apiKey: "your-api-key",
343
- aiEnabled: true,
344
295
 
345
296
  // Consistent position, different margins
346
297
  position: "bottom-right", // Global fallback
@@ -357,28 +308,6 @@ WebChat.initialize({
357
308
  });
358
309
  ```
359
310
 
360
- #### Message Collection Only (No AI)
361
- ```javascript
362
- WebChat.initialize({
363
- elementId: "webchat-component",
364
- title: "Contact Form",
365
- aiEnabled: false, // Disable AI responses
366
- apiKey: "your-api-key",
367
-
368
- desktop: {
369
- position: "bottom-right",
370
- marginBottom: 30,
371
- marginSide: 30
372
- },
373
-
374
- mobile: {
375
- position: "bottom-right",
376
- marginBottom: 60,
377
- marginSide: 20
378
- }
379
- });
380
- ```
381
-
382
311
  ## 👨‍💻 Developer Guide
383
312
 
384
313
  ### 🚀 Getting Started
@@ -800,105 +729,6 @@ webchat-widget/
800
729
  └── package.json # pnpm + React + TypeScript dependencies
801
730
  ```
802
731
 
803
- ## 🚀 Deployment
804
-
805
- ### Option 1: CDN Hosting
806
- Upload the single bundle file to your CDN:
807
-
808
- ```html
809
- <script src="https://your-cdn.com/webchat-bundle.min.umd.cjs"></script>
810
- ```
811
-
812
- ### Option 2: Self-Hosting
813
- Host the bundle file on your server:
814
-
815
- ```html
816
- <script src="/assets/js/webchat-bundle.min.umd.cjs"></script>
817
- ```
818
-
819
- ### Option 3: Download and Include
820
- Download the bundle file and include it directly:
821
-
822
- ```html
823
- <script src="./webchat-bundle.min.umd.cjs"></script>
824
- ```
825
-
826
- ## 🔧 API Integration
827
-
828
- The widget can integrate with any chat API. Here's an example server endpoint:
829
-
830
- ```typescript
831
- // Express.js example
832
- app.post('/api/chat', async (req, res) => {
833
- const { message, sessionId } = req.body;
834
-
835
- // Process the message with your AI/chat service
836
- const response = await processChatMessage(message, sessionId);
837
-
838
- res.json({
839
- message: response,
840
- success: true
841
- });
842
- });
843
- ```
844
-
845
- ## 🎯 Browser Support
846
-
847
- - Chrome 63+ (ES modules, React, and TypeScript support)
848
- - Firefox 60+
849
- - Safari 11+
850
- - Edge 79+
851
-
852
- ## ⚡ Why This Tech Stack?
853
-
854
- ### TypeScript
855
- - **🛡️ Type Safety**: Catch errors at compile time, not runtime
856
- - **🧠 Better IntelliSense**: Enhanced autocomplete and refactoring
857
- - **📚 Self-Documenting**: Interfaces serve as living documentation
858
- - **🔧 Better Refactoring**: Safe and confident code changes
859
-
860
- ### Single File Bundle
861
- - **📦 Simplicity**: Just one file to include - no CSS dependencies
862
- - **🚀 Fast Loading**: Everything bundled and optimized
863
- - **🔄 Auto CSS Injection**: Styles are automatically added to the page
864
- - **🚫 No Conflicts**: Scoped styles prevent conflicts with existing CSS
865
-
866
- ### React
867
- - **🧱 Component Architecture**: Modular, reusable components
868
- - **🔄 State Management**: Built-in hooks for complex interactions
869
- - **🧪 Testability**: Easy to write unit and integration tests
870
- - **📚 Ecosystem**: Vast ecosystem of libraries and tools
871
-
872
- ### Tailwind CSS
873
- - **⚡ Utility-First**: Write styles directly in components
874
- - **📦 Small Bundle**: Only includes used styles
875
- - **🎨 Design System**: Consistent spacing, colors, and typography
876
- - **🔧 No Conflicts**: Prefixed classes (`nbc-`) prevent style conflicts
877
-
878
- ### Vite + pnpm
879
- - **🚀 Lightning Fast**: Instant dev server and optimized builds
880
- - **💾 Efficient**: pnpm saves disk space and installs faster
881
- - **🔧 Simple Config**: Minimal configuration required
882
- - **🎯 Modern**: Built for modern JavaScript, TypeScript, and React
883
-
884
732
  ## 📄 License
885
733
 
886
- MIT License - see the [LICENSE](LICENSE) file for details.
887
-
888
- ## 🤝 Contributing
889
-
890
- 1. Fork the repository
891
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
892
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
893
- 4. Push to the branch (`git push origin feature/amazing-feature`)
894
- 5. Open a Pull Request
895
-
896
- ## 📞 Support
897
-
898
- - 📧 Email: support@example.com
899
- - 💬 Issues: [GitHub Issues](https://github.com/your-username/webchat-widget/issues)
900
- - 📖 Docs: [Documentation](https://your-docs-site.com)
901
-
902
- ---
903
-
904
- Made with ❤️, 🔷 TypeScript, ⚛️ React, 🎨 Tailwind CSS, and ⚡ Vite - **All in one file!** 📦
734
+ MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1,4 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { ChatWindowProps } from '../types';
3
- declare const ChatWindow: React.FC<ChatWindowProps>;
3
+ interface ChatWindowWithApiKeyProps extends ChatWindowProps {
4
+ apiKeyMissing?: boolean;
5
+ }
6
+ declare const ChatWindow: React.FC<ChatWindowWithApiKeyProps>;
4
7
  export default ChatWindow;
@@ -1,8 +1,7 @@
1
1
  export declare const COMPANY_CONFIG: {
2
- readonly apiKey: "dedcf0f1-0c44-4435-806d-c0bb9acf4714";
3
- readonly chatbotId: 73;
2
+ readonly apiKey: "";
4
3
  readonly primaryColor: "#111111";
5
- readonly avatar: "https://n3v6oj3tw5ouoeeb.public.blob.vercel-storage.com/almohadovar-YwigR5IYdZVfSNI8uWilFrzAeVo4JZ.png";
4
+ readonly avatar: "";
6
5
  readonly title: "ChatBot - NotChatBot";
7
6
  readonly placeholder: "Escribe tu mensaje...";
8
7
  readonly initialMessage: "¡Hola! ¿En qué puedo ayudarte?";
@@ -22,5 +21,4 @@ export declare const COMPANY_CONFIG: {
22
21
  readonly closeButtonIcon: "default";
23
22
  readonly closeButtonText: "Cerrar";
24
23
  readonly closeButtonCustomIcon: "";
25
- readonly aiEnabled: true;
26
24
  };
@@ -1,6 +1,5 @@
1
1
  export declare const COMPANY_CONFIG: {
2
2
  readonly apiKey: "{{ API_KEY }}";
3
- readonly chatbotId: "{{ CHATBOT_ID }}";
4
3
  readonly primaryColor: "{{ PRIMARY_COLOR }}";
5
4
  readonly avatar: "{{ AVATAR_URL }}";
6
5
  readonly title: "{{ TITLE }}";
@@ -22,5 +21,4 @@ export declare const COMPANY_CONFIG: {
22
21
  readonly closeButtonIcon: "{{ CLOSE_BUTTON_ICON }}";
23
22
  readonly closeButtonText: "{{ CLOSE_BUTTON_TEXT }}";
24
23
  readonly closeButtonCustomIcon: "{{ CLOSE_BUTTON_CUSTOM_ICON }}";
25
- readonly aiEnabled: "{{ AI_ENABLED }}";
26
24
  };
package/dist/types.d.ts CHANGED
@@ -10,7 +10,6 @@ export interface WebChatConfig {
10
10
  primaryColor?: string;
11
11
  avatar?: string;
12
12
  apiKey?: string;
13
- chatbotId?: number;
14
13
  position?: 'bottom-right' | 'bottom-left';
15
14
  conversationId?: string;
16
15
  initialMessage?: string;
@@ -19,7 +18,6 @@ export interface WebChatConfig {
19
18
  closeButtonCustomIcon?: string;
20
19
  marginBottom?: number;
21
20
  marginSide?: number;
22
- aiEnabled?: boolean;
23
21
  mobile?: WebChatPositionConfig;
24
22
  desktop?: WebChatPositionConfig;
25
23
  }
@@ -6,7 +6,6 @@ export interface ResolvedWebChatConfig extends WebChatConfig {
6
6
  position: 'bottom-right' | 'bottom-left';
7
7
  marginBottom: number;
8
8
  marginSide: number;
9
- aiEnabled: boolean;
10
9
  }
11
10
  /**
12
11
  * Resolves the final configuration by applying device-specific overrides
@@ -3,18 +3,11 @@ export interface SendMessagePayload {
3
3
  conversationId: string;
4
4
  conversation: {
5
5
  id: string;
6
- chatbotId: string | null;
7
6
  senderId: string;
8
7
  createdAt: string;
9
8
  chatbotActivated: boolean;
10
9
  updatedAt: string;
11
10
  source: string;
12
- lastUserMessage: null;
13
- qualification: null;
14
- contactId: null;
15
- conversationType: null;
16
- language: null;
17
- region: null;
18
11
  website: string;
19
12
  messages: any[];
20
13
  };
@@ -25,11 +18,6 @@ export interface SendMessagePayload {
25
18
  * @returns Fallback bot message
26
19
  */
27
20
  export declare const createFallbackMessage: () => Message;
28
- /**
29
- * Creates a notification message for when AI is disabled
30
- * @returns Notification message
31
- */
32
- export declare const createNotificationMessage: () => Message;
33
21
  /**
34
22
  * Builds the payload for sending messages to the API
35
23
  * @param conversationId Conversation ID
@@ -40,7 +28,6 @@ export declare const createNotificationMessage: () => Message;
40
28
  */
41
29
  export declare const buildMessagePayload: (conversationId: string, messages: Message[], config: {
42
30
  apiKey: string;
43
- chatbotId?: string;
44
31
  }, userIP: string) => SendMessagePayload;
45
32
  /**
46
33
  * Sends messages to the chat API