@schmitech/chatbot-widget 0.2.0 → 0.2.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 CHANGED
@@ -46,69 +46,6 @@ A reusable chatbot widget that can be easily integrated into any website.
46
46
  - `chatbot-widget.umd.js` - UMD module (if you need the JS separately)
47
47
  - `chatbot-widget.css` - Styles (if you need the CSS separately)
48
48
 
49
- ## Usage
50
-
51
- ### Using direct script tags
52
-
53
- Add the following code to your website's HTML:
54
-
55
- ```html
56
- <!-- Include React and ReactDOM first -->
57
- <script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
58
- <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
59
- <!-- Include the bundled widget -->
60
- <script src="path/to/chatbot-widget.bundle.js"></script>
61
-
62
- <script>
63
- // Initialize the widget when the page loads
64
- window.addEventListener('load', function() {
65
- window.initChatbotWidget({
66
- apiUrl: 'https://your-api-server.com'
67
- });
68
- });
69
- </script>
70
- ```
71
-
72
- ### Using npm
73
-
74
- 1. Install the package:
75
- ```bash
76
- npm install chatbot-widget
77
- ```
78
-
79
- 2. Import in your application:
80
- ```javascript
81
- import { ChatWidget } from 'chatbot-widget';
82
-
83
- // Use in your React component
84
- function App() {
85
- return (
86
- <div className="App">
87
- <ChatWidget />
88
- </div>
89
- );
90
- }
91
-
92
- // Set API URL via the exposed function
93
- window.ChatbotWidget.setApiUrl('https://your-api-server.com');
94
- ```
95
-
96
- ### Advanced Usage
97
-
98
- You can customize the widget by specifying a container:
99
-
100
- ```html
101
- <div id="my-chat-container"></div>
102
-
103
- <script>
104
- window.addEventListener('load', function() {
105
- window.initChatbotWidget({
106
- apiUrl: 'https://your-api-server.com',
107
- containerSelector: '#my-chat-container'
108
- });
109
- });
110
- </script>
111
- ```
112
49
 
113
50
  ## Customizing the Widget
114
51
  Check file demo.html containing an working example on how to customize the widget.
@@ -156,78 +93,55 @@ npm run preview
156
93
 
157
94
  ## Publishing to npm
158
95
 
159
- ### Option 1: Using npm link (for local development)
160
-
161
- To use this widget in other projects on your local machine during development:
162
-
163
- 1. In this widget directory, run:
164
- ```bash
165
- npm run build
166
- npm run build:bundle
167
- npm link
168
- ```
169
-
170
- 2. In your project directory, run:
171
- ```bash
172
- npm link chatbot-widget
173
- ```
174
-
175
- 3. Now you can import and use the widget in your project:
176
- ```javascript
177
- import { ChatWidget } from 'chatbot-widget';
178
- ```
179
-
180
- ### Option 2: Installing from a local directory
96
+ To publish a new version of the widget:
181
97
 
182
- You can also install the package directly from the local directory:
183
-
184
- 1. In this widget directory, run:
185
- ```bash
186
- npm run build
187
- npm run build:bundle
188
- ```
189
-
190
- 2. In your project directory, run:
191
- ```bash
192
- npm install /path/to/qa-chatbot-server/widget
193
- ```
194
-
195
- 3. Now you can import and use the widget in your project:
196
- ```javascript
197
- import { ChatWidget } from 'chatbot-widget';
198
- ```
199
-
200
- ### Option 3: Publishing to npm (for production)
201
-
202
- To make this widget available to anyone via npm:
203
-
204
- 1. Build the widget and create the bundle:
98
+ 1. Build the widget:
205
99
  ```bash
206
100
  npm run build
207
- npm run build:bundle
208
101
  ```
209
102
 
210
- 2. Login to npm with your account:
103
+ 2. Test the package locally (optional):
211
104
  ```bash
212
- npm login
105
+ npm pack --dry-run
213
106
  ```
214
107
 
215
- 3. Publish the package (if you're publishing for the first time, or updating the version):
108
+ You should see an output like this:
109
+ npm notice
110
+ ```bash
111
+ npm notice 📦 @schmitech/chatbot-widget@0.2.0
112
+ npm notice === Tarball Contents ===
113
+ npm notice 1.1kB package.json
114
+ npm notice 31.0kB dist/chatbot-widget.css
115
+ npm notice 160.0kB dist/chatbot-widget.umd.js
116
+ npm notice 2.1kB dist/index.d.ts
117
+ ...
118
+ npm notice === Tarball Details ===
119
+ npm notice name: @schmitech/chatbot-widget
120
+ npm notice version: 0.2.0
121
+ npm notice package size: 193.2 kB
122
+ npm notice unpacked size: 1.2 MB
123
+ npm notice shasum: abc123...
124
+ npm notice integrity: sha512-...
125
+ npm notice total files: 15
126
+ ```
127
+
128
+ 3. Update the version:
216
129
  ```bash
217
- npm publish --access public
130
+ npm version patch # for bug fixes
131
+ npm version minor # for new features
132
+ npm version major # for breaking changes
218
133
  ```
219
134
 
220
- 4. To update an existing package, first update the version in package.json, then run:
135
+ 4. Publish to npm:
221
136
  ```bash
222
- npm version patch # or minor or major
223
137
  npm publish --access public
224
138
  ```
225
139
 
226
140
  ### After Publishing
227
141
 
228
- The package has been successfully published to npm as `@schmitech/chatbot-widget` version 0.1.0!
142
+ The package is available on npm as `@schmitech/chatbot-widget`. The latest version is 0.2.0.
229
143
 
230
- You can now use it in any project:
144
+ You can use it in any project:
231
145
 
232
146
  1. Visit the package on npm:
233
147
  ```
@@ -242,66 +156,37 @@ You can now use it in any project:
242
156
  3. Test the bundle in a simple HTML file:
243
157
  ```html
244
158
  <!DOCTYPE html>
245
- <html>
159
+ <html lang="en">
246
160
  <head>
247
- <title>Chatbot Widget Test</title>
161
+ <meta charset="UTF-8" />
162
+ <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
163
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
164
+ <title>Your Web App</title>
165
+ <!-- Add widget CSS -->
166
+ <link rel="stylesheet" href="https://unpkg.com/@schmitech/chatbot-widget@0.2.0/dist/chatbot-widget.css">
248
167
  </head>
249
168
  <body>
250
- <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
251
- <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
252
- <script src="https://unpkg.com/@schmitech/chatbot-widget@0.1.0/dist/chatbot-widget.bundle.js"></script>
253
- <script>
254
- window.addEventListener('load', function() {
255
- window.initChatbotWidget({
256
- apiUrl: 'https://your-api-server.com'
257
- });
258
- });
259
- </script>
169
+ <div id="root"></div>
170
+
171
+ <!-- Widget dependencies -->
172
+ <script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
173
+ <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
174
+ <script src="https://unpkg.com/@schmitech/chatbot-widget@0.2.0/dist/chatbot-widget.umd.js" crossorigin></script>
260
175
  </body>
261
176
  </html>
262
177
  ```
263
178
 
264
- 4. Verify the files in an existing installation:
265
- ```bash
266
- ls -la node_modules/@schmitech/chatbot-widget/dist
267
- ```
268
-
269
- You should see these files:
270
- - `chatbot-widget.bundle.js` - The bundled JS+CSS file
271
- - `chatbot-widget.umd.js` - The UMD module
272
- - `chatbot-widget.css` - The CSS file
273
-
274
- ### Troubleshooting npm Publishing
275
-
276
- If you encounter issues publishing to npm, check the following:
277
-
278
- 1. **Package Not Found (404)**
279
- - Confirm you've successfully completed the `npm publish --access public` command
280
- - Ensure there were no errors during publishing
281
- - Wait a few minutes as npm registry might take time to update
282
-
283
- 2. **Authentication Issues**
284
- - Make sure you're logged in with `npm login`
285
- - Verify your account has permission to publish
286
-
287
- 3. **Name Already Taken**
288
- - If the package name is already taken, modify the name in package.json
289
- - Use a more specific scoped name like `@your-username/chatbot-widget`
290
-
291
- 4. **Local Testing Before Publishing**
292
- - To test locally before publishing, use Option 1 or 2 described above
293
-
294
179
  ### Importing the Bundled Version
295
180
 
296
- After publishing, users can import your bundled widget in different ways:
181
+ You can import the widget in different ways:
297
182
 
298
183
  ```html
299
184
  <!-- HTML - Using the full bundle (JS + CSS combined) -->
300
- <script src="https://unpkg.com/@schmitech/chatbot-widget/dist/chatbot-widget.bundle.js"></script>
185
+ <script src="https://unpkg.com/@schmitech/chatbot-widget@0.2.0/dist/chatbot-widget.bundle.js"></script>
301
186
 
302
187
  <!-- Using UMD version + separate CSS -->
303
- <script src="https://unpkg.com/@schmitech/chatbot-widget"></script>
304
- <link rel="stylesheet" href="https://unpkg.com/@schmitech/chatbot-widget/dist/chatbot-widget.css" />
188
+ <script src="https://unpkg.com/@schmitech/chatbot-widget@0.2.0"></script>
189
+ <link rel="stylesheet" href="https://unpkg.com/@schmitech/chatbot-widget@0.2.0/dist/chatbot-widget.css" />
305
190
  ```
306
191
 
307
192
  ```javascript
@@ -311,6 +196,78 @@ import { ChatWidget } from '@schmitech/chatbot-widget';
311
196
  import '@schmitech/chatbot-widget/bundle';
312
197
  ```
313
198
 
199
+ Using in TSX components:
200
+
201
+ ```javascript
202
+ useEffect(() => {
203
+ // Initialize the widget when component mounts
204
+ if (typeof window !== 'undefined' && window.initChatbotWidget) {
205
+ console.log('Initializing chatbot widget...');
206
+ setTimeout(() => {
207
+ try {
208
+ window.initChatbotWidget!({
209
+ apiUrl: import.meta.env.VITE_API_ENDPOINT,
210
+ widgetConfig: {
211
+ header: {
212
+ title: "Community Services Help Center"
213
+ },
214
+ welcome: {
215
+ title: "Welcome to Our Community Services!",
216
+ description: "I can help you with information about youth programs, senior services, adult education, family services, and more."
217
+ },
218
+ suggestedQuestions: [
219
+ {
220
+ text: "What youth programs are available?",
221
+ query: "Tell me about the youth programs"
222
+ },
223
+ {
224
+ text: "Senior services information",
225
+ query: "What services are available for seniors?"
226
+ },
227
+ {
228
+ text: "Adult education courses",
229
+ query: "What adult education courses do you offer?"
230
+ }
231
+ ],
232
+ theme: {
233
+ primary: '#2C3E50',
234
+ secondary: '#f97316',
235
+ background: '#ffffff',
236
+ text: {
237
+ primary: '#1a1a1a',
238
+ secondary: '#666666',
239
+ inverse: '#ffffff'
240
+ },
241
+ input: {
242
+ background: '#f9fafb',
243
+ border: '#e5e7eb'
244
+ },
245
+ message: {
246
+ user: '#2C3E50',
247
+ assistant: '#ffffff',
248
+ userText: '#ffffff'
249
+ },
250
+ suggestedQuestions: {
251
+ background: '#fff7ed',
252
+ hoverBackground: '#ffedd5',
253
+ text: '#2C3E50'
254
+ },
255
+ iconColor: '#f97316'
256
+ },
257
+ icon: "message-square"
258
+ }
259
+ });
260
+ console.log('Chatbot widget initialized successfully');
261
+ } catch (error) {
262
+ console.error('Failed to initialize chatbot widget:', error);
263
+ }
264
+ }, 1000);
265
+ } else {
266
+ console.error('Chatbot widget initialization function not found');
267
+ }
268
+ }, []);
269
+ ```
270
+
314
271
  ### Known Limitations and Troubleshooting
315
272
 
316
273
  #### Scrolling Behavior