@schmitech/chatbot-widget 0.2.4 โ 0.3.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 +139 -227
- package/dist/chatbot-widget.bundle.js +33 -33
- package/dist/chatbot-widget.es.js +1283 -1267
- package/dist/chatbot-widget.umd.js +33 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,89 +1,108 @@
|
|
|
1
|
-
# Chatbot Widget
|
|
1
|
+
# ๐ฌ Chatbot Widget
|
|
2
2
|
|
|
3
|
-
A reusable chatbot widget
|
|
3
|
+
A simple, reusable chatbot widget seamlessly integrated into any website with minimal effort.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
+
---
|
|
18
17
|
|
|
18
|
+
## ๐ ๏ธ Installation
|
|
19
|
+
|
|
20
|
+
### โ
Prerequisites
|
|
19
21
|
- Node.js 18+ and npm
|
|
20
22
|
|
|
21
|
-
###
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
```bash
|
|
35
|
+
cd api
|
|
36
|
+
npm install
|
|
37
|
+
npm run build
|
|
38
|
+
```
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
cd api
|
|
32
|
-
npm install
|
|
33
|
-
npm run build
|
|
34
|
-
```
|
|
40
|
+
3. **Install & Build Widget**
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
42
|
+
```bash
|
|
43
|
+
cd ../widget
|
|
44
|
+
npm install
|
|
45
|
+
npm run build
|
|
46
|
+
npm run build:bundle
|
|
47
|
+
```
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
##
|
|
51
|
-
Check file demo.html containing an working example on how to customize the widget.
|
|
56
|
+
## ๐จ Customization
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
See `demo.html` for customization examples:
|
|
54
59
|
|
|
55
|
-
```
|
|
60
|
+
```bash
|
|
56
61
|
python3 -m http.server 8080
|
|
57
62
|
```
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## ๐ข Deployment
|
|
60
67
|
|
|
61
|
-
1. Host
|
|
62
|
-
2. Update
|
|
63
|
-
3.
|
|
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
|
-
|
|
72
|
+
---
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
## โ๏ธ Widget API Reference
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
### `initChatbotWidget(config)`
|
|
77
|
+
Initializes widget configuration.
|
|
70
78
|
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
99
|
+
# Development server
|
|
81
100
|
npm run dev
|
|
82
101
|
|
|
83
|
-
#
|
|
102
|
+
# Code linting
|
|
84
103
|
npm run lint
|
|
85
104
|
|
|
86
|
-
#
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
167
|
+
**React/TSX example:**
|
|
168
|
+
```tsx
|
|
202
169
|
useEffect(() => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
180
|
+
---
|
|
272
181
|
|
|
273
|
-
|
|
182
|
+
## โ ๏ธ Known Issues & Troubleshooting
|
|
274
183
|
|
|
275
|
-
|
|
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
|
-
|
|
186
|
+
By default, widget height is `500px`. Customize with CSS:
|
|
282
187
|
|
|
283
188
|
```css
|
|
284
189
|
:root {
|
|
285
|
-
--chat-container-height: 600px;
|
|
190
|
+
--chat-container-height: 600px;
|
|
286
191
|
}
|
|
287
192
|
```
|
|
288
193
|
|
|
289
|
-
|
|
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
|
|
203
|
+
Apache 2.0 License - See [LICENSE](LICENSE).
|