lulichat 1.0.8 → 1.0.16
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 +111 -42
- package/dist/index.d.ts +131 -4
- package/dist/lulichat-widget-standalone.es.js +12691 -0
- package/dist/lulichat-widget-standalone.umd.js +116 -0
- package/dist/lulichat-widget.es.js +3129 -0
- package/dist/lulichat-widget.html +153 -0
- package/dist/lulichat-widget.js +131 -0
- package/dist/lulichat-widget.umd.js +29 -0
- package/dist/style.css +1 -1
- package/package.json +91 -72
- package/dist/components/LuliChat.d.ts +0 -3
- package/dist/lulichat-support.es.js +0 -1993
- package/dist/lulichat-support.umd.js +0 -31
- package/dist/types/index.d.ts +0 -167
package/README.md
CHANGED
|
@@ -1,69 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LuliChat Support Chat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
LuliChat Support Chat is a library that provides a real-time live support chat widget for web applications. It can be integrated into React applications or loaded directly via UMD/script tags in standard HTML pages.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Contact information collection form with validation.
|
|
9
|
-
- Real-time chat interface using WebSocket.
|
|
10
|
-
- Easy integration into any React application.
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
To install the Lulichat Support Chat library, run the following command:
|
|
7
|
+
## 1. React Installation & Usage
|
|
15
8
|
|
|
9
|
+
### Installation
|
|
16
10
|
```bash
|
|
17
11
|
npm install lulichat
|
|
18
12
|
```
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
To use the Lulichat Support Chat in your application, import the components as follows:
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
import Lulichat from "lulichat";
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Example
|
|
29
|
-
|
|
14
|
+
### Usage
|
|
15
|
+
Import the component and stylesheet:
|
|
30
16
|
```tsx
|
|
31
17
|
import React from "react";
|
|
32
|
-
import
|
|
18
|
+
import LuliChat from "lulichat";
|
|
33
19
|
import "lulichat/dist/style.css";
|
|
34
20
|
|
|
35
21
|
const App = () => {
|
|
36
22
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
position="bottom-right"
|
|
47
|
-
/>
|
|
48
|
-
</div>
|
|
23
|
+
<LuliChat
|
|
24
|
+
apiKey="YOUR_API_KEY"
|
|
25
|
+
companyName="LuliChat Demo"
|
|
26
|
+
welcomeMessage="How can we help you today?"
|
|
27
|
+
primaryColor="#4f46e5"
|
|
28
|
+
allowAnonymous={true}
|
|
29
|
+
requireContactInfo={true}
|
|
30
|
+
position="bottom-right"
|
|
31
|
+
/>
|
|
49
32
|
);
|
|
50
33
|
};
|
|
51
34
|
|
|
52
35
|
export default App;
|
|
53
36
|
```
|
|
54
37
|
|
|
55
|
-
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 2. Vanilla Script Integration (No React)
|
|
41
|
+
|
|
42
|
+
You can load the widget on any website using the unpkg CDN.
|
|
43
|
+
|
|
44
|
+
### Option A: Standalone Bundle (Recommended for non-React websites)
|
|
45
|
+
This bundle includes React, ReactDOM, Socket.io, marked, and DOMPurify internally, making it a zero-dependency drop-in.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<script
|
|
49
|
+
src="https://unpkg.com/lulichat/dist/lulichat-widget-standalone.umd.js"
|
|
50
|
+
data-api-key="YOUR_API_KEY"
|
|
51
|
+
data-company-name="Your Company"
|
|
52
|
+
data-position="bottom-right"
|
|
53
|
+
data-primary-color="#4f46e5"
|
|
54
|
+
defer
|
|
55
|
+
onload="window.LuliChatSupport && window.LuliChatSupport.initFromScript()"
|
|
56
|
+
></script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Option B: Externalized Bundle
|
|
60
|
+
If your page already loads React, ReactDOM, and socket.io-client, use the smaller externalized bundle:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<link rel="stylesheet" href="https://unpkg.com/lulichat/dist/style.css" />
|
|
64
|
+
<script
|
|
65
|
+
src="https://unpkg.com/lulichat/dist/lulichat-widget.umd.js"
|
|
66
|
+
data-api-key="YOUR_API_KEY"
|
|
67
|
+
data-company-name="Your Company"
|
|
68
|
+
data-position="bottom-right"
|
|
69
|
+
data-primary-color="#4f46e5"
|
|
70
|
+
defer
|
|
71
|
+
onload="window.LuliChatSupport && window.LuliChatSupport.initFromScript()"
|
|
72
|
+
></script>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 3. Iframe Embedding Options
|
|
78
|
+
|
|
79
|
+
### Option A: Isolated Iframe (Script Tag)
|
|
80
|
+
To isolate the chat DOM and CSS from your parent page styles, enable isolated mode using the `data-isolated` attribute:
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<script
|
|
84
|
+
src="https://unpkg.com/lulichat/dist/lulichat-widget.umd.js"
|
|
85
|
+
data-api-key="YOUR_API_KEY"
|
|
86
|
+
data-isolated="iframe"
|
|
87
|
+
data-iframe-width="360px"
|
|
88
|
+
data-iframe-height="560px"
|
|
89
|
+
defer
|
|
90
|
+
onload="window.LuliChatSupport && window.LuliChatSupport.initFromScript()"
|
|
91
|
+
></script>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Option B: Zero-JS Iframe Embedding (Static Frame)
|
|
95
|
+
If you want to embed the chat widget strictly via a standard `<iframe>` without any scripts on the parent page, point the frame to the hosted `lulichat-widget.html`:
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<iframe
|
|
99
|
+
src="https://unpkg.com/lulichat/dist/lulichat-widget.html?apiKey=YOUR_API_KEY&position=bottom-right&primaryColor=%234f46e5"
|
|
100
|
+
width="380"
|
|
101
|
+
height="600"
|
|
102
|
+
style="border:0;background:transparent"
|
|
103
|
+
loading="lazy"
|
|
104
|
+
></iframe>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 4. Configuration Options
|
|
110
|
+
|
|
111
|
+
Set these options via React component props, `data-*` script tag attributes, or URL query parameters:
|
|
112
|
+
|
|
113
|
+
| Parameter / Attribute | Description | Default |
|
|
114
|
+
| :--- | :--- | :--- |
|
|
115
|
+
| `apiKey` / `data-api-key` | Your LuliChat public API key (Required) | - |
|
|
116
|
+
| `companyName` / `data-company-name` | Header title of the widget | `LuliChat` |
|
|
117
|
+
| `welcomeMessage` / `data-welcome-message` | Initial greeting message | - |
|
|
118
|
+
| `primaryColor` / `data-primary-color` | Hex theme color code (e.g. `#4f46e5`) | `#4f46e5` |
|
|
119
|
+
| `position` / `data-position` | Widget placement (`bottom-right`, `bottom-left`, `top-right`, `top-left`) | `bottom-right` |
|
|
120
|
+
| `allowAnonymous` / `data-allow-anonymous` | Allow users to chat without entering contact info | `false` |
|
|
121
|
+
| `requireContactInfo` / `data-require-contact-info` | Ask for contact info before initiating a session | `true` |
|
|
122
|
+
| `baseUrl` / `data-base-url` | Base endpoint URL for the chat backend API | `https://api.lulichat.com` |
|
|
56
123
|
|
|
57
|
-
|
|
124
|
+
---
|
|
58
125
|
|
|
59
|
-
|
|
60
|
-
- **ContactForm**: Displays a form for users to input their contact details.
|
|
61
|
-
- **SupportChat**: Manages the chat interface and socket connection.
|
|
126
|
+
## 5. JavaScript / Programmatic API
|
|
62
127
|
|
|
63
|
-
|
|
128
|
+
When loaded via a script tag, the widget registers a global `window.LuliChatSupport` object:
|
|
64
129
|
|
|
65
|
-
|
|
130
|
+
- `window.LuliChatSupport.mount(config, targetSelector?)`: Mounts the widget programmatically.
|
|
131
|
+
- `window.LuliChatSupport.unmount(id)`: Unmounts a specific widget instance by ID.
|
|
132
|
+
- `window.LuliChatSupport.unmountAll()`: Removes all mounted widget instances.
|
|
133
|
+
- `window.LuliChatSupport.mountIframe(config, iframeConfig)`: Programmatically mounts the widget within an isolated iframe.
|
|
134
|
+
- `window.LuliChatSupport.initFromScript()`: Reads properties from the current `<script>` tag and initializes the widget.
|
|
66
135
|
|
|
67
136
|
## License
|
|
68
137
|
|
|
69
|
-
This project is licensed under the MIT License.
|
|
138
|
+
This project is licensed under the MIT License.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,131 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface LuliChatConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
7
|
+
primaryColor?: string;
|
|
8
|
+
companyName?: string;
|
|
9
|
+
welcomeMessage?: string;
|
|
10
|
+
requireContactInfo?: boolean;
|
|
11
|
+
allowAnonymous?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MountResult {
|
|
15
|
+
id: string;
|
|
16
|
+
unmount: () => void;
|
|
17
|
+
container: HTMLElement;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function mount(
|
|
21
|
+
config: LuliChatConfig,
|
|
22
|
+
target?: string | HTMLElement
|
|
23
|
+
): MountResult;
|
|
24
|
+
|
|
25
|
+
export function unmount(id: string): void;
|
|
26
|
+
|
|
27
|
+
export function unmountAll(): void;
|
|
28
|
+
|
|
29
|
+
export interface IframeOptions {
|
|
30
|
+
width?: string | number;
|
|
31
|
+
height?: string | number;
|
|
32
|
+
autoResize?: boolean;
|
|
33
|
+
minHeight?: string | number;
|
|
34
|
+
maxHeight?: string | number;
|
|
35
|
+
styleHref?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function mountIframe(
|
|
39
|
+
config: LuliChatConfig,
|
|
40
|
+
options?: IframeOptions
|
|
41
|
+
): MountResult & { iframe: HTMLIFrameElement };
|
|
42
|
+
|
|
43
|
+
export function unmountIframe(id: string): void;
|
|
44
|
+
|
|
45
|
+
export function initFromScript(script?: HTMLScriptElement): any;
|
|
46
|
+
|
|
47
|
+
export interface ContactInfo {
|
|
48
|
+
name?: string;
|
|
49
|
+
email?: string;
|
|
50
|
+
queueId?: string | number;
|
|
51
|
+
queueOptionId?: string | number;
|
|
52
|
+
guestId?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface Help {
|
|
56
|
+
id: number;
|
|
57
|
+
title: string;
|
|
58
|
+
description: string;
|
|
59
|
+
category: string;
|
|
60
|
+
video: string;
|
|
61
|
+
link: string;
|
|
62
|
+
type: string;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type Sender = "user" | "human-agent" | "system" | "ai-agent" | "auto-respond";
|
|
68
|
+
export type MessageStatus = "error" | "pending" | "delivered" | "seen" | "played" | "unknown";
|
|
69
|
+
|
|
70
|
+
export interface ChatMessage {
|
|
71
|
+
mediaUrl?: string | null;
|
|
72
|
+
id: string;
|
|
73
|
+
dataJson?: any;
|
|
74
|
+
ack: number;
|
|
75
|
+
read: boolean;
|
|
76
|
+
fromMe: boolean;
|
|
77
|
+
body: string;
|
|
78
|
+
mediaType?: string;
|
|
79
|
+
isDeleted?: boolean;
|
|
80
|
+
createdAt: string | Date;
|
|
81
|
+
quotedMsgId?: number | string | null;
|
|
82
|
+
queueId?: number;
|
|
83
|
+
isEdited?: boolean;
|
|
84
|
+
quotedMsg?: ChatMessage | null;
|
|
85
|
+
status: string;
|
|
86
|
+
sender: Sender;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface Ticket {
|
|
90
|
+
id: number;
|
|
91
|
+
status: string;
|
|
92
|
+
unreadMessages: null;
|
|
93
|
+
lastMessage: string;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
updatedAt: string;
|
|
96
|
+
companyId: string;
|
|
97
|
+
queueId: string;
|
|
98
|
+
contact: Contact;
|
|
99
|
+
queue: {
|
|
100
|
+
id: number;
|
|
101
|
+
name: string;
|
|
102
|
+
color: string;
|
|
103
|
+
};
|
|
104
|
+
ticketTracking: any;
|
|
105
|
+
tags: any[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface Contact {
|
|
109
|
+
id: number;
|
|
110
|
+
name: string;
|
|
111
|
+
number: string;
|
|
112
|
+
email: string;
|
|
113
|
+
chatId: string;
|
|
114
|
+
profilePicUrl: null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface Queue {
|
|
118
|
+
id: number;
|
|
119
|
+
name: string;
|
|
120
|
+
color: string;
|
|
121
|
+
greetingMessage: string;
|
|
122
|
+
outOfHoursMessage: string;
|
|
123
|
+
companyId: number;
|
|
124
|
+
createdAt: string;
|
|
125
|
+
updatedAt: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type ChatState = "closed" | "contact-form" | "chat" | "loading";
|
|
129
|
+
|
|
130
|
+
declare const LuliChat: React.FC<LuliChatConfig>;
|
|
131
|
+
export default LuliChat;
|