@schmitech/chatbot-widget 0.1.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,84 +93,100 @@ 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:
96
+ To publish a new version of the widget:
162
97
 
163
- 1. In this widget directory, run:
98
+ 1. Build the widget:
164
99
  ```bash
165
100
  npm run build
166
- npm run build:bundle
167
- npm link
168
101
  ```
169
102
 
170
- 2. In your project directory, run:
103
+ 2. Test the package locally (optional):
171
104
  ```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';
105
+ npm pack --dry-run
178
106
  ```
179
107
 
180
- ### Option 2: Installing from a local directory
181
-
182
- You can also install the package directly from the local directory:
183
-
184
- 1. In this widget directory, run:
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:
185
129
  ```bash
186
- npm run build
187
- npm run build:bundle
130
+ npm version patch # for bug fixes
131
+ npm version minor # for new features
132
+ npm version major # for breaking changes
188
133
  ```
189
134
 
190
- 2. In your project directory, run:
135
+ 4. Publish to npm:
191
136
  ```bash
192
- npm install /path/to/qa-chatbot-server/widget
137
+ npm publish --access public
193
138
  ```
194
139
 
195
- 3. Now you can import and use the widget in your project:
196
- ```javascript
197
- import { ChatWidget } from 'chatbot-widget';
198
- ```
140
+ ### After Publishing
199
141
 
200
- ### Option 3: Publishing to npm (for production)
142
+ The package is available on npm as `@schmitech/chatbot-widget`. The latest version is 0.2.0.
201
143
 
202
- To make this widget available to anyone via npm:
144
+ You can use it in any project:
203
145
 
204
- 1. Build the widget and create the bundle:
205
- ```bash
206
- npm run build
207
- npm run build:bundle
146
+ 1. Visit the package on npm:
208
147
  ```
209
-
210
- 2. Login to npm with your account:
211
- ```bash
212
- npm login
148
+ https://www.npmjs.com/package/@schmitech/chatbot-widget
213
149
  ```
214
150
 
215
- 3. Publish the package (if you're publishing for the first time, or updating the version):
151
+ 2. Install it in any project:
216
152
  ```bash
217
- npm publish --access public
153
+ npm install @schmitech/chatbot-widget
218
154
  ```
219
155
 
220
- 4. To update an existing package, first update the version in package.json, then run:
221
- ```bash
222
- npm version patch # or minor or major
223
- npm publish --access public
156
+ 3. Test the bundle in a simple HTML file:
157
+ ```html
158
+ <!DOCTYPE html>
159
+ <html lang="en">
160
+ <head>
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">
167
+ </head>
168
+ <body>
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>
175
+ </body>
176
+ </html>
224
177
  ```
225
178
 
226
179
  ### Importing the Bundled Version
227
180
 
228
- After publishing, users can import your bundled widget in different ways:
181
+ You can import the widget in different ways:
229
182
 
230
183
  ```html
231
184
  <!-- HTML - Using the full bundle (JS + CSS combined) -->
232
- <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>
233
186
 
234
187
  <!-- Using UMD version + separate CSS -->
235
- <script src="https://unpkg.com/@schmitech/chatbot-widget"></script>
236
- <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" />
237
190
  ```
238
191
 
239
192
  ```javascript
@@ -243,6 +196,78 @@ import { ChatWidget } from '@schmitech/chatbot-widget';
243
196
  import '@schmitech/chatbot-widget/bundle';
244
197
  ```
245
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
+
246
271
  ### Known Limitations and Troubleshooting
247
272
 
248
273
  #### Scrolling Behavior
@@ -0,0 +1,5 @@
1
+ typeof window < "u" && (window.global = window);
2
+ const o = {};
3
+ export {
4
+ o as default
5
+ };