@verba-ai/chat-sdk 1.0.3 → 1.0.5
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 +66 -53
- package/dist/chat-sdk.es.js +1 -1
- package/dist/chat-sdk.es.js.map +1 -1
- package/dist/chat-sdk.umd.cjs +1 -1
- package/dist/chat-sdk.umd.cjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,41 +4,37 @@ A lightweight, TypeScript SDK for embedding the Verba AI chat widget into any we
|
|
|
4
4
|
|
|
5
5
|
The SDK acts as a secure, high-performance orchestration layer that manages the injection and lifecycle of the Verba chat `iframe`. It supports both floating and inline mounting strategies.
|
|
6
6
|
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Install via your preferred package manager:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @verba-ai/chat-sdk
|
|
13
|
-
# or
|
|
14
|
-
yarn add @verba-ai/chat-sdk
|
|
15
|
-
# or
|
|
16
|
-
pnpm add @verba-ai/chat-sdk
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
7
|
## Usage
|
|
22
8
|
|
|
23
9
|
### 1. Floating Bubble (Default)
|
|
10
|
+
|
|
24
11
|
The easiest way to integrate the chat. It creates a fixed-position action button in the bottom corner of your screen that toggles the chat window.
|
|
25
12
|
|
|
26
13
|
```typescript
|
|
27
|
-
import { ChatSDK } from
|
|
14
|
+
import { ChatSDK } from "@verba-ai/chat-sdk";
|
|
28
15
|
|
|
29
16
|
const chat = new ChatSDK({
|
|
30
17
|
// Required: Your unique Verba tenant ID
|
|
31
|
-
tenant:
|
|
32
|
-
|
|
33
|
-
// Optional
|
|
34
|
-
theme:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
tenant: "your-tenant-id",
|
|
19
|
+
|
|
20
|
+
// Optional
|
|
21
|
+
theme: {
|
|
22
|
+
primaryColor: "#6366f1",
|
|
23
|
+
backgroundColor: "#080b14",
|
|
24
|
+
textColor: "#f1f5f9",
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// Optional: Configuration for the floating bubble
|
|
28
|
+
bubble: {
|
|
29
|
+
position: "bottom-right",
|
|
30
|
+
color: "#8b5cf6", // custom background gradient/color
|
|
31
|
+
size: 56, // size in pixels
|
|
32
|
+
icon: "<link>", // src to <img> tag
|
|
33
|
+
},
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
// Inject the bubble into the DOM
|
|
41
|
-
chat.init();
|
|
37
|
+
chat.init();
|
|
42
38
|
|
|
43
39
|
// Optional programmatic controls
|
|
44
40
|
// chat.show();
|
|
@@ -47,47 +43,48 @@ chat.init();
|
|
|
47
43
|
```
|
|
48
44
|
|
|
49
45
|
### 2. Inline Mounting
|
|
46
|
+
|
|
50
47
|
If you want to render the chat inside a specific part of your page (like a dashboard panel or a dedicated contact page).
|
|
51
48
|
|
|
52
49
|
```typescript
|
|
53
|
-
import { ChatSDK } from
|
|
50
|
+
import { ChatSDK } from "@verba-ai/chat-sdk";
|
|
54
51
|
|
|
55
52
|
// Ensure the container exists in your DOM
|
|
56
53
|
// <div id="my-chat-container" style="height: 600px;"></div>
|
|
57
54
|
|
|
58
55
|
const chat = new ChatSDK({
|
|
59
|
-
tenant:
|
|
60
|
-
|
|
56
|
+
tenant: "your-tenant-id",
|
|
57
|
+
|
|
61
58
|
// Target a CSS selector or pass an HTMLElement directly
|
|
62
|
-
container:
|
|
63
|
-
|
|
59
|
+
container: "#my-chat-container",
|
|
60
|
+
|
|
64
61
|
// Optional: Advanced visual theming
|
|
65
62
|
theme: {
|
|
66
|
-
primaryColor:
|
|
67
|
-
backgroundColor:
|
|
68
|
-
textColor:
|
|
69
|
-
|
|
70
|
-
}
|
|
63
|
+
primaryColor: "#6366f1",
|
|
64
|
+
backgroundColor: "#080b14",
|
|
65
|
+
textColor: "#f1f5f9",
|
|
66
|
+
},
|
|
71
67
|
});
|
|
72
68
|
|
|
73
69
|
chat.init();
|
|
74
70
|
```
|
|
75
71
|
|
|
76
72
|
### 3. Usage via CDN (UMD)
|
|
73
|
+
|
|
77
74
|
If you aren't using a bundler (Webpack/Vite/Rollup), you can load the SDK directly via a script tag.
|
|
78
75
|
|
|
79
76
|
```html
|
|
80
77
|
<script src="https://unpkg.com/@verba-ai/chat-sdk@latest/dist/chat-sdk.umd.cjs"></script>
|
|
81
78
|
<script>
|
|
82
79
|
const { ChatSDK } = window.VerbaChatSDK;
|
|
83
|
-
|
|
84
|
-
new ChatSDK({ tenant:
|
|
80
|
+
|
|
81
|
+
new ChatSDK({ tenant: "your-tenant-id" }).init();
|
|
85
82
|
</script>
|
|
86
83
|
```
|
|
87
84
|
|
|
88
85
|
---
|
|
89
86
|
|
|
90
|
-
##
|
|
87
|
+
## API Reference
|
|
91
88
|
|
|
92
89
|
### `ChatSDK` Class
|
|
93
90
|
|
|
@@ -95,12 +92,12 @@ The main entry point for the widget.
|
|
|
95
92
|
|
|
96
93
|
#### Methods
|
|
97
94
|
|
|
98
|
-
| Method
|
|
99
|
-
|
|
|
100
|
-
| `init()`
|
|
101
|
-
| `show()`
|
|
102
|
-
| `hide()`
|
|
103
|
-
| `destroy()
|
|
95
|
+
| Method | Description |
|
|
96
|
+
| :---------- | :------------------------------------------------------------------------------------- |
|
|
97
|
+
| `init()` | Injects the CSS and iframe into the DOM. |
|
|
98
|
+
| `show()` | Makes the widget visible (animates the iframe open in floating mode). |
|
|
99
|
+
| `hide()` | Hides the widget (animates the iframe closed in floating mode). |
|
|
100
|
+
| `destroy()` | Completely tears down the SDK, removing all injected DOM elements, styles, and events. |
|
|
104
101
|
|
|
105
102
|
---
|
|
106
103
|
|
|
@@ -112,18 +109,36 @@ The main entry point for the widget.
|
|
|
112
109
|
interface ChatSDKConfig {
|
|
113
110
|
/** Your Verba tenant ID (Required) */
|
|
114
111
|
tenant: string;
|
|
115
|
-
|
|
112
|
+
|
|
116
113
|
/** Where to mount the widget. Omit for floating bubble. */
|
|
117
114
|
container?: string | HTMLElement;
|
|
118
|
-
|
|
115
|
+
|
|
119
116
|
/** Visual theme. String preset or detailed config. */
|
|
120
|
-
theme?:
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
theme?: "light" | "dark" | ThemeConfig;
|
|
118
|
+
|
|
119
|
+
/** Configuration for the floating bubble. */
|
|
120
|
+
bubble?: ChatBubbleConfig;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### `ChatBubbleConfig`
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
interface ChatBubbleConfig {
|
|
128
|
+
/** Corner position of the floating bubble (Default: 'bottom-right') */
|
|
129
|
+
position?: "bottom-right" | "bottom-left";
|
|
130
|
+
|
|
131
|
+
/** Background color of the bubble (Default: '#ffffff') */
|
|
132
|
+
color?: string;
|
|
133
|
+
|
|
134
|
+
/** Size of the bubble in pixels (Default: 56) */
|
|
135
|
+
size?: number;
|
|
136
|
+
|
|
137
|
+
/** SVG string for a custom open (chat) icon */
|
|
138
|
+
icon?: string;
|
|
139
|
+
|
|
140
|
+
/** Color of the close (X) icon (Default: '#ffffff') */
|
|
141
|
+
closeIconColor?: string;
|
|
127
142
|
}
|
|
128
143
|
```
|
|
129
144
|
|
|
@@ -135,7 +150,5 @@ interface ThemeConfig {
|
|
|
135
150
|
textColor?: string;
|
|
136
151
|
backgroundColor?: string;
|
|
137
152
|
fontFamily?: string;
|
|
138
|
-
borderRadius?: string | number;
|
|
139
153
|
}
|
|
140
154
|
```
|
|
141
|
-
|
package/dist/chat-sdk.es.js
CHANGED
|
@@ -3187,7 +3187,7 @@ class Aa {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
buildWidgetUrl() {
|
|
3189
3189
|
const t = new URL(wa);
|
|
3190
|
-
if (t.searchParams.set("
|
|
3190
|
+
if (t.searchParams.set("tag-id", this.config.tenant), t.searchParams.set("sdk-version", "1.0.5"), typeof this.config.theme == "object") {
|
|
3191
3191
|
const n = this.config.theme;
|
|
3192
3192
|
n.primaryColor && t.searchParams.set("color", n.primaryColor), n.textColor && t.searchParams.set("textColor", n.textColor), n.backgroundColor && t.searchParams.set("backgroundColor", n.backgroundColor), n.fontFamily && t.searchParams.set("fontFamily", n.fontFamily);
|
|
3193
3193
|
} else
|