obi-sdk 0.1.10 → 0.2.0
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 +46 -29
- package/dist/modular/chunks/{session-c3b70ffb.js → index-2d0b05af.js} +5409 -818
- package/dist/modular/chunks/index-2d0b05af.js.map +1 -0
- package/dist/modular/chunks/obi-widget-0970cbbe.js +2221 -0
- package/dist/modular/chunks/obi-widget-0970cbbe.js.map +1 -0
- package/dist/modular/core.js +3 -8
- package/dist/modular/core.js.map +1 -1
- package/dist/modular/index.js +20 -228
- package/dist/modular/index.js.map +1 -1
- package/dist/modular/ui.js +17 -16
- package/dist/modular/ui.js.map +1 -1
- package/dist/obi-sdk.es.js +21068 -7
- package/dist/obi-sdk.standalone.iife.js +60 -33
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/obi-sdk.umd.js +103 -76
- package/index.d.ts +10 -61
- package/package.json +4 -4
- package/dist/index-719ec57d.js +0 -5168
- package/dist/modular/chunks/mitt-3c1f932d.js +0 -20
- package/dist/modular/chunks/mitt-3c1f932d.js.map +0 -1
- package/dist/modular/chunks/obi-widget-ff350828.js +0 -6369
- package/dist/modular/chunks/obi-widget-ff350828.js.map +0 -1
- package/dist/modular/chunks/session-c3b70ffb.js.map +0 -1
- package/dist/session-730ff76c.js +0 -15762
package/README.md
CHANGED
|
@@ -9,16 +9,18 @@ A JavaScript SDK with dynamic content capabilities for integrating Obi into your
|
|
|
9
9
|
- Framework-agnostic UI components using Web Components
|
|
10
10
|
- Event-based API
|
|
11
11
|
- TypeScript support
|
|
12
|
+
- Session persistence across page reloads
|
|
12
13
|
|
|
13
14
|
## Configuration Options
|
|
14
15
|
|
|
15
16
|
The loader accepts the following configuration options:
|
|
16
17
|
|
|
17
|
-
| Option | Type
|
|
18
|
-
| ---------- |
|
|
19
|
-
| `position` | string
|
|
20
|
-
| `apiKey` | string
|
|
21
|
-
| `user` | object
|
|
18
|
+
| Option | Type | Default | Description |
|
|
19
|
+
| ---------- | ------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| `position` | string | `'bottom-right'` | Position of the widget on the page. Options: `'bottom-right'`, `'bottom-left'`, `'bottom-center'`, `'top-right'`, `'top-left'`, `'top-center'`, `'middle-left'`, `'middle-right'` |
|
|
21
|
+
| `apiKey` | string | - | Your Obi API key (required for production) |
|
|
22
|
+
| `user` | object | - | User information with `id` (required), `email` (optional) and `metadata` (optional) |
|
|
23
|
+
| `isActive` | boolean | `true` | Whether to show the widget. Set to `false` to disable the widget for specific users |
|
|
22
24
|
|
|
23
25
|
## Installation Options
|
|
24
26
|
|
|
@@ -32,29 +34,30 @@ The simplest way to add Obi to your website is by using the inline loader script
|
|
|
32
34
|
|
|
33
35
|
**Example HTML structure:**
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
<!DOCTYPE html>
|
|
38
|
+
<html>
|
|
39
|
+
<head>
|
|
40
|
+
<title>My Website with Obi</title>
|
|
41
|
+
<script>
|
|
42
|
+
// Configure Obi
|
|
43
|
+
window.obiWidgetConfig = {
|
|
44
|
+
position: "bottom-right",
|
|
45
|
+
apiKey: "YOUR_API_KEY",
|
|
46
|
+
isActive: true,
|
|
47
|
+
user: {
|
|
48
|
+
id: "user-123",
|
|
49
|
+
email: "user@example.com",
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
</
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</
|
|
57
|
-
</
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
</head>
|
|
54
|
+
<body>
|
|
55
|
+
<!-- Your website content -->
|
|
56
|
+
<script>
|
|
57
|
+
(()=>{var t,e,n=window,o=document,s=n.ObiSDK;"function"==typeof s||"object"==typeof s?s("update",n.obiWidgetConfig):((t=function(){t.q.push(arguments)}).q=[],n.ObiSDK=t,e=function(t){var e=o.createElement("script"),t=(e.type="text/javascript",e.async=!0,e.src="https://unpkg.com/obi-sdk@"+(t||"latest")+"/dist/obi-sdk.standalone.iife.js",o.getElementsByTagName("script")[0]);t.parentNode.insertBefore(e,t)},s=function(){try{var t=new XMLHttpRequest;t.open("GET","https://registry.npmjs.org/obi-sdk/latest"),t.onload=function(){if(200===t.status)try{e(JSON.parse(t.responseText).version)}catch(t){e()}else e()},t.onerror=function(){e()},t.send()}catch(t){e()}},"complete"===o.readyState?s():n.attachEvent?n.attachEvent("onload",s):n.addEventListener("load",s,!1))})();
|
|
58
|
+
</script>
|
|
59
|
+
</body>
|
|
60
|
+
</html>
|
|
58
61
|
|
|
59
62
|
The widget will automatically appear in the specified position on your page.
|
|
60
63
|
|
|
@@ -68,6 +71,7 @@ You can also include the loader directly from our CDN:
|
|
|
68
71
|
window.obiWidgetConfig = {
|
|
69
72
|
position: "bottom-right",
|
|
70
73
|
apiKey: "YOUR_API_KEY",
|
|
74
|
+
isActive: true,
|
|
71
75
|
}
|
|
72
76
|
</script>
|
|
73
77
|
|
|
@@ -77,15 +81,28 @@ You can also include the loader directly from our CDN:
|
|
|
77
81
|
|
|
78
82
|
## Widget Positioning
|
|
79
83
|
|
|
80
|
-
The widget can be positioned in one of
|
|
84
|
+
The widget can be positioned in one of eight positions on the page:
|
|
81
85
|
|
|
82
86
|
```js
|
|
83
87
|
window.obiWidgetConfig = {
|
|
84
|
-
position: "bottom-right", // Options: "bottom-right", "bottom-left", "top-right", "top-left"
|
|
88
|
+
position: "bottom-right", // Options: "bottom-right", "bottom-left", "bottom-center", "top-right", "top-left", "top-center", "middle-left", "middle-right"
|
|
85
89
|
apiKey: "YOUR_API_KEY",
|
|
86
90
|
}
|
|
87
91
|
```
|
|
88
92
|
|
|
93
|
+
## Session Persistence
|
|
94
|
+
|
|
95
|
+
The SDK now supports session persistence across page reloads and navigation. If a user refreshes the page or navigates to another page on your site, the session with Obi will be automatically restored when they return, providing a seamless experience.
|
|
96
|
+
|
|
97
|
+
Key features of session persistence:
|
|
98
|
+
|
|
99
|
+
- Sessions are stored locally in the browser using a namespaced localStorage implementation
|
|
100
|
+
- Session data is automatically cleared after a configurable expiration time (default: 5 minutes)
|
|
101
|
+
- When reconnecting, the previous session state is restored, including the current conversation
|
|
102
|
+
- Users can manually end a session at any time by using the disconnect option
|
|
103
|
+
|
|
104
|
+
No additional configuration is required to enable this feature.
|
|
105
|
+
|
|
89
106
|
## License
|
|
90
107
|
|
|
91
108
|
SEE LICENSE IN LICENSE.txt
|