@hexabot-ai/widget 3.0.0-alpha.3
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/.prettierrc +4 -0
- package/README.md +166 -0
- package/dist/hexabot-widget.es.js +10509 -0
- package/dist/hexabot-widget.umd.js +31 -0
- package/dist/style.css +1 -0
- package/eslint.config-staged.cjs +10 -0
- package/eslint.config.cjs +148 -0
- package/package.json +64 -0
package/.prettierrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Hexabot Live Chat Widget
|
|
2
|
+
|
|
3
|
+
The [Hexabot](https://hexabot.ai/) Live Chat Widget is a React-based embeddable widget that allows users to integrate real-time chat functionality into their websites. It connects to the Hexabot API and facilitates seamless interaction between end-users and chatbots across multiple channels.
|
|
4
|
+
|
|
5
|
+
[Hexabot](https://hexabot.ai/) is a chatbot / agent solution that allows users to create and manage AI-powered, multi-channel, and multilingual chatbots with ease. If you would like to learn more, please visit the [official github repo](https://github.com/Hexastack/Hexabot/).
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **Real-Time Chat:** Engage in real-time conversations with users directly through your website.
|
|
10
|
+
- **Customizable:** Easily customize the widget's appearance and behavior to fit your brand and website.
|
|
11
|
+
- **Multi-Channel Support:** Integrates with multiple messaging platforms through the Hexabot API.
|
|
12
|
+
- **Embeddable:** Simple to embed and integrate into any web page with just a few lines of code.
|
|
13
|
+
|
|
14
|
+
## Directory Structure
|
|
15
|
+
|
|
16
|
+
The Hexabot Live Chat Widget is organized into the following directory structure, under `src` we have:
|
|
17
|
+
|
|
18
|
+
- **src/assets:** Static assets like icons, fonts, and images used in the widget.
|
|
19
|
+
- **src/components:** Reusable React components that make up the chat widget interface, such as message bubbles, input fields, and buttons.
|
|
20
|
+
- **src/constants:** Hard coded values that are used like colors.
|
|
21
|
+
- **src/hooks:** Custom React hooks for managing widget state and handling side effects like API calls or real-time events.
|
|
22
|
+
- **src/services:** Handles external services, such as communication with the Hexabot API or other third-party integrations.
|
|
23
|
+
- **src/styles:** Contains the styling for the widget, including CSS or SCSS files used to define the look and feel of the chat interface.
|
|
24
|
+
- **src/providers:** Context providers for managing global state, such as user session, chat messages, and widget configurations.
|
|
25
|
+
- **src/translations:** Contains transalation of a couple of strings.
|
|
26
|
+
- **src/types:** Defines the typescript interfaces, types, and enums used.
|
|
27
|
+
- **src/utils:** Utility functions and helpers used throughout the widget, such as formatting, validations, or data transformations.
|
|
28
|
+
|
|
29
|
+
- **/public:** Contains static files that are publicly accessible. This includes the main HTML template where the widget is embedded for local development.
|
|
30
|
+
|
|
31
|
+
## Run the Live Chat Widget
|
|
32
|
+
|
|
33
|
+
### Dev Mode
|
|
34
|
+
|
|
35
|
+
Start the widget dev server from the repository root:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm --filter @hexabot-ai/widget run dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The live chat widget will be accessible at http://localhost:5173.
|
|
42
|
+
|
|
43
|
+
### Build for Production
|
|
44
|
+
|
|
45
|
+
Compile the distributable bundle:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pnpm --filter @hexabot-ai/widget run build
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This will generate a production-ready build in the dist folder.
|
|
52
|
+
|
|
53
|
+
### Preview the Bundle
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm --filter @hexabot-ai/widget run preview
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The preview server is helpful for validating the compiled assets before publishing.
|
|
60
|
+
|
|
61
|
+
## Embed Chat Widget
|
|
62
|
+
|
|
63
|
+
Once the widget is built, you can easily embed it into any webpage. Here's an example of how to add it to your website:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
67
|
+
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
68
|
+
<link rel="stylesheet" href="./style.css">
|
|
69
|
+
<script src="<<WIDGET URL>>/hexabot-widget.umd.js"></script>
|
|
70
|
+
|
|
71
|
+
<div id="hb-chat-widget"></div>
|
|
72
|
+
<script>
|
|
73
|
+
const el = React.createElement;
|
|
74
|
+
const domContainer = document.getElementById('hb-chat-widget');
|
|
75
|
+
ReactDOM.render(
|
|
76
|
+
el(HexabotWidget, {
|
|
77
|
+
apiUrl: 'https://api.yourdomain.com',
|
|
78
|
+
channel: 'web-channel',
|
|
79
|
+
token: 'token123',
|
|
80
|
+
}),
|
|
81
|
+
domContainer,
|
|
82
|
+
);
|
|
83
|
+
</script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Replace the values in apiUrl and token with your configuration details.
|
|
87
|
+
|
|
88
|
+
To prevent the website css from conflicting with the chat widget css, we can leverage the shadow dom:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
|
|
92
|
+
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
93
|
+
<script src="<<WIDGET URL>>/hexabot-widget.umd.js"></script>
|
|
94
|
+
|
|
95
|
+
<div id="hb-chat-widget"></div>
|
|
96
|
+
<script>
|
|
97
|
+
// Create the shadow root and attach it to the widget container
|
|
98
|
+
const createElement = (tag, props = {}) => Object.assign(document.createElement(tag), props);
|
|
99
|
+
const shadowContainer = createElement("div");
|
|
100
|
+
document
|
|
101
|
+
.getElementById('hb-chat-widget')
|
|
102
|
+
.attachShadow({ mode: 'open' })
|
|
103
|
+
.append(
|
|
104
|
+
shadowContainer,
|
|
105
|
+
createElement("link", {
|
|
106
|
+
rel: "stylesheet",
|
|
107
|
+
href: "<<WIDGET URL>>/style.css"
|
|
108
|
+
});
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// Render the widget inside the shadow root
|
|
112
|
+
ReactDOM.render(
|
|
113
|
+
React.createElement(HexabotWidget, {
|
|
114
|
+
apiUrl: 'https://api.yourdomain.com',
|
|
115
|
+
channel: 'web-channel',
|
|
116
|
+
token: 'token123',
|
|
117
|
+
}),
|
|
118
|
+
shadowContainer,
|
|
119
|
+
);
|
|
120
|
+
</script>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
If you would like to use the official widget and benefit from updates automatically, you can consider using the CDN url:
|
|
124
|
+
`https://cdn.jsdelivr.net/npm/@hexabot-ai/widget@2.0.4/dist/`
|
|
125
|
+
|
|
126
|
+
or latest from the major version:
|
|
127
|
+
`https://cdn.jsdelivr.net/npm/@hexabot-ai/widget@2/dist/`
|
|
128
|
+
|
|
129
|
+
JsDelivr uses the package published in the npm registry: https://www.npmjs.com/package/@hexabot-ai/widget
|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
133
|
+
As a proof of concept we developed a Wordpress plugin to embed the chat widget in a Wordpress website : [https://github.com/hexastack/hexabot-wordpress-live-chat-widget](https://github.com/hexastack/hexabot-wordpress-live-chat-widget)
|
|
134
|
+
|
|
135
|
+
## Customization
|
|
136
|
+
|
|
137
|
+
You can customize the look and feel of the chat widget by modifying the widget’s scss styles or behavior. The widget allows you to:
|
|
138
|
+
|
|
139
|
+
- Change colors and fonts to match your website's branding.
|
|
140
|
+
- Configure user settings like language and chatbot response preferences.
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
We welcome contributions from the community! Whether you want to report a bug, suggest new features, or submit a pull request, your input is valuable to us.
|
|
145
|
+
|
|
146
|
+
Feel free to join us on [Discord](https://discord.gg/rNb9t2MFkG)
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
Copyright (c) 2025 Hexastack.
|
|
151
|
+
|
|
152
|
+
This project is licensed under the **Fair Core License, Version 1.0**, with **Apache License 2.0** as the future license (abbrev. **FCL-1.0-ALv2**).
|
|
153
|
+
|
|
154
|
+
**Change date.** For each version of the software, the Fair Core License converts to Apache-2.0 on the **second anniversary** of the date that version is made available.
|
|
155
|
+
|
|
156
|
+
**Commercial features & license keys.** Certain features of Hexabot are protected by license-key checks. You **must not** remove, modify, disable, or circumvent those checks, nor enable access to protected functionality without a valid license key.
|
|
157
|
+
|
|
158
|
+
**Competing uses (non-compete).** Use that competes with Hexastack’s business—for example, offering Hexabot (or a substantially similar service) as a hosted or commercial product—is not permitted until the conversion to Apache-2.0 for the applicable version.
|
|
159
|
+
|
|
160
|
+
**Redistribution.** If you distribute copies, modifications, or derivatives, you must include this license and not remove copyright or proprietary notices.
|
|
161
|
+
|
|
162
|
+
**Patents.** A limited patent license is granted for permitted uses and terminates on patent aggression.
|
|
163
|
+
|
|
164
|
+
**Trademarks.** “Hexabot” and “Hexastack” are trademarks. Except to identify Hexastack as the origin of the software, no trademark rights are granted.
|
|
165
|
+
|
|
166
|
+
**Disclaimer.** The software is provided “AS IS,” without warranties or conditions of any kind, and Hexastack will not be liable for any damages arising from its use.
|