@developer.notchatbot/webchat 1.2.10 → 1.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 +14 -33
- package/dist/types.d.ts +1 -0
- package/dist/utils/messaging.d.ts +2 -0
- package/dist/webchat-bundle.min.js +10 -9
- package/dist/webchat-bundle.min.umd.cjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
# 🔷 WebChat
|
|
2
|
-
|
|
3
|
-
A beautiful, embeddable chatbot widget built with **React**, **TypeScript**, **Vite**, **pnpm**, and **Tailwind CSS** that can be easily integrated into any website with **just one file**.
|
|
4
|
-
|
|
5
|
-
## ✨ Features
|
|
6
|
-
|
|
7
|
-
- **📦 Single File Bundle**: Everything in one file - no separate CSS needed!
|
|
8
|
-
- **🔷 TypeScript**: Full type safety with strict typing and excellent IntelliSense
|
|
9
|
-
- **⚛️ React 18**: Component-based architecture for maintainability
|
|
10
|
-
- **🎨 Tailwind CSS**: Utility-first styling with prefixed classes (`ncb-`)
|
|
11
|
-
- **⚡ Vite**: Lightning-fast development and optimized builds
|
|
12
|
-
- **📦 pnpm**: Efficient package management and faster installs
|
|
13
|
-
- **🔧 Easy Integration**: Add to any website with just one script tag
|
|
14
|
-
- **🎨 Modern Design**: Beautiful, responsive UI that works on all devices
|
|
15
|
-
- **🛠️ Customizable**: Configure colors, text, and behavior to match your brand
|
|
16
|
-
- **✨ Smooth Animations**: Typing indicators and smooth transitions
|
|
17
|
-
- **📱 Mobile Responsive**: Optimized for mobile and desktop
|
|
18
|
-
- **🔌 API Ready**: Built-in support for chat API integration
|
|
19
|
-
- **🚫 Zero Conflicts**: Prefixed CSS classes prevent style conflicts
|
|
20
|
-
- **🛡️ Type Safe**: Catch errors at compile time with TypeScript
|
|
1
|
+
# 🔷 WebChat - Embedded Chat
|
|
21
2
|
|
|
22
3
|
## 📦 Quick Start
|
|
23
4
|
|
|
@@ -343,21 +324,21 @@ We emit **custom browser events** so you can capture interactions and feed them
|
|
|
343
324
|
|
|
344
325
|
| Widget | Event name | Fired when | `detail` payload |
|
|
345
326
|
|--------|------------|------------|------------------|
|
|
346
|
-
| WebChat | `
|
|
347
|
-
| WebChat | `
|
|
348
|
-
| WebChat | `
|
|
349
|
-
| WebChat | `
|
|
350
|
-
| EmbedChat | `
|
|
351
|
-
| EmbedChat | `
|
|
327
|
+
| WebChat | `notchatbot-webchat-open` | The floating chat is opened | `{ conversationId }` |
|
|
328
|
+
| WebChat | `notchatbot-webchat-closed` | The floating chat is closed | `{ conversationId }` |
|
|
329
|
+
| WebChat | `notchatbot-webchat-message-sent` | The user sends one or more messages | `{ messages: Message[] }` |
|
|
330
|
+
| WebChat | `notchatbot-webchat-message-received` | A message is received from the server | `{ message: Message, role: 'assistant' \| 'employee' }` |
|
|
331
|
+
| EmbedChat | `notchatbot-embedchat-message-sent` | The user sends a message | `{ message: Message }` |
|
|
332
|
+
| EmbedChat | `notchatbot-embedchat-message-received` | A message is received | `{ message: Message, role: 'assistant' \| 'employee' }` |
|
|
352
333
|
|
|
353
334
|
`Message` follows the same interface used internally by the widget (id, text, sender, timestamp, etc.).
|
|
354
335
|
|
|
355
336
|
#### Quick example
|
|
356
337
|
```js
|
|
357
|
-
window.addEventListener('
|
|
358
|
-
window.addEventListener('
|
|
359
|
-
window.addEventListener('
|
|
360
|
-
window.addEventListener('
|
|
338
|
+
window.addEventListener('notchatbot-webchat-open', e => console.log('WebChat opened', e.detail));
|
|
339
|
+
window.addEventListener('notchatbot-webchat-closed', e => console.log('WebChat closed', e.detail));
|
|
340
|
+
window.addEventListener('notchatbot-webchat-message-sent', e => console.log('Sent', e.detail.messages));
|
|
341
|
+
window.addEventListener('notchatbot-webchat-message-received', e => {
|
|
361
342
|
const { role, message } = e.detail;
|
|
362
343
|
console.log('Received', role, message);
|
|
363
344
|
});
|
|
@@ -366,7 +347,7 @@ window.addEventListener('WebChatMessageReceived', e => {
|
|
|
366
347
|
#### Google Tag Manager / Google Analytics (GA4)
|
|
367
348
|
Push data directly to the **dataLayer** and create a trigger in GTM:
|
|
368
349
|
```js
|
|
369
|
-
window.addEventListener('
|
|
350
|
+
window.addEventListener('notchatbot-webchat-message-sent', e => {
|
|
370
351
|
window.dataLayer = window.dataLayer || [];
|
|
371
352
|
window.dataLayer.push({
|
|
372
353
|
event: 'webchat_message_sent',
|
|
@@ -379,13 +360,13 @@ Then in GTM, add a **Custom Event** trigger called `webchat_message_sent` and li
|
|
|
379
360
|
|
|
380
361
|
#### Meta / Facebook Pixel
|
|
381
362
|
```js
|
|
382
|
-
window.addEventListener('
|
|
363
|
+
window.addEventListener('notchatbot-webchat-open', () => {
|
|
383
364
|
if (window.fbq) {
|
|
384
365
|
fbq('trackCustom', 'WebChatOpened');
|
|
385
366
|
}
|
|
386
367
|
});
|
|
387
368
|
|
|
388
|
-
window.addEventListener('
|
|
369
|
+
window.addEventListener('notchatbot-webchat-message-received', e => {
|
|
389
370
|
if (window.fbq) {
|
|
390
371
|
fbq('trackCustom', 'WebChatMessageReceived', {
|
|
391
372
|
role: e.detail.role
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface SendMessagePayload {
|
|
|
13
13
|
};
|
|
14
14
|
chatbotUid: string;
|
|
15
15
|
newMessages: any[];
|
|
16
|
+
note?: string;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Creates a fallback bot message for error scenarios
|
|
@@ -30,6 +31,7 @@ export declare const createFallbackMessage: () => Message;
|
|
|
30
31
|
*/
|
|
31
32
|
export declare const buildMessagePayload: (conversationId: string, messages: Message[], newMessages: Message[], config: {
|
|
32
33
|
apiKey: string;
|
|
34
|
+
note?: string;
|
|
33
35
|
}, sessionId: string) => SendMessagePayload;
|
|
34
36
|
/**
|
|
35
37
|
* Sends messages to the chat API
|
|
@@ -16423,7 +16423,8 @@ const um = /* @__PURE__ */ Lu(lm), Mo = (e, t, n, r, o, i) => Pe(void 0, null, f
|
|
|
16423
16423
|
conversationId: e,
|
|
16424
16424
|
conversation: l,
|
|
16425
16425
|
chatbotUid: r.apiKey,
|
|
16426
|
-
newMessages: a
|
|
16426
|
+
newMessages: a,
|
|
16427
|
+
note: r.note
|
|
16427
16428
|
};
|
|
16428
16429
|
}, wd = (e) => Pe(void 0, null, function* () {
|
|
16429
16430
|
try {
|
|
@@ -16470,7 +16471,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16470
16471
|
return;
|
|
16471
16472
|
}
|
|
16472
16473
|
if (typeof window != "undefined") {
|
|
16473
|
-
const ee = o ? "
|
|
16474
|
+
const ee = o ? "notchatbot-webchat-open" : "notchatbot-webchat-closed";
|
|
16474
16475
|
window.dispatchEvent(new CustomEvent(ee, { detail: { conversationId: f } }));
|
|
16475
16476
|
}
|
|
16476
16477
|
}, [o, f]);
|
|
@@ -16485,7 +16486,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16485
16486
|
]), T = Z.useCallback((ee, Y = "bot") => {
|
|
16486
16487
|
if (A((le) => [...le, ee]), !o && (ee.sender === "bot" || Y === "bot") && ee.id !== s && h(!0), typeof window != "undefined" && (Y === "bot" || Y === "ably")) {
|
|
16487
16488
|
const le = Y === "bot" ? "assistant" : "employee";
|
|
16488
|
-
window.dispatchEvent(new CustomEvent("
|
|
16489
|
+
window.dispatchEvent(new CustomEvent("notchatbot-webchat-message-received", {
|
|
16489
16490
|
detail: { message: ee, role: le }
|
|
16490
16491
|
}));
|
|
16491
16492
|
}
|
|
@@ -16604,7 +16605,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16604
16605
|
}));
|
|
16605
16606
|
ae.push(...ce), be.push(...ce);
|
|
16606
16607
|
}
|
|
16607
|
-
A((ce) => [...ce, ...ae]), typeof window != "undefined" && ae.length > 0 && window.dispatchEvent(new CustomEvent("
|
|
16608
|
+
A((ce) => [...ce, ...ae]), typeof window != "undefined" && ae.length > 0 && window.dispatchEvent(new CustomEvent("notchatbot-webchat-message-sent", {
|
|
16608
16609
|
detail: { messages: ae }
|
|
16609
16610
|
})), C(!0);
|
|
16610
16611
|
try {
|
|
@@ -16612,7 +16613,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16612
16613
|
f,
|
|
16613
16614
|
be,
|
|
16614
16615
|
ae,
|
|
16615
|
-
{ apiKey: e.apiKey || "" },
|
|
16616
|
+
{ apiKey: e.apiKey || "", note: e.note },
|
|
16616
16617
|
P
|
|
16617
16618
|
), ve = yield wd(ce);
|
|
16618
16619
|
if (ve) {
|
|
@@ -16897,7 +16898,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16897
16898
|
});
|
|
16898
16899
|
}, []);
|
|
16899
16900
|
const C = Z.useCallback((p) => {
|
|
16900
|
-
u(p), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("
|
|
16901
|
+
u(p), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("notchatbot-embedchat-message-received", {
|
|
16901
16902
|
detail: { message: p, role: "employee" }
|
|
16902
16903
|
}));
|
|
16903
16904
|
}, [u]), P = Z.useCallback((p) => {
|
|
@@ -16916,7 +16917,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16916
16917
|
conversationId: S,
|
|
16917
16918
|
type: "text"
|
|
16918
16919
|
};
|
|
16919
|
-
u(s), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("
|
|
16920
|
+
u(s), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("notchatbot-embedchat-message-sent", {
|
|
16920
16921
|
detail: { message: s }
|
|
16921
16922
|
})), d.push(s), c.push(s);
|
|
16922
16923
|
}
|
|
@@ -16931,7 +16932,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16931
16932
|
metaContent: w.url
|
|
16932
16933
|
}));
|
|
16933
16934
|
s.forEach((w) => {
|
|
16934
|
-
u(w), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("
|
|
16935
|
+
u(w), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("notchatbot-embedchat-message-sent", {
|
|
16935
16936
|
detail: { message: w }
|
|
16936
16937
|
})), c.push(w);
|
|
16937
16938
|
}), d.push(...s);
|
|
@@ -16957,7 +16958,7 @@ También puedes pedir hablar con nuestro equipo de los sueños!`, xd = (e) => ({
|
|
|
16957
16958
|
l(k), f.current = k.client, m(!0);
|
|
16958
16959
|
}
|
|
16959
16960
|
const v = bd(w.response.message);
|
|
16960
|
-
v && (u(v), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("
|
|
16961
|
+
v && (u(v), typeof window != "undefined" && window.dispatchEvent(new CustomEvent("notchatbot-embedchat-message-received", {
|
|
16961
16962
|
detail: { message: v, role: "assistant" }
|
|
16962
16963
|
})));
|
|
16963
16964
|
} else {
|