@headwai/chat-bubble 1.0.2 → 2.0.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
@@ -1,209 +1,19 @@
1
- # Chat Bubble Svelte
2
-
3
- The chat bubble is based on a Svelte integration for the [deep-chat](https://www.npmjs.com/package/deep-chat) component, providing an easy-to-use AI chat interface for your web applications.
1
+ # Headwai Chat Bubble
4
2
 
5
3
  ## Features
6
4
 
7
5
  - 🚀 Easy integration
8
6
  - 🔧 Configurable via environment variables
9
- - 💬 Support for various AI providers (LocalChat, OpenAI and more)
7
+ - 💬 Connect to your LocalChat Model
8
+ - Review user conversations in LocalChat
10
9
  - 📱 Responsive design
11
10
  - 🎨 Customizable UI components
12
11
  - 🔄 Real-time messaging with WebSocket support
13
12
 
14
- ## Installation
15
-
16
- ### Prerequisites
17
-
18
- - Node.js (version 16 or higher)
19
- - npm or yarn
20
-
21
- ### Setup
22
-
23
- 1. Clone this repository:
24
- ```bash
25
- git clone <your-repo-url>
26
- cd chat-bubble
27
- ```
28
-
29
- 2. Install dependencies:
30
- ```bash
31
- npm install
32
- ```
33
-
34
- 3. Create a `.env` file in the root directory:
35
- ```bash
36
- cp .env.example .env
37
- ```
38
-
39
- 4. Configure your environment variables (see [Configuration](#configuration) section)
40
-
41
- 5. Start the development server:
42
- ```bash
43
- npm run dev
44
- ```
45
-
46
- ## Configuration
47
-
48
- The deep-chat component can be configured using environment variables. Create a `.env` file in your project root with the following variables:
49
-
50
- ### Required Environment Variables
51
-
52
- ```env
53
- # API Configuration
54
- VITE_CHAT_BUBBLE_API_URL=https://your-api-endpoint.com/api/chat/completions
55
- VITE_CHAT_BUBBLE_API_KEY=your-api-key-here
56
- VITE_CHAT_BUBBLE_MODEL_NAME=gpt-3.5-turbo
57
-
58
- # Connection Type (websocket, openAI, etc.)
59
- VITE_CHAT_BUBBLE_CONNECTION_TYPE=websocket
60
- ```
61
-
62
- ### Optional Environment Variables
63
-
64
- ```env
65
- # Additional Headers
66
- VITE_CHAT_BUBBLE_CONTENT_TYPE=application/json
67
-
68
- # Request Configuration
69
- VITE_CHAT_BUBBLE_MAX_MESSAGES=0
70
-
71
- # UI Configuration
72
- VITE_CHAT_BUBBLE_PLACEHOLDER_TEXT=Welcome to the chat!
73
- VITE_CHAT_BUBBLE_DEMO_MODE=false
74
- VITE_CHAT_BUBBLE_FAVICON_PATH=/icons/favicon.svg
75
- ```
76
-
77
- ## Usage
13
+ ### Easy Website Integration
78
14
 
79
- ### Basic Integration
15
+ Add the Headwai Chat Bubble to the respective .html file.
80
16
 
81
- To integrate the deep-chat component into your Svelte application:
82
-
83
- 1. **Install the package** (if using as a standalone package):
84
- ```bash
85
- npm install deep-chat
86
- ```
87
-
88
- 2. **Import and use in your Svelte component**:
89
-
90
- ```svelte
91
- <script>
92
- import { DeepChat } from "deep-chat";
93
-
94
- // Configuration using environment variables
95
- const connect = {
96
- type: import.meta.env.VITE_CHAT_BUBBLE_CONNECTION_TYPE || "websocket",
97
- url: import.meta.env.VITE_CHAT_BUBBLE_API_URL,
98
- headers: {
99
- Authorization: `Bearer ${import.meta.env.VITE_CHAT_BUBBLE_API_KEY}`,
100
- "Content-Type": import.meta.env.VITE_CHAT_BUBBLE_CONTENT_TYPE || "application/json"
101
- },
102
- additionalBodyProps: {
103
- model: import.meta.env.VITE_CHAT_BUBBLE_MODEL_NAME
104
- }
105
- };
106
-
107
- const requestBodyLimits = {
108
- maxMessages: parseInt(import.meta.env.VITE_CHAT_BUBBLE_MAX_MESSAGES) || 0
109
- };
110
-
111
- const textInputConfig = {
112
- placeholder: {
113
- text: import.meta.env.VITE_CHAT_BUBBLE_PLACEHOLDER_TEXT || "Type your message..."
114
- }
115
- };
116
-
117
- // Message transformation for OpenAI compatibility
118
- const requestInterceptor = (details) => {
119
- if (details.body && details.body.messages) {
120
- details.body.messages = details.body.messages.map(message => ({
121
- role: message.role === "ai" ? "assistant" : message.role,
122
- content: message.text || message.content
123
- }));
124
- }
125
- return details;
126
- };
127
-
128
- const responseInterceptor = (response) => {
129
- if (response.choices && response.choices[0] && response.choices[0].message) {
130
- const message = response.choices[0].message;
131
- return {
132
- text: message.content,
133
- role: message.role === "assistant" ? "ai" : message.role
134
- };
135
- }
136
-
137
- if (response.text || response.html || response.files) {
138
- return response;
139
- }
140
-
141
- if (typeof response === 'string') {
142
- return { text: response };
143
- }
144
-
145
- return response;
146
- };
147
- </script>
148
-
149
- <deep-chat
150
- demo={import.meta.env.VITE_CHAT_BUBBLE_DEMO_MODE === 'true'}
151
- textInput={textInputConfig}
152
- connect={connect}
153
- requestBodyLimits={requestBodyLimits}
154
- requestInterceptor={requestInterceptor}
155
- responseInterceptor={responseInterceptor}
156
- />
157
- ```
158
-
159
- ### Including Chat Bubble in Customer Websites
160
-
161
- #### Option 1: Build and Deploy (Complete Application)
162
-
163
- This option bundles everything into a ready-to-use application including all interceptors and logic.
164
-
165
- **What gets bundled:**
166
- - ✅ Request/Response interceptors (OpenAI compatibility)
167
- - ✅ Environment variable configuration
168
- - ✅ All chat functionality
169
- - ✅ UI components and styling
170
-
171
- **Build and deployment steps:**
172
- 1. **Configure environment variables** for production:
173
- ```bash
174
- # Production .env file
175
- VITE_CHAT_BUBBLE_API_URL=https://api.customer-domain.com/chat
176
- VITE_CHAT_BUBBLE_API_KEY=prod-api-key
177
- VITE_CHAT_BUBBLE_MODEL_NAME=gpt-4
178
- VITE_CHAT_BUBBLE_CONNECTION_TYPE=websocket
179
- VITE_CHAT_BUBBLE_DEMO_MODE=false
180
- ```
181
-
182
- 2. **Build the widget**:
183
- ```bash
184
- npm run build:widget
185
- ```
186
-
187
- 3. **Deploy the `dist-widget` folder** to your web server or CDN.
188
-
189
- **Result:** Customers get a complete chat application - no additional coding required!
190
-
191
- #### Option 2: Embed Chat Bubble as Script (Plug-and-Play)
192
-
193
- After building the widget, you can include the chat component in any website as a complete widget.
194
-
195
- **Build steps:**
196
- 1. **Build the widget**:
197
- ```bash
198
- npm run build:widget
199
- ```
200
-
201
- 2. **Publish to NPM** (for jsDelivr access):
202
- ```bash
203
- npm publish
204
- ```
205
-
206
- **Customer integration:**
207
17
  ```html
208
18
  <!DOCTYPE html>
209
19
  <html>
@@ -212,11 +22,19 @@ npm publish
212
22
  <!-- Configure via global variables -->
213
23
  <script>
214
24
  // Runtime configuration override
215
- window.DEEP_CHAT_CONFIG = {
216
- apiUrl: 'https://customer-api.com/chat',
217
- apiKey: 'customer-api-key',
218
- modelName: 'gpt-4',
219
- connectionType: 'websocket'
25
+ window.HEADWAI_CHAT_BUBBLE_CONFIG = {
26
+ apiUrl: 'https://company.localchat.at', // required
27
+ apiKey: 'customer-support-user-api-key', // required
28
+ modelId: 'customer-support-model-id', // required
29
+ maxMessages: 0, // optional - 0 means unlimited
30
+ placeholderText: 'Ask your question here!', // optional - default: 'Enter your questions here'
31
+ faviconPath: 'https://cdn.company.at/icons/favicon.svg', // optional - default: '/icons/favicon.svg'
32
+ initialMessage: 'Hey! My name is Supporty, how can I help you?', // optional - default: 'Hey, how can I help you?'
33
+ userMessageBackgroundColor: '#007bff', // optional - default: '#007bff'
34
+ aiMessageBackgroundColor: '#f1f3f4', // optional - default: '#f1f3f4'
35
+ userMessageTextColor: '#000000', // optional - default: '#000000'
36
+ aiMessageTextColor: '#000000', // optional - default: '#000000'
37
+ faviconBackgroundColor: '#667eea' // optional - default: '#667eea'
220
38
  };
221
39
  </script>
222
40
  </head>
@@ -233,274 +51,191 @@ npm publish
233
51
  </html>
234
52
  ```
235
53
 
236
- **Alternative: Multiple chat bubbles with data attributes:**
54
+ Set the configuration of the Headwai Chat Bubble in the `<script>` tag of the `<head>`.
55
+ Get the desired version of the JavaScript and CSS in your `<body>`.
56
+
57
+
58
+
59
+ ```html
60
+ <!-- Latest version -->
61
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist-widget/chat-bubble.css">
62
+ <script src="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist-widget/chat-bubble.js"></script>
63
+
64
+ <!-- Specific version -->
65
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@1.0.0/dist-widget/chat-bubble.css">
66
+ <script src="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@1.0.0/dist-widget/chat-bubble.js"></script>
67
+ ```
68
+
69
+ Place the Headwai Chat Bubble into the `<body>` tag. It will apear on the right corner of your website.
70
+
71
+
72
+ #### Multiple Headwai Chat Bubbles
73
+
74
+ For multiple instances use data attributes of the `<div>` tag for configuration instead.
75
+
237
76
  ```html
238
77
  <!-- Chat bubble with specific configuration -->
239
78
  <div data-chat-bubble
240
- data-chat-bubble-api-url="https://api1.com/chat"
241
- data-chat-bubble-api-key="key1"></div>
79
+ data-chat-bubble-api-url="https://company.localchat.at"
80
+ data-chat-bubble-api-key="customer-support-user-api-key"
81
+ data-chat-bubble-model-name="customer-support-model-id"
82
+ data-chat-bubble-max-messages="0"
83
+ data-chat-bubble-placeholder-text="Ask your question here!"
84
+ data-chat-bubble-favicon-path="https://cdn.company.at/icons/favicon.svg"
85
+ data-chat-bubble-initial-message="Hey! My name is Supporty, how can I help you?"
86
+ data-chat-bubble-user-message-background-color="#007bff"
87
+ data-chat-bubble-ai-message-background-color="#f1f3f4"
88
+ data-chat-bubble-user-message-text-color="#000000"
89
+ data-chat-bubble-ai-message-text-color="#000000"
90
+ data-chat-bubble-assistant-icon-color="#667eea">
91
+ </div>
242
92
 
243
93
  <!-- Another chat bubble with different config -->
244
94
  <div data-chat-bubble
245
- data-chat-bubble-api-url="https://api2.com/chat"
246
- data-chat-bubble-api-key="key2"></div>
95
+ data-chat-bubble-api-url="https://company.localchat.at"
96
+ data-chat-bubble-api-key="customer-support-user-api-key"
97
+ data-chat-bubble-model-name="FAQ-model-id"
98
+ data-chat-bubble-max-messages="10"
99
+ data-chat-bubble-placeholder-text="Ask about our FAQ..."
100
+ data-chat-bubble-favicon-path="https://cdn.company.at/icons/faq-icon.svg"
101
+ data-chat-bubble-initial-message="Hello! I can help you with frequently asked questions."
102
+ data-chat-bubble-user-message-background-color="#28a745"
103
+ data-chat-bubble-ai-message-background-color="#e9ecef"
104
+ data-chat-bubble-user-message-text-color="#ffffff"
105
+ data-chat-bubble-ai-message-text-color="#495057"
106
+ data-chat-bubble-assistant-icon-color="#28a745">
107
+ </div>
247
108
 
109
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist-widget/chat-bubble.css">
248
110
  <script src="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist-widget/chat-bubble.js"></script>
249
111
  ```
250
112
 
251
- **What customers get:**
252
- - ✅ Complete chat interface
253
- - ✅ All interceptors included
254
- - ✅ OpenAI API compatibility built-in
255
- - ✅ Just needs API configuration
256
- - ✅ Auto-initialization on page load
113
+ ## Configuration
257
114
 
258
- #### Option 3: NPM Package Integration (Developer Integration)
115
+ The Headwai Chat Bubble can be configured using either the global `window.HEADWAI_CHAT_BUBBLE_CONFIG` object or data attributes on individual chat bubble elements. Below are all available configuration options:
259
116
 
260
- For developers who need full control and customization.
117
+ ### Required Configuration
261
118
 
262
- **Build and publish steps:**
263
- 1. **Build the library**:
264
- ```bash
265
- npm run build:lib
119
+ #### `apiUrl`
120
+ **Type:** `string` | **Required:**
121
+ The base URL of your LocalChat API endpoint where the chat bubble will send messages. This is the same URL you access your LocalCaht instance in the Webbrowser.
122
+ ```javascript
123
+ apiUrl: 'https://company.localchat.at'
266
124
  ```
267
125
 
268
- 2. **Publish to NPM**:
269
- ```bash
270
- npm publish
126
+ #### `apiKey`
127
+ **Type:** `string` | **Required:** ✅
128
+ The API Key of a dedicated Headwai Chat Bubble user in LocalChat.
129
+ ```javascript
130
+ apiKey: 'customer-support-user-api-key'
271
131
  ```
272
132
 
273
- **Customer installation:**
274
- ```bash
275
- # Install in customer's project
276
- npm install @headwai/chat-bubble
277
- ```
133
+ **How to get your API Key:**
278
134
 
279
- **For Svelte projects:**
280
- ```svelte
281
- <!-- Customer's Svelte component -->
282
- <script>
283
- import { ChatBubble } from '@headwai/chat-bubble';
284
-
285
- // Customers MUST implement these interceptors themselves
286
- const requestInterceptor = (details) => {
287
- if (details.body && details.body.messages) {
288
- details.body.messages = details.body.messages.map(message => ({
289
- role: message.role === "ai" ? "assistant" : message.role,
290
- content: message.text || message.content
291
- }));
292
- }
293
- return details;
294
- };
295
-
296
- const responseInterceptor = (response) => {
297
- if (response.choices && response.choices[0] && response.choices[0].message) {
298
- const message = response.choices[0].message;
299
- return {
300
- text: message.content,
301
- role: message.role === "assistant" ? "ai" : message.role
302
- };
303
- }
304
- return response;
305
- };
306
-
307
- const connect = {
308
- type: "websocket",
309
- url: process.env.API_URL,
310
- headers: {
311
- Authorization: `Bearer ${process.env.API_KEY}`,
312
- "Content-Type": "application/json"
313
- },
314
- additionalBodyProps: {
315
- model: process.env.MODEL_NAME
316
- }
317
- };
318
- </script>
319
-
320
- <ChatBubble
321
- connect={connect}
322
- requestInterceptor={requestInterceptor}
323
- responseInterceptor={responseInterceptor}
324
- />
325
- ```
135
+ 1. **Access Settings**: Login to LocalChat with the dedicated Headwai Chat Bubble user (All conversations will be stored at this user's chats list) and click on the user menu, then select `Settings`.
326
136
 
327
- **For vanilla JavaScript projects:**
328
- ```html
329
- <script type="module">
330
- import { createChatBubble } from 'https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist/index.js';
331
-
332
- // Initialize manually with custom configuration
333
- const chatBubble = createChatBubble(
334
- document.getElementById('chat-container'),
335
- {
336
- apiUrl: 'https://api.example.com/chat',
337
- apiKey: 'your-api-key',
338
- // ... other props
339
- }
340
- );
341
- </script>
342
- ```
137
+ <img src="docs/images/settings.png" alt="LocalChat User Menu" width="50%" />
343
138
 
344
- **What customers need to implement:**
345
- - ❌ Request/Response interceptors (manual setup required)
346
- - ❌ Environment variable handling
347
- - ❌ API configuration logic
348
- - ✅ Deep chat component only
349
-
350
- ## Deployment Options Comparison
351
-
352
- | Feature | Built App (Option 1) | Script Embed (Option 2) | NPM Package (Option 3) |
353
- |---------|----------------------|--------------------------|-------------------------|
354
- | **Build Command** | `npm run build:widget` | `npm run build:widget` + publish | `npm run build:lib` + publish |
355
- | **Interceptors Included** | ✅ Yes, automatically | ✅ Yes, automatically | ❌ No, manual setup required |
356
- | **Environment Variables** | ✅ Built-in support | ✅ Runtime configuration | ❌ Customer implements |
357
- | **OpenAI Compatibility** | ✅ Ready to use | ✅ Ready to use | ❌ Customer implements |
358
- | **Setup Complexity** | 🟢 Minimal (just config) | � Minimal (script tag) | �🟡 Moderate (coding required) |
359
- | **Customization** | 🟡 Limited to env vars | � Limited to config object | �🟢 Full control |
360
- | **File Size** | 🟡 Larger (complete app) | � Larger (complete app) | �🟢 Smaller (just component) |
361
- | **Use Case** | Self-hosted deployment | CDN/jsDelivr embedding | Developers, custom integration |
362
- | **Auto-initialization** | ✅ Yes | ✅ Yes | ❌ Manual setup |
363
-
364
- ### Recommended Approach
365
-
366
- **For most customers:** Use **Option 2** (Script Embed via jsDelivr)
367
- - ✅ No coding required
368
- - ✅ All interceptors included
369
- - ✅ Easy CDN access via jsDelivr
370
- - ✅ Just configure via JavaScript object
371
- - ✅ Ready-to-deploy solution
372
- - ✅ Auto-initialization
373
-
374
- **For self-hosted deployments:** Use **Option 1** (Built Application)
375
- - ✅ Complete control over hosting
376
- - ✅ No external CDN dependencies
377
- - ✅ All interceptors included
378
- - ✅ Environment variable configuration
379
-
380
- **For developers who need customization:** Use **Option 3** (NPM Package)
381
- - ✅ Full control over interceptors
382
- - ✅ Custom API integrations
383
- - ✅ Smaller bundle size
384
- - ❌ More setup required
385
-
386
- ## Publishing to NPM and jsDelivr Access
387
-
388
- ### Publishing Steps
389
-
390
- 1. **Build both library and widget**:
391
- ```bash
392
- npm run build
393
- ```
139
+ 2. **Navigate to Account**: In the Settings sidebar, click on `Account` to access your account settings.
394
140
 
395
- 2. **Login to NPM** (if not already logged in):
396
- ```bash
397
- npm login
398
- ```
141
+ <img src="docs/images/api-keys.png" alt="LocalChat Settings Account" width="50%" />
399
142
 
400
- 3. **Publish the package**:
401
- ```bash
402
- npm publish
403
- ```
143
+ 3. **Get your API credentials**: In the API keys section, you have two options:
144
+ - **JWT Token**: Copy the existing JWT Token (expires after 7 days)
145
+ - **API Key**: Generate an API Key via `Generate API Key` button. Click the copy button next to the API Key field, or click the refresh button to generate a new permanent API Key
404
146
 
405
- ### jsDelivr CDN Access
147
+ **⚠️ Security Note:** When using permanent API Keys, ensure they are stored securely (e.g., environment variables, secure configuration) and never expose them directly in client-side code. If using JWT Tokens, implement an automatic refresh mechanism since they expire after 7 days - consider using a server-side proxy to handle token renewal and keep tokens secure.
406
148
 
407
- Once published to NPM, your package is automatically available on jsDelivr:
408
149
 
409
- **For Widget/Script Embed (Options 1 & 2):**
410
- ```html
411
- <!-- Latest version -->
412
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist-widget/chat-bubble.css">
413
- <script src="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist-widget/chat-bubble.js"></script>
414
-
415
- <!-- Specific version -->
416
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@1.0.0/dist-widget/chat-bubble.css">
417
- <script src="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@1.0.0/dist-widget/chat-bubble.js"></script>
150
+ #### `modelId`
151
+ **Type:** `string` | **Required:** ✅
152
+ The identifier of the AI model to use for generating responses. This should match a model configured in your LocalChat instance.
153
+ ```javascript
154
+ modelId: 'customer-support-model-id'
418
155
  ```
419
156
 
420
- **For Library/Module Import (Option 3):**
421
- ```html
422
- <!-- ES Module -->
423
- <script type="module">
424
- import { ChatBubble, createChatBubble } from 'https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist/index.js';
425
- </script>
157
+ 1. **Navigate to Model**: Login to LocalChat with the dedicated Headwai Chat Bubble user (Or any other user that is allowed to see the desired model) and click on the `Workspace` menu, then select `Models`. Search for the name of the desired model (Or create one). Click onto the edit-`Pen`.
426
158
 
427
- <!-- UMD (Universal Module Definition) -->
428
- <script src="https://cdn.jsdelivr.net/npm/@headwai/chat-bubble@latest/dist/index.umd.js"></script>
429
- ```
159
+ <img src="docs/images/model-edit.png" alt="LocalChat User Menu" width="50%" />
160
+
161
+ 1. **Copy Model Id**: Now the model is displayed with its `name` and right underneath the `model-id`. Copy the `model-id`.
162
+
163
+ <img src="docs/images/model-id.png" alt="LocalChat User Menu" width="50%" />
430
164
 
431
- ### File Structure After Build
165
+ ### Optional Configuration
432
166
 
167
+ #### `maxMessages`
168
+ **Type:** `number` | **Default:** `0` (unlimited)
169
+ Limits the number of messages stored in the conversation history in one singel conversation. Set to `0` for unlimited messages, or specify a positive number to limit history.
170
+ ```javascript
171
+ maxMessages: 10 // Keep and use only last 10 messages
433
172
  ```
434
- dist/ # NPM package (Option 3)
435
- ├── index.js # ES module
436
- ├── index.umd.js # UMD module
437
- └── style.css # Component styles
438
-
439
- dist-widget/ # Standalone widget (Options 1 & 2)
440
- ├── widget.html # Demo page
441
- ├── chat-bubble.js # Complete widget with auto-init
442
- ├── chat-bubble.css # Widget styles
443
- └── assets/ # Additional assets
173
+
174
+ #### `placeholderText`
175
+ **Type:** `string` | **Default:** `'Type your message...'`
176
+ The placeholder text displayed in the message input field when it's empty.
177
+ ```javascript
178
+ placeholderText: 'Ask your question here!'
444
179
  ```
445
180
 
446
- ## Environment Variables Reference
181
+ #### `faviconPath`
182
+ **Type:** `string` | **Default:** `'/icons/favicon.svg'`
183
+ Path or URL to the icon displayed on the chat bubble toggle button. Can be a relative path or absolute URL.
184
+ ```javascript
185
+ faviconPath: 'https://cdn.company.at/icons/favicon.svg'
186
+ ```
447
187
 
448
- | Variable | Description | Default | Required |
449
- |----------|-------------|---------|----------|
450
- | `VITE_CHAT_BUBBLE_API_URL` | The API endpoint URL | - | |
451
- | `VITE_CHAT_BUBBLE_API_KEY` | API authentication key | - | ✅ |
452
- | `VITE_CHAT_BUBBLE_MODEL_NAME` | AI model name to use | `gpt-3.5-turbo` | |
453
- | `VITE_CHAT_BUBBLE_CONNECTION_TYPE` | Connection type (websocket, openAI, etc.) | `websocket` | ✅ |
454
- | `VITE_CHAT_BUBBLE_CONTENT_TYPE` | HTTP Content-Type header | `application/json` | ❌ |
455
- | `VITE_CHAT_BUBBLE_MAX_MESSAGES` | Maximum messages in conversation history | `0` (unlimited) | ❌ |
456
- | `VITE_CHAT_BUBBLE_PLACEHOLDER_TEXT` | Chat input placeholder text | `Type your message...` | ❌ |
457
- | `VITE_CHAT_BUBBLE_DEMO_MODE` | Enable demo mode | `false` | ❌ |
458
- | `VITE_CHAT_BUBBLE_FAVICON_PATH` | Path to favicon/icon for chat toggle button | `/icons/favicon.svg` | ❌ |
188
+ #### `initialMessage`
189
+ **Type:** `string` | **Default:** `undefined`
190
+ An optional welcome message that appears when the chat is first opened. If not set, no initial message is displayed.
191
+ ```javascript
192
+ initialMessage: 'Hey! My name is Supporty, how can I help you?'
193
+ ```
459
194
 
460
- ## API Compatibility
195
+ ### Styling Configuration
461
196
 
462
- This component is designed to work with OpenAI-compatible APIs. The request and response interceptors handle the message format transformation between deep-chat and OpenAI formats.
197
+ #### `userMessageBackgroundColor`
198
+ **Type:** `string` | **Default:** `'#007bff'`
199
+ Background color for messages sent by the user. Accepts any valid CSS color value.
200
+ ```javascript
201
+ userMessageBackgroundColor: '#007bff'
202
+ ```
463
203
 
464
- ### Supported Message Flow
204
+ #### `aiMessageBackgroundColor`
205
+ **Type:** `string` | **Default:** `'#f1f3f4'`
206
+ Background color for messages sent by the AI assistant. Accepts any valid CSS color value.
207
+ ```javascript
208
+ aiMessageBackgroundColor: '#f1f3f4'
209
+ ```
465
210
 
466
- 1. **User Input** → Deep Chat format
467
- 2. **Request Interceptor** Transforms to OpenAI format
468
- 3. **API Call** Your configured endpoint
469
- 4. **Response Interceptor** → Transforms back to Deep Chat format
470
- 5. **Display** → Rendered in chat interface
211
+ #### `userMessageTextColor`
212
+ **Type:** `string` | **Default:** `'#000000'`
213
+ Text color for user messages. Accepts any valid CSS color value.
214
+ ```javascript
215
+ userMessageTextColor: '#ffffff'
216
+ ```
471
217
 
472
- ## Development
218
+ #### `aiMessageTextColor`
219
+ **Type:** `string` | **Default:** `'#000000'`
220
+ Text color for AI assistant messages. Accepts any valid CSS color value.
221
+ ```javascript
222
+ aiMessageTextColor: '#333333'
223
+ ```
473
224
 
474
- ### Scripts
225
+ #### `faviconBackgroundColor`
226
+ **Type:** `string` | **Default:** `'#667eea'`
227
+ Base color used for the assistant icon gradient. This color influences the overall appearance of the AI assistant's avatar.
228
+ ```javascript
229
+ faviconBackgroundColor: '#667eea'
230
+ ```
475
231
 
476
- - `npm run dev` - Start development server
477
- - `npm run build` - Build both library and widget for production
478
- - `npm run build:lib` - Build NPM package (Option 3)
479
- - `npm run build:widget` - Build standalone widget (Options 1 & 2)
480
- - `npm run build:app` - Build demo application
481
- - `npm run preview` - Preview production build
232
+ ### Data Attribute Format
482
233
 
483
- ### Project Structure
234
+ When using data attributes for multiple chat bubbles, convert camelCase property names to kebab-case with the `data-chat-bubble-` prefix:
484
235
 
485
- ```
486
- chat-bubble/
487
- ├── src/
488
- │ ├── App.svelte # Main chat component
489
- │ ├── main.js # Development entry point
490
- │ ├── lib.js # NPM package entry point
491
- │ └── widget.js # Widget/standalone entry point
492
- ├── dist/ # NPM package build output
493
- ├── dist-widget/ # Widget build output
494
- ├── package.json # Dependencies and scripts
495
- ├── vite.config.js # Default Vite configuration
496
- ├── vite.lib.config.js # Library build configuration
497
- ├── vite.widget.config.js # Widget build configuration
498
- ├── vite.app.config.js # App build configuration
499
- ├── svelte.config.js # Svelte configuration
500
- ├── index.html # Development HTML
501
- ├── widget.html # Widget HTML template
502
- └── README.md # This file
503
- ```
236
+ - `apiUrl` → `data-chat-bubble-api-url`
237
+ - `userMessageBackgroundColor` → `data-chat-bubble-user-message-background-color`
238
+ - `initialMessage` → `data-chat-bubble-initial-message`
504
239
 
505
240
  ## Troubleshooting
506
241
 
@@ -508,21 +243,4 @@ chat-bubble/
508
243
 
509
244
  1. **CORS Errors**: Ensure your API endpoint allows requests from your domain
510
245
  2. **Authentication Failures**: Verify your API key is correct and has proper permissions
511
- 3. **WebSocket Connection Issues**: Check if your API supports WebSocket connections
512
- 4. **Environment Variables Not Loading**: Ensure variables are prefixed with `VITE_CHAT_BUBBLE_`
513
-
514
- ### Debug Mode
515
-
516
- Enable debug mode by setting:
517
- ```env
518
- VITE_CHAT_BUBBLE_DEMO_MODE=true
519
- ```
520
-
521
- This will enable demo features that can help test the component without a real API connection.
522
-
523
- ## Support
524
246
 
525
- For issues and questions:
526
- - Create an issue in this repository
527
- - Check the [deep-chat documentation](https://deepchat.dev/)
528
- - Review the [API compatibility guide](https://deepchat.dev/docs/connect)