@data-netmonk/mona-chat-widget 2.6.6 → 2.6.8
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 +119 -104
- package/dist/index.cjs +56 -56
- package/dist/index.js +6613 -6497
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Chat widget package developed by Netmonk data & solution team to be imported in
|
|
|
18
18
|
|
|
19
19
|
✅ **Previous Non-breaking Changes (`v2.6.1`):**
|
|
20
20
|
1. **Built-in voice mode button** - Chat widget now includes a microphone button to toggle voice mode directly from the input area
|
|
21
|
-
2. **Speech-to-text flow for voice mode** - Recorded user audio is sent to the configured
|
|
21
|
+
2. **Speech-to-text flow for voice mode** - Recorded user audio is sent to the configured STT endpoint, then the transcription is forwarded as a normal chat message
|
|
22
22
|
3. **Phoneme-driven avatar animation** - The widget can animate Mona's avatar during TTS playback based on phoneme/viseme IDs returned by the backend
|
|
23
23
|
4. **Supported phoneme IDs** - `A`, `BP`, `ChJ`, `E`, `FV`, `I`, `KG`, `L`, `M`, `O`, `SZ`, `U`
|
|
24
24
|
|
|
@@ -93,83 +93,97 @@ Chat widget package developed by Netmonk data & solution team to be imported in
|
|
|
93
93
|
|
|
94
94
|
## 🚅 Quick start
|
|
95
95
|
|
|
96
|
-
### Prerequisites
|
|
97
|
-
|
|
98
96
|
---
|
|
99
97
|
|
|
100
|
-
1. Install
|
|
101
|
-
```
|
|
102
|
-
npm install
|
|
103
|
-
```
|
|
104
|
-
2.
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
98
|
+
1. Install the package
|
|
99
|
+
```bash
|
|
100
|
+
npm install @data-netmonk/mona-chat-widget
|
|
101
|
+
```
|
|
102
|
+
2. Render the widget with the minimum required props
|
|
103
|
+
```jsx
|
|
104
|
+
import { ChatWidget } from "@data-netmonk/mona-chat-widget";
|
|
105
|
+
|
|
106
|
+
export default function App() {
|
|
107
|
+
return (
|
|
108
|
+
<ChatWidget
|
|
109
|
+
sourceId="source-123"
|
|
110
|
+
webhookUrl="https://api.example.com/webhook"
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
3. Choose the usage mode you need
|
|
116
|
+
|
|
117
|
+
**1. Basic mode**
|
|
118
|
+
|
|
119
|
+
```jsx
|
|
120
|
+
<ChatWidget
|
|
121
|
+
sourceId="source-123"
|
|
122
|
+
webhookUrl="https://api.example.com/webhook"
|
|
123
|
+
/>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**2. With auth mode**
|
|
127
|
+
|
|
128
|
+
```jsx
|
|
129
|
+
<ChatWidget
|
|
130
|
+
sourceId="source-123"
|
|
131
|
+
webhookUrl="https://api.example.com/webhook"
|
|
132
|
+
userId="user-123"
|
|
133
|
+
username="John"
|
|
134
|
+
authUrl="https://api.example.com/login/chatwidget"
|
|
135
|
+
/>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**3. With voice mode**
|
|
139
|
+
|
|
140
|
+
```jsx
|
|
141
|
+
<ChatWidget
|
|
142
|
+
sourceId="source-123"
|
|
143
|
+
webhookUrl="https://api.example.com/webhook"
|
|
144
|
+
voiceConfig={{
|
|
145
|
+
sttEndpoint: "https://voice.example.com/stt",
|
|
146
|
+
sttApiKey: "your-stt-key",
|
|
147
|
+
ttsEndpoint: "https://voice.example.com/tts",
|
|
148
|
+
ttsApiKey: "your-tts-key",
|
|
149
|
+
ttsMinioObjectEndpoint: "https://voice.example.com/minio/object",
|
|
150
|
+
ttsMinioApiKey: "your-minio-key",
|
|
151
|
+
ttsMinioBucket: "chatbot-tts",
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**4. Full props example**
|
|
157
|
+
|
|
158
|
+
```jsx
|
|
159
|
+
<ChatWidget
|
|
160
|
+
sourceId="source-123"
|
|
161
|
+
webhookUrl="https://api.example.com/webhook"
|
|
162
|
+
userId="user-123"
|
|
163
|
+
authUrl="https://api.example.com/login/chatwidget"
|
|
164
|
+
username="John Doe"
|
|
165
|
+
voiceConfig={{
|
|
166
|
+
sttEndpoint: "https://voice.example.com/stt",
|
|
167
|
+
sttApiKey: "your-stt-key",
|
|
168
|
+
ttsEndpoint: "https://voice.example.com/tts",
|
|
169
|
+
ttsApiKey: "your-tts-key",
|
|
170
|
+
ttsMinioObjectEndpoint: "https://voice.example.com/minio/object",
|
|
171
|
+
ttsMinioApiKey: "your-minio-key",
|
|
172
|
+
ttsMinioBucket: "chatbot-tts",
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Common optional props**
|
|
178
|
+
|
|
179
|
+
- `userId`: ID user login. Jika tidak diisi, widget akan memakai guest visitor ID.
|
|
180
|
+
- `username`: nama yang dikirim bersama session chat.
|
|
181
|
+
- `authUrl`: endpoint auth/refresh khusus chat widget.
|
|
182
|
+
- `data`: custom payload tambahan untuk backend.
|
|
183
|
+
- `voiceConfig`: aktifkan voice mode, STT, TTS, dan phoneme avatar bila dibutuhkan.
|
|
184
|
+
- `showLauncher`, `autoOpen`, `enabled`, `position`, `width`, `height`: untuk perilaku dan layout widget.
|
|
185
|
+
|
|
186
|
+
By default, STT and TTS requests send the API key using `x-api-key` without any prefix. MinIO object fetch uses `X-API-Key`. If your provider needs a different auth format, override it through `voiceConfig`.
|
|
173
187
|
|
|
174
188
|
---
|
|
175
189
|
|
|
@@ -180,8 +194,8 @@ Chat widget package developed by Netmonk data & solution team to be imported in
|
|
|
180
194
|
The chat widget includes a built-in mock mode for testing and demonstrations without requiring a backend server.
|
|
181
195
|
|
|
182
196
|
**To enable mock mode:**
|
|
183
|
-
1.
|
|
184
|
-
2.
|
|
197
|
+
1. Pass `widgetConfig={{ useMockResponses: true }}`
|
|
198
|
+
2. Render the widget normally
|
|
185
199
|
|
|
186
200
|
**Mock responses include:**
|
|
187
201
|
- Greetings (hello, hi, halo, start) - with interactive buttons
|
|
@@ -353,9 +367,9 @@ For responses with buttons:
|
|
|
353
367
|
|
|
354
368
|
---
|
|
355
369
|
|
|
356
|
-
The widget now includes a built-in microphone button in the input area. Clicking the button toggles voice mode, requests microphone access, records speech, sends the recorded audio to `
|
|
370
|
+
The widget now includes a built-in microphone button in the input area. Clicking the button toggles voice mode, requests microphone access, records speech, sends the recorded audio to `voiceConfig.sttEndpoint`, and forwards the returned transcription as a regular user message.
|
|
357
371
|
|
|
358
|
-
If `
|
|
372
|
+
If `voiceConfig.sttApiKey` is set, the STT request includes `x-api-key: <key>` by default. If another provider needs a different auth format, override it through `voiceConfig`.
|
|
359
373
|
|
|
360
374
|
**Expected STT request/response shape:**
|
|
361
375
|
|
|
@@ -407,45 +421,46 @@ Phoneme IDs are normalized case-insensitively in the widget, so values such as `
|
|
|
407
421
|
}
|
|
408
422
|
```
|
|
409
423
|
|
|
410
|
-
When this payload is available, the widget resolves MinIO object keys first for audio and timeline metadata. If no usable asset is found, it falls back to `
|
|
424
|
+
When this payload is available, the widget resolves MinIO object keys first for audio and timeline metadata. If no usable asset is found, it falls back to `voiceConfig.ttsEndpoint`.
|
|
411
425
|
|
|
412
426
|
**Expected TTS response shape:**
|
|
413
427
|
|
|
414
428
|
```text
|
|
415
429
|
body: <raw WAV or other audio binary>
|
|
416
430
|
content-type: audio/wav
|
|
417
|
-
x-tts-
|
|
418
|
-
x-tts-
|
|
419
|
-
x-tts-
|
|
431
|
+
x-tts-metadata-id: 7d8f6a0f0f684e97b7b8d8db67f4f3a1
|
|
432
|
+
x-tts-metadata-path: /tts/metadata/7d8f6a0f0f684e97b7b8d8db67f4f3a1
|
|
433
|
+
x-tts-duration-ms: 120
|
|
420
434
|
```
|
|
421
435
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
Decoded `x-tts-phonemes-b64`:
|
|
425
|
-
|
|
426
|
-
```text
|
|
427
|
-
M A
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
Decoded `x-tts-phoneme-timeline-b64`:
|
|
436
|
+
Metadata lengkap diambil dari endpoint metadata yang ditunjuk header tadi:
|
|
431
437
|
|
|
432
438
|
```json
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
439
|
+
GET /tts/metadata/7d8f6a0f0f684e97b7b8d8db67f4f3a1
|
|
440
|
+
{
|
|
441
|
+
"id": "7d8f6a0f0f684e97b7b8d8db67f4f3a1",
|
|
442
|
+
"phonemes": "M A",
|
|
443
|
+
"phoneme_timeline": [
|
|
444
|
+
{ "phoneme": "M", "startMs": 0, "endMs": 120 }
|
|
445
|
+
],
|
|
446
|
+
"visemes": [
|
|
447
|
+
{ "id": "M", "startMs": 0, "endMs": 120 },
|
|
448
|
+
{ "id": "A", "startMs": 121, "endMs": 260 },
|
|
449
|
+
{ "id": "SZ", "startMs": 261, "endMs": 420 }
|
|
450
|
+
],
|
|
451
|
+
"duration_ms": 420
|
|
452
|
+
}
|
|
436
453
|
```
|
|
437
454
|
|
|
438
|
-
|
|
455
|
+
Widget ini masih mendukung header base64 lama sebagai fallback:
|
|
439
456
|
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
{ "id": "SZ", "startMs": 261, "endMs": 420 }
|
|
445
|
-
]
|
|
457
|
+
```text
|
|
458
|
+
x-tts-visemes-b64
|
|
459
|
+
x-tts-phonemes-b64
|
|
460
|
+
x-tts-phoneme-timeline-b64
|
|
446
461
|
```
|
|
447
462
|
|
|
448
|
-
|
|
463
|
+
Widget juga masih mendukung format JSON body lama sebagai fallback, tetapi untuk audio binary format metadata endpoint di atas sekarang jadi jalur utama yang direkomendasikan.
|
|
449
464
|
|
|
450
465
|
---
|
|
451
466
|
|