@developer.notchatbot/webchat 1.2.9 → 1.2.11

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,23 +1,4 @@
1
- # 🔷 WebChat Widget
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
 
@@ -337,6 +318,64 @@ window.mountEmbedChat('embed-small'); // Remounts the chat in the same element
337
318
 
338
319
  ---
339
320
 
321
+ ### Listen to lifecycle & message events (🆕)
322
+
323
+ We emit **custom browser events** so you can capture interactions and feed them into Google Tag Manager, Google Analytics, Meta Pixel, or any other analytics tool.
324
+
325
+ | Widget | Event name | Fired when | `detail` payload |
326
+ |--------|------------|------------|------------------|
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' }` |
333
+
334
+ `Message` follows the same interface used internally by the widget (id, text, sender, timestamp, etc.).
335
+
336
+ #### Quick example
337
+ ```js
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 => {
342
+ const { role, message } = e.detail;
343
+ console.log('Received', role, message);
344
+ });
345
+ ```
346
+
347
+ #### Google Tag Manager / Google Analytics (GA4)
348
+ Push data directly to the **dataLayer** and create a trigger in GTM:
349
+ ```js
350
+ window.addEventListener('notchatbot-webchat-message-sent', e => {
351
+ window.dataLayer = window.dataLayer || [];
352
+ window.dataLayer.push({
353
+ event: 'webchat_message_sent',
354
+ messages: e.detail.messages,
355
+ conversationId: e.detail.messages[0]?.conversationId || null
356
+ });
357
+ });
358
+ ```
359
+ Then in GTM, add a **Custom Event** trigger called `webchat_message_sent` and link it to a GA4 event tag.
360
+
361
+ #### Meta / Facebook Pixel
362
+ ```js
363
+ window.addEventListener('notchatbot-webchat-open', () => {
364
+ if (window.fbq) {
365
+ fbq('trackCustom', 'WebChatOpened');
366
+ }
367
+ });
368
+
369
+ window.addEventListener('notchatbot-webchat-message-received', e => {
370
+ if (window.fbq) {
371
+ fbq('trackCustom', 'WebChatMessageReceived', {
372
+ role: e.detail.role
373
+ });
374
+ }
375
+ });
376
+ ```
377
+ These events make it easy to measure engagement and conversions driven by the chat widget without modifying its source code.
378
+
340
379
  ### Change position and padding dynamically (WebChat)
341
380
 
342
381
  #### 1. Change position and margin globally (flat)