tia-chatbot 1.2.5 → 1.2.7
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 +29 -76
- package/dist/tia-widget.iife.js +187 -36
- package/dist/tia-widget.iife.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,103 +18,66 @@ npm install tia-widget
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### Prerequisites (CDN)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Since the widget is built as a library interacting with React, you **must** include React and ReactDOM before the widget script.
|
|
24
24
|
|
|
25
25
|
```html
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<head>
|
|
29
|
-
<title>My Website</title>
|
|
30
|
-
<!-- Include React and ReactDOM for the widget -->
|
|
31
|
-
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
32
|
-
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
33
|
-
</head>
|
|
34
|
-
<body>
|
|
35
|
-
<!-- Your website content -->
|
|
36
|
-
|
|
37
|
-
<!-- TIA Widget Script -->
|
|
38
|
-
<script
|
|
39
|
-
src="https://unpkg.com/tia-widget@latest/dist/tia-widget.iife.js"
|
|
40
|
-
data-auto-init
|
|
41
|
-
data-api-url="https://your-api-endpoint.com"
|
|
42
|
-
data-container-id="custom-widget-container">
|
|
43
|
-
</script>
|
|
44
|
-
</body>
|
|
45
|
-
</html>
|
|
26
|
+
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
27
|
+
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
46
28
|
```
|
|
47
29
|
|
|
48
|
-
###
|
|
30
|
+
### Initialization
|
|
31
|
+
|
|
32
|
+
Use the `mountChainlitWidget` function to initialize the widget with your configuration.
|
|
49
33
|
|
|
50
34
|
```html
|
|
51
35
|
<!DOCTYPE html>
|
|
52
36
|
<html>
|
|
53
37
|
<head>
|
|
54
38
|
<title>My Website</title>
|
|
55
|
-
<!-- Include React and ReactDOM -->
|
|
56
39
|
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
57
40
|
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
58
41
|
</head>
|
|
59
42
|
<body>
|
|
60
|
-
<!-- Your website content -->
|
|
61
|
-
<div id="my-widget"></div>
|
|
62
|
-
|
|
63
43
|
<!-- TIA Widget Script -->
|
|
64
44
|
<script src="https://unpkg.com/tia-widget@latest/dist/tia-widget.iife.js"></script>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
window.mountChainlitWidget({
|
|
48
|
+
chainlitServer: "https://v2.tia.ascenthr.ai", // Your Chainlit Server URL
|
|
49
|
+
accessToken: "<access-token>", // Your Access Token
|
|
50
|
+
theme: "light", // Optional: Theme
|
|
51
|
+
customCssUrl: "https://example.com/style.css", // Optional: Custom CSS URL
|
|
52
|
+
button: { // Optional: Custom Button Config
|
|
53
|
+
imageUrl: "https://example.com/logo.png",
|
|
54
|
+
className: "p-0"
|
|
72
55
|
}
|
|
73
56
|
});
|
|
74
|
-
|
|
75
|
-
// Optional: Unmount the widget later
|
|
76
|
-
// widget.unmount();
|
|
77
57
|
</script>
|
|
78
58
|
</body>
|
|
79
59
|
</html>
|
|
80
60
|
```
|
|
81
61
|
|
|
82
|
-
###
|
|
62
|
+
### Backward Compatibility (Old Method)
|
|
83
63
|
|
|
84
|
-
|
|
85
|
-
import { initTIAWidget } from 'tia-widget';
|
|
86
|
-
|
|
87
|
-
// Initialize the widget
|
|
88
|
-
const widget = initTIAWidget({
|
|
89
|
-
apiUrl: 'https://your-api-endpoint.com',
|
|
90
|
-
containerId: 'my-widget',
|
|
91
|
-
onError: (error) => {
|
|
92
|
-
console.error('Widget error:', error);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Later, unmount if needed
|
|
97
|
-
widget.unmount();
|
|
98
|
-
```
|
|
64
|
+
The previous initialization methods (`window.TIAWidget.init` and data attributes) still work.
|
|
99
65
|
|
|
100
66
|
## Configuration Options
|
|
101
67
|
|
|
102
68
|
| Option | Type | Default | Description |
|
|
103
69
|
|--------|------|---------|-------------|
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- `data-auto-init`: Enables automatic initialization
|
|
111
|
-
- `data-api-url`: Sets the API URL
|
|
112
|
-
- `data-container-id`: Sets the container element ID
|
|
70
|
+
| `chainlitServer` | `string` | `https://v2.tia.ascenthr.ai` | The API endpoint URL for the chatbot. |
|
|
71
|
+
| `accessToken` | `string` | `undefined` | The Bearer token for authentication. |
|
|
72
|
+
| `serverUrl` | `string` | `undefined` | Alias for `chainlitServer`. |
|
|
73
|
+
| `token` | `string` | `undefined` | Alias for `accessToken`. |
|
|
74
|
+
| `containerId` | `string` | `'tia-widget-root'` | The ID of the DOM element where the widget will be mounted. |
|
|
75
|
+
| `onError` | `function` | `console.error` | Error handler function. |
|
|
113
76
|
|
|
114
77
|
## Publishing to NPM
|
|
115
78
|
|
|
116
79
|
```bash
|
|
117
|
-
npm run build
|
|
80
|
+
npm run build
|
|
118
81
|
npm publish
|
|
119
82
|
```
|
|
120
83
|
|
|
@@ -122,25 +85,15 @@ npm publish
|
|
|
122
85
|
|
|
123
86
|
```bash
|
|
124
87
|
# Install dependencies
|
|
125
|
-
|
|
88
|
+
npm install
|
|
126
89
|
|
|
127
90
|
# Start development server
|
|
128
|
-
|
|
91
|
+
npm run dev
|
|
129
92
|
|
|
130
93
|
# Build for production
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
# Build for CDN
|
|
134
|
-
pnpm run build:cdn
|
|
94
|
+
npm run build
|
|
135
95
|
```
|
|
136
96
|
|
|
137
|
-
## Requirements
|
|
138
|
-
|
|
139
|
-
- React 18+
|
|
140
|
-
- React DOM 18+
|
|
141
|
-
|
|
142
|
-
The widget bundles React and other dependencies, but for CDN usage, you need to include React and ReactDOM scripts separately.
|
|
143
|
-
|
|
144
97
|
## License
|
|
145
98
|
|
|
146
99
|
MIT
|