tia-chatbot 1.2.4 → 1.2.6

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
@@ -18,103 +18,66 @@ npm install tia-widget
18
18
 
19
19
  ## Usage
20
20
 
21
- ### Automatic Initialization (CDN)
21
+ ### Prerequisites (CDN)
22
22
 
23
- Add the script tag with data attributes for auto-initialization:
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
- <!DOCTYPE html>
27
- <html>
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
- ### Manual Initialization
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
- <script>
66
- // Initialize the widget manually
67
- const widget = window.TIAWidget.init({
68
- apiUrl: 'https://your-api-endpoint.com',
69
- containerId: 'my-widget',
70
- onError: (error) => {
71
- console.error('TIA Widget Error:', error);
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
- ### Programmatic Usage (NPM)
62
+ ### Backward Compatibility (Old Method)
83
63
 
84
- ```javascript
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
- | `apiUrl` | `string` | `window.origin + routerBasename` | The API endpoint URL for the TIA chatbot |
105
- | `containerId` | `string` | `'tia-widget-root'` | The ID of the DOM element where the widget will be mounted |
106
- | `onError` | `function` | `console.error` | Error handler function |
107
-
108
- ## Data Attributes (for CDN auto-init)
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:cdn
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
- pnpm install
88
+ npm install
126
89
 
127
90
  # Start development server
128
- pnpm run dev
91
+ npm run dev
129
92
 
130
93
  # Build for production
131
- pnpm run build
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