@schmitech/chatbot-widget 0.2.4 โ†’ 0.3.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
@@ -1,89 +1,108 @@
1
- # Chatbot Widget
1
+ # ๐Ÿ’ฌ Chatbot Widget
2
2
 
3
- A reusable chatbot widget that can be easily integrated into any website.
3
+ A simple, reusable chatbot widget seamlessly integrated into any website with minimal effort.
4
4
 
5
- ## Features
5
+ ---
6
6
 
7
- - Easy to integrate with a single JavaScript snippet
8
- - Responsive design with mobile support
9
- - Customizable appearance
10
- - Markdown support for rich text responses
11
- - Link detection and formatting
12
- - Scrollable chat interface with "scroll to top" button
13
- - Clear conversation functionality
7
+ ## ๐ŸŒŸ Key Features
14
8
 
15
- ## Building the Widget
9
+ - ๐Ÿš€ **Quick Integration:** One-line JavaScript integration
10
+ - ๐Ÿ“ฑ **Responsive Design:** Mobile-friendly and adaptive layout
11
+ - ๐ŸŽจ **Customizable Appearance:** Easy theme adjustments
12
+ - ๐Ÿ“ **Rich Text:** Supports Markdown and automatic link formatting
13
+ - ๐Ÿ–ฑ๏ธ **User-Friendly UI:** Scrollable conversation view with "scroll to top" shortcut
14
+ - ๐Ÿงน **Clear Conversation:** Reset chat with a single click
16
15
 
17
- ### Prerequisites
16
+ ---
18
17
 
18
+ ## ๐Ÿ› ๏ธ Installation
19
+
20
+ ### โœ… Prerequisites
19
21
  - Node.js 18+ and npm
20
22
 
21
- ### Build Steps
23
+ ### ๐Ÿ“ฆ Setup Instructions
24
+
25
+ 1. **Clone Repository**
26
+
27
+ ```bash
28
+ git https://github.com/schmitech/orbit.git
29
+ cd orbit/widget
30
+ ```
31
+
32
+ 2. **Install & Build API**
22
33
 
23
- 1. Clone the repository:
24
- ```bash
25
- git clone <repository-url>
26
- cd qa-chatbot-server
27
- ```
34
+ ```bash
35
+ cd api
36
+ npm install
37
+ npm run build
38
+ ```
28
39
 
29
- 2. Install dependencies for the API:
30
- ```bash
31
- cd api
32
- npm install
33
- npm run build
34
- ```
40
+ 3. **Install & Build Widget**
35
41
 
36
- 3. Build the widget:
37
- ```bash
38
- cd ../widget
39
- npm install
40
- npm run build
41
- npm run build:bundle
42
- ```
42
+ ```bash
43
+ cd ../widget
44
+ npm install
45
+ npm run build
46
+ npm run build:bundle
47
+ ```
43
48
 
44
- 4. The built files will be in the `widget/dist` directory:
45
- - `chatbot-widget.bundle.js` - Single file containing both JS and CSS (recommended for direct usage)
46
- - `chatbot-widget.umd.js` - UMD module (if you need the JS separately)
47
- - `chatbot-widget.css` - Styles (if you need the CSS separately)
49
+ The build outputs are located in `widget/dist`:
50
+ - `chatbot-widget.bundle.js` (JS + CSS combined, recommended)
51
+ - `chatbot-widget.umd.js` (JS only, UMD)
52
+ - `chatbot-widget.css` (CSS only)
48
53
 
54
+ ---
49
55
 
50
- ## Customizing the Widget
51
- Check file demo.html containing an working example on how to customize the widget.
56
+ ## ๐ŸŽจ Customization
52
57
 
53
- To run the example:
58
+ See `demo.html` for customization examples:
54
59
 
55
- ```python
60
+ ```bash
56
61
  python3 -m http.server 8080
57
62
  ```
58
63
 
59
- ## Deployment
64
+ ---
65
+
66
+ ## ๐Ÿšข Deployment
60
67
 
61
- 1. Host the bundled file (`chatbot-widget.bundle.js`) on a CDN or your web server
62
- 2. Update the script tag in your HTML to point to the hosted file
63
- 3. Make sure your chatbot API server is accessible at the URL you provide to `initChatbotWidget`
68
+ 1. Host `chatbot-widget.bundle.js` on a CDN or server.
69
+ 2. Update your HTML with the script reference.
70
+ 3. Ensure your chatbot API URL is accessible.
64
71
 
65
- ## API Reference
72
+ ---
66
73
 
67
- ### initChatbotWidget(config)
74
+ ## โš™๏ธ Widget API Reference
68
75
 
69
- Initializes the chatbot widget with the given configuration.
76
+ ### `initChatbotWidget(config)`
77
+ Initializes widget configuration.
70
78
 
71
- #### Parameters
79
+ | Parameter | Description | Required |
80
+ |-----------|-------------|----------|
81
+ | `apiUrl` | URL of chatbot API | โœ… Yes |
82
+ | `apiKey` | API key for authentication | โœ… Yes |
83
+ | `containerSelector` | CSS selector for widget container | โŒ No (Defaults to body) |
84
+
85
+ Example configuration:
86
+ ```javascript
87
+ initChatbotWidget({
88
+ apiUrl: 'https://your-api-url.com',
89
+ apiKey: 'your-api-key',
90
+ containerSelector: '#chat-container'
91
+ });
92
+ ```
72
93
 
73
- - `config` (object):
74
- - `apiUrl` (string, required): The URL of your chatbot API server
75
- - `containerSelector` (string, optional): CSS selector for the container where the widget should be rendered. If not specified, the widget will be appended to the body.
94
+ ---
76
95
 
77
- ## Development
96
+ ## ๐Ÿง‘โ€๐Ÿ’ป Development Commands
78
97
 
79
98
  ```bash
80
- # Start development server
99
+ # Development server
81
100
  npm run dev
82
101
 
83
- # Run linting
102
+ # Code linting
84
103
  npm run lint
85
104
 
86
- # Build for production
105
+ # Production builds
87
106
  npm run build
88
107
  npm run build:bundle
89
108
 
@@ -91,201 +110,94 @@ npm run build:bundle
91
110
  npm run preview
92
111
  ```
93
112
 
94
- ## Publishing to npm
95
-
96
- To publish a new version of the widget:
97
-
98
- 1. Build the widget:
99
- ```bash
100
- npm run build
101
- ```
102
-
103
- 2. Test the package locally (optional):
104
- ```bash
105
- npm pack --dry-run
106
- ```
107
-
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:
129
- ```bash
130
- npm version patch # for bug fixes
131
- npm version minor # for new features
132
- npm version major # for breaking changes
133
- ```
134
-
135
- 4. Publish to npm:
136
- ```bash
137
- npm publish --access public
138
- ```
139
-
140
- ### After Publishing
141
-
142
- The package is available on npm as `@schmitech/chatbot-widget`. The latest version is 0.2.0.
143
-
144
- You can use it in any project:
145
-
146
- 1. Visit the package on npm:
147
- ```
148
- https://www.npmjs.com/package/@schmitech/chatbot-widget
149
- ```
150
-
151
- 2. Install it in any project:
152
- ```bash
153
- npm install @schmitech/chatbot-widget
154
- ```
155
-
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>
177
- ```
178
-
179
- ### Importing the Bundled Version
180
-
181
- You can import the widget in different ways:
113
+ ---
114
+
115
+ ## ๐Ÿ“ค Publish to npm
116
+
117
+ **Build package:**
118
+
119
+ ```bash
120
+ npm run build
121
+ ```
182
122
 
123
+ **Test locally (optional):**
124
+
125
+ ```bash
126
+ npm pack --dry-run
127
+ ```
128
+
129
+ **Update version:**
130
+
131
+ ```bash
132
+ npm version [patch|minor|major]
133
+ ```
134
+
135
+ **Publish:**
136
+
137
+ ```bash
138
+ npm publish --access public
139
+ ```
140
+
141
+ Package URL: [@schmitech/chatbot-widget](https://www.npmjs.com/package/@schmitech/chatbot-widget)
142
+
143
+ ---
144
+
145
+ ## ๐Ÿ”— Usage Examples
146
+
147
+ ### HTML Integration
148
+
149
+ **Full bundle:**
183
150
  ```html
184
- <!-- HTML - Using the full bundle (JS + CSS combined) -->
185
151
  <script src="https://unpkg.com/@schmitech/chatbot-widget@0.2.0/dist/chatbot-widget.bundle.js"></script>
152
+ ```
186
153
 
187
- <!-- Using UMD version + separate CSS -->
154
+ **UMD + CSS separately:**
155
+ ```html
188
156
  <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" />
157
+ <link rel="stylesheet" href="https://unpkg.com/@schmitech/chatbot-widget@0.2.0/dist/chatbot-widget.css">
190
158
  ```
191
159
 
160
+ ### JavaScript/TypeScript
161
+
192
162
  ```javascript
193
- // ES Module - Using direct import from node_modules
194
163
  import { ChatWidget } from '@schmitech/chatbot-widget';
195
- // For the bundled version (if you're using a bundler like webpack)
196
164
  import '@schmitech/chatbot-widget/bundle';
197
165
  ```
198
166
 
199
- Using in TSX components:
200
-
201
- ```javascript
167
+ **React/TSX example:**
168
+ ```tsx
202
169
  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
- }, []);
170
+ if (typeof window !== 'undefined' && window.initChatbotWidget) {
171
+ window.initChatbotWidget({
172
+ apiUrl: import.meta.env.VITE_API_ENDPOINT,
173
+ apiKey: import.meta.env.VITE_API_KEY,
174
+ widgetConfig: { /* widget configurations */ }
175
+ });
176
+ }
177
+ }, []);
269
178
  ```
270
179
 
271
- ### Known Limitations and Troubleshooting
180
+ ---
272
181
 
273
- #### Scrolling Behavior
182
+ ## โš ๏ธ Known Issues & Troubleshooting
274
183
 
275
- The chat widget has a maximum height of 500px by default. When the conversation exceeds this height:
276
- - A scrollbar appears to navigate through the conversation
277
- - A "scroll to top" button appears when scrolled down more than 200px
278
- - The widget automatically scrolls to the bottom when new messages are added
279
- - You can clear the entire conversation by clicking the "Clear" button in the header
184
+ ### **Scrolling behavior:**
280
185
 
281
- If you need to customize the chat container height, you can modify it using CSS variables:
186
+ By default, widget height is `500px`. Customize with CSS:
282
187
 
283
188
  ```css
284
189
  :root {
285
- --chat-container-height: 600px; /* Increase maximum height */
190
+ --chat-container-height: 600px;
286
191
  }
287
192
  ```
288
193
 
289
- ## License
194
+ - Scrollbar auto-appears with long content
195
+ - "Scroll to top" button shows after scrolling `200px`
196
+ - Auto-scroll to bottom on new messages
197
+ - Clear conversations easily from the header
198
+
199
+ ---
200
+
201
+ ## ๐Ÿ“ƒ License
290
202
 
291
- Apache 2.0 (See LICENSE in project folder).
203
+ Apache 2.0 License - See [LICENSE](LICENSE).