@schmitech/chatbot-widget 0.3.6 → 0.4.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.
package/README.md CHANGED
@@ -27,79 +27,81 @@ Add this code to your website:
27
27
  <script>
28
28
  window.addEventListener('load', function() {
29
29
  window.initChatbotWidget({
30
- apiUrl: 'https://your-api-url.com', // Your chatbot API endpoint
30
+ apiUrl: 'https://your-api-url.com', // Your chatbot API endpoint
31
31
  apiKey: 'your-api-key', // Your API key
32
- sessionId: 'optional-session-id', // Optional: Provide a custom session ID
33
- widgetConfig: {
34
- header: {
35
- title: "Chat Assistant"
32
+ sessionId: 'optional-session-id', // Required: Provide a session ID
33
+ // Optional widget configuration
34
+ header: {
35
+ title: "Chat Assistant"
36
+ },
37
+ welcome: {
38
+ title: "Welcome!",
39
+ description: "How can I help you today?"
40
+ },
41
+ suggestedQuestions: [
42
+ {
43
+ text: "How can you help me?",
44
+ query: "What can you do?"
45
+ },
46
+ {
47
+ text: "Contact support",
48
+ query: "How do I contact support?"
49
+ }
50
+ ],
51
+ theme: {
52
+ primary: '#4f46e5',
53
+ secondary: '#7c3aed',
54
+ background: '#ffffff',
55
+ text: {
56
+ primary: '#111827',
57
+ inverse: '#ffffff'
36
58
  },
37
- welcome: {
38
- title: "Welcome!",
39
- description: "How can I help you today?"
59
+ input: {
60
+ background: '#f9fafb',
61
+ border: '#e5e7eb'
40
62
  },
41
- suggestedQuestions: [
42
- {
43
- text: "How can you help me?",
44
- query: "What can you do?"
45
- },
46
- {
47
- text: "Contact support",
48
- query: "How do I contact support?"
49
- }
50
- ],
51
- theme: {
52
- primary: '#2C3E50',
53
- secondary: '#f97316',
63
+ message: {
64
+ user: '#4f46e5',
65
+ assistant: '#f8fafc',
66
+ userText: '#ffffff'
67
+ },
68
+ suggestedQuestions: {
69
+ background: '#eef2ff',
70
+ hoverBackground: '#e0e7ff',
71
+ text: '#4338ca'
72
+ },
73
+ chatButton: {
54
74
  background: '#ffffff',
55
- text: {
56
- primary: '#1a1a1a',
57
- secondary: '#666666',
58
- inverse: '#ffffff'
59
- },
60
- input: {
61
- background: '#f9fafb',
62
- border: '#e5e7eb'
63
- },
64
- message: {
65
- user: '#2C3E50',
66
- assistant: '#ffffff',
67
- userText: '#ffffff'
68
- },
69
- suggestedQuestions: {
70
- background: '#fff7ed',
71
- hoverBackground: '#ffedd5',
72
- text: '#2C3E50'
73
- },
74
- iconColor: '#f97316'
75
+ hoverBackground: '#f8fafc'
75
76
  },
76
- icon: "message-square"
77
- }
77
+ iconColor: '#7c3aed'
78
+ },
79
+ icon: "message-square"
78
80
  });
79
81
  });
80
82
  </script>
81
83
  ```
82
84
 
83
- ## Session Management
85
+ ## Configuration Options
84
86
 
85
- The widget now includes improved session management:
87
+ ### Required Parameters
86
88
 
87
- 1. **Server-Provided Session ID**: If your server provides a session ID through `window.CHATBOT_SESSION_ID`, the widget will use it automatically.
89
+ | Parameter | Type | Description |
90
+ |-----------|------|-------------|
91
+ | `apiUrl` | string | Your chatbot API endpoint URL |
92
+ | `apiKey` | string | Your API authentication key |
93
+ | `sessionId` | string | Unique identifier for the chat session |
88
94
 
89
- 2. **Custom Session ID**: You can provide your own session ID during initialization:
90
- ```javascript
91
- window.initChatbotWidget({
92
- apiUrl: 'https://your-api-url.com',
93
- apiKey: 'your-api-key',
94
- sessionId: 'your-custom-session-id',
95
- // ... other config
96
- });
97
- ```
95
+ ### Optional Parameters
98
96
 
99
- 3. **Automatic Session ID**: If no session ID is provided, the widget will:
100
- - First check for an existing session ID in `sessionStorage`
101
- - If none exists, generate a new UUID
102
- - Store the session ID in both `sessionStorage` and `window.CHATBOT_SESSION_ID`
97
+ | Parameter | Type | Description |
98
+ |-----------|------|-------------|
99
+ | `containerSelector` | string | CSS selector for custom container (defaults to bottom-right corner) |
100
+ | `header` | object | Widget header configuration |
101
+ | `welcome` | object | Welcome message configuration |
102
+ | `suggestedQuestions` | array | Array of suggested question buttons |
103
+ | `theme` | object | Theme customization options |
104
+ | `icon` | string | Widget icon type |
103
105
 
104
106
  ## Advanced Usage
105
107
 
@@ -114,10 +116,9 @@ To place the widget in a specific container instead of the bottom-right corner:
114
116
  window.initChatbotWidget({
115
117
  apiUrl: 'https://your-api-url.com',
116
118
  apiKey: 'your-api-key',
119
+ sessionId: 'your-session-id',
117
120
  containerSelector: '#my-chat-container',
118
- widgetConfig: {
119
- // ... your config here
120
- }
121
+ // ... other config options
121
122
  });
122
123
  </script>
123
124
  ```
@@ -135,10 +136,11 @@ function App() {
135
136
  window.initChatbotWidget({
136
137
  apiUrl: process.env.REACT_APP_API_ENDPOINT,
137
138
  apiKey: process.env.REACT_APP_API_KEY,
138
- sessionId: process.env.REACT_APP_SESSION_ID, // Optional: Provide custom session ID
139
- widgetConfig: {
140
- // ... your config here
141
- }
139
+ sessionId: process.env.REACT_APP_SESSION_ID,
140
+ header: {
141
+ title: "AI Assistant"
142
+ },
143
+ // ... other config options
142
144
  });
143
145
  }
144
146
  }, []);
@@ -149,26 +151,66 @@ function App() {
149
151
  }
150
152
  ```
151
153
 
152
- ## Configuration Options
154
+ ## Theme Configuration
153
155
 
154
- ### Required Parameters
156
+ The widget supports extensive theme customization:
155
157
 
156
- | Parameter | Type | Description |
157
- |-----------|------|-------------|
158
- | `apiUrl` | string | Your chatbot API endpoint URL |
159
- | `apiKey` | string | Your API authentication key |
158
+ ```typescript
159
+ theme: {
160
+ primary: string; // Primary color (headers, user messages)
161
+ secondary: string; // Secondary/accent color
162
+ background: string; // Widget background color
163
+ text: {
164
+ primary: string; // Primary text color
165
+ inverse: string; // Text color on colored backgrounds
166
+ },
167
+ input: {
168
+ background: string; // Input field background
169
+ border: string; // Input field border color
170
+ },
171
+ message: {
172
+ user: string; // User message bubble color
173
+ assistant: string; // Assistant message bubble color
174
+ userText: string; // User message text color
175
+ },
176
+ suggestedQuestions: {
177
+ background: string; // Suggested questions background
178
+ hoverBackground: string; // Suggested questions hover background
179
+ text: string; // Suggested questions text color
180
+ },
181
+ chatButton: {
182
+ background: string; // Chat button background
183
+ hoverBackground: string; // Chat button hover background
184
+ },
185
+ iconColor: string; // Widget icon color
186
+ }
187
+ ```
160
188
 
161
- ### Optional Parameters
189
+ ### Built-in Themes
162
190
 
163
- | Parameter | Type | Description |
164
- |-----------|------|-------------|
165
- | `sessionId` | string | Unique identifier for the chat session. If not provided, one will be generated automatically |
166
- | `containerSelector` | string | CSS selector for custom container |
167
- | `widgetConfig` | object | Widget appearance and behavior settings |
191
+ The demo includes several professional themes:
192
+ - **Modern** - Vibrant indigo/purple gradient
193
+ - **Minimal** - Clean gray palette
194
+ - **Corporate** - Professional blue theme
195
+ - **Dark** - Sleek dark theme with cyan accents
196
+ - **Emerald** - Fresh green theme
197
+ - **Sunset** - Warm orange-red gradient
198
+ - **Lavender** - Elegant purple theme
199
+ - **Monochrome** - Sophisticated grayscale
168
200
 
169
- ### Widget Configuration
201
+ ## Available Icons
202
+
203
+ Choose from these built-in icons:
204
+ - `heart` - Heart icon
205
+ - `message-square` - Square message bubble (default)
206
+ - `message-circle` - Round message bubble
207
+ - `message-dots` - Message bubble with dots
208
+ - `help-circle` - Question mark in circle
209
+ - `info` - Information icon
210
+ - `bot` - Robot icon
211
+ - `sparkles` - Sparkles icon
170
212
 
171
- The `widgetConfig` object supports these properties:
213
+ ## Widget Configuration Structure
172
214
 
173
215
  ```typescript
174
216
  {
@@ -182,59 +224,40 @@ The `widgetConfig` object supports these properties:
182
224
  suggestedQuestions: [ // Array of suggested questions
183
225
  {
184
226
  text: string; // Button text
185
- query: string; // Question to send
227
+ query: string; // Question to send when clicked
186
228
  }
187
229
  ],
188
- theme: { // Theme customization
189
- primary: string; // Primary color
190
- secondary: string; // Secondary/accent color
191
- background: string; // Background color
192
- text: {
193
- primary: string; // Primary text color
194
- secondary: string; // Secondary text color
195
- inverse: string; // Inverse text color
196
- },
197
- input: {
198
- background: string; // Input background
199
- border: string; // Input border color
200
- },
201
- message: {
202
- user: string; // User message bubble color
203
- assistant: string; // Assistant message bubble color
204
- userText: string; // User message text color
205
- },
206
- suggestedQuestions: {
207
- background: string; // Suggested questions background
208
- hoverBackground: string; // Suggested questions hover background
209
- text: string; // Suggested questions text color
210
- },
211
- iconColor: string; // Widget icon color
212
- },
230
+ theme: { /* theme object */ },
213
231
  icon: string; // Widget icon type
214
232
  }
215
233
  ```
216
234
 
217
- ## Available Icons
218
-
219
- Choose from these built-in icons:
220
- - `heart` ❤️
221
- - `message-square` 💬
222
- - `message-circle` 🗨️
223
- - `help-circle` ❓
224
- - `info` ℹ️
225
- - `bot` 🤖
226
- - `sparkles` ✨
235
+ ## Session Management
227
236
 
228
- ## Customizing Height
237
+ The widget requires a `sessionId` parameter for proper conversation management:
229
238
 
230
- To adjust the widget height, add this CSS to your website:
239
+ 1. **Generate a unique session ID** for each user conversation
240
+ 2. **Maintain the session ID** throughout the user's visit
241
+ 3. **Use UUIDs or similar** for session identification
231
242
 
232
- ```css
233
- :root {
234
- --chat-container-height: 600px; /* Default is 500px */
243
+ Example session ID generation:
244
+ ```javascript
245
+ function generateSessionId() {
246
+ return 'session-' + Math.random().toString(36).substr(2, 9) + '-' + Date.now();
235
247
  }
248
+
249
+ window.initChatbotWidget({
250
+ apiUrl: 'https://your-api-url.com',
251
+ apiKey: 'your-api-key',
252
+ sessionId: generateSessionId(),
253
+ // ... other config
254
+ });
236
255
  ```
237
256
 
257
+ ## Typography
258
+
259
+ The widget uses **Mona Sans** font by default, with fallbacks to system fonts for optimal performance and consistency.
260
+
238
261
  ## Troubleshooting
239
262
 
240
263
  1. **Widget not appearing?**
@@ -244,9 +267,9 @@ To adjust the widget height, add this CSS to your website:
244
267
  - Check if the container element exists
245
268
 
246
269
  2. **Session ID issues?**
247
- - Verify that `window.CHATBOT_SESSION_ID` is set if using server-provided sessions
248
- - Check browser console for session-related errors
249
- - Ensure `sessionStorage` is available and not blocked
270
+ - Ensure `sessionId` parameter is provided
271
+ - Verify the session ID is unique per conversation
272
+ - Check that your API supports session-based conversations
250
273
 
251
274
  3. **API connection issues?**
252
275
  - Verify your API endpoint is accessible
@@ -257,9 +280,11 @@ To adjust the widget height, add this CSS to your website:
257
280
  4. **Styling conflicts?**
258
281
  - The widget uses scoped CSS to prevent conflicts
259
282
  - If you see styling issues, check for conflicting CSS rules
283
+ - Dark themes require proper text color configuration
260
284
 
261
285
  ## Support
262
286
 
263
287
  For more help:
264
288
  - Visit our [GitHub repository](https://github.com/schmitech/orbit)
289
+ - Check the demo at `/demo.html` for live examples
265
290
  - Open an issue on GitHub for bug reports