@robylon/web-react-sdk 1.1.28-staging.7 → 1.1.30-staging.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 +211 -37
- package/dist/cjs/index.js +1 -5534
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/config.d.ts +1 -1
- package/dist/cjs/types/core/api.d.ts +6 -54
- package/dist/cjs/types/core/config.d.ts +34 -0
- package/dist/cjs/types/core/events.d.ts +22 -0
- package/dist/cjs/types/core/index.d.ts +4 -0
- package/dist/cjs/types/core/state.d.ts +33 -0
- package/dist/cjs/types/index.d.ts +4 -9
- package/dist/cjs/types/types.d.ts +4 -9
- package/dist/cjs/types/vanilla/components/ChatbotFloatingButton.d.ts +46 -0
- package/dist/cjs/types/vanilla/components/ChatbotIframe.d.ts +66 -0
- package/dist/cjs/types/vanilla/index.d.ts +38 -25
- package/dist/esm/index.js +1 -5527
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/config.d.ts +1 -1
- package/dist/esm/types/core/api.d.ts +6 -54
- package/dist/esm/types/core/config.d.ts +34 -0
- package/dist/esm/types/core/events.d.ts +22 -0
- package/dist/esm/types/core/index.d.ts +4 -0
- package/dist/esm/types/core/state.d.ts +33 -0
- package/dist/esm/types/index.d.ts +4 -9
- package/dist/esm/types/types.d.ts +4 -9
- package/dist/esm/types/vanilla/components/ChatbotFloatingButton.d.ts +46 -0
- package/dist/esm/types/vanilla/components/ChatbotIframe.d.ts +66 -0
- package/dist/esm/types/vanilla/index.d.ts +38 -25
- package/dist/index.d.ts +90 -68
- package/dist/umd/robylon-chatbot.js +2 -0
- package/dist/umd/robylon-chatbot.js.map +1 -0
- package/dist/umd/types/config.d.ts +1 -1
- package/dist/umd/types/core/api.d.ts +6 -54
- package/dist/umd/types/core/config.d.ts +34 -0
- package/dist/umd/types/core/events.d.ts +22 -0
- package/dist/umd/types/core/index.d.ts +4 -0
- package/dist/umd/types/core/state.d.ts +33 -0
- package/dist/umd/types/index.d.ts +4 -9
- package/dist/umd/types/types.d.ts +4 -9
- package/dist/umd/types/vanilla/components/ChatbotFloatingButton.d.ts +46 -0
- package/dist/umd/types/vanilla/components/ChatbotIframe.d.ts +66 -0
- package/dist/umd/types/vanilla/index.d.ts +38 -25
- package/package.json +17 -81
- package/dist/cjs/legacy.js +0 -2
- package/dist/cjs/legacy.js.map +0 -1
- package/dist/cjs/react.js +0 -2
- package/dist/cjs/react.js.map +0 -1
- package/dist/cjs/types/core/chatbotEmbed.d.ts +0 -59
- package/dist/cjs/types/core/utils/color.d.ts +0 -1
- package/dist/cjs/types/core/utils/cookies.d.ts +0 -30
- package/dist/cjs/types/core/utils/environment.d.ts +0 -19
- package/dist/cjs/types/core/utils/logger.d.ts +0 -37
- package/dist/cjs/types/core/utils/system.d.ts +0 -22
- package/dist/cjs/types/index.legacy.d.ts +0 -7
- package/dist/cjs/types/index.react.d.ts +0 -9
- package/dist/cjs/types/index.vanilla.d.ts +0 -32
- package/dist/cjs/types/react/components/Chatbot.d.ts +0 -34
- package/dist/cjs/types/react/components/ErrorBoundary.d.ts +0 -18
- package/dist/esm/legacy.js +0 -2
- package/dist/esm/legacy.js.map +0 -1
- package/dist/esm/react.js +0 -2
- package/dist/esm/react.js.map +0 -1
- package/dist/esm/types/core/chatbotEmbed.d.ts +0 -59
- package/dist/esm/types/core/utils/color.d.ts +0 -1
- package/dist/esm/types/core/utils/cookies.d.ts +0 -30
- package/dist/esm/types/core/utils/environment.d.ts +0 -19
- package/dist/esm/types/core/utils/logger.d.ts +0 -37
- package/dist/esm/types/core/utils/system.d.ts +0 -22
- package/dist/esm/types/index.legacy.d.ts +0 -7
- package/dist/esm/types/index.react.d.ts +0 -9
- package/dist/esm/types/index.vanilla.d.ts +0 -32
- package/dist/esm/types/react/components/Chatbot.d.ts +0 -34
- package/dist/esm/types/react/components/ErrorBoundary.d.ts +0 -18
- package/dist/legacy.d.ts +0 -160
- package/dist/react.d.ts +0 -49
- package/dist/umd/robylon.js +0 -5545
- package/dist/umd/robylon.js.map +0 -1
- package/dist/umd/robylon.min.js +0 -20
- package/dist/umd/robylon.min.js.map +0 -1
- package/dist/umd/types/core/chatbotEmbed.d.ts +0 -59
- package/dist/umd/types/core/utils/color.d.ts +0 -1
- package/dist/umd/types/core/utils/cookies.d.ts +0 -30
- package/dist/umd/types/core/utils/environment.d.ts +0 -19
- package/dist/umd/types/core/utils/logger.d.ts +0 -37
- package/dist/umd/types/core/utils/system.d.ts +0 -22
- package/dist/umd/types/index.legacy.d.ts +0 -7
- package/dist/umd/types/index.react.d.ts +0 -9
- package/dist/umd/types/index.vanilla.d.ts +0 -32
- package/dist/umd/types/react/components/Chatbot.d.ts +0 -34
- package/dist/umd/types/react/components/ErrorBoundary.d.ts +0 -18
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Robylon SDK
|
|
1
|
+
# Robylon Web React SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight SDK for integrating Robylon's AI-powered chatbot into your web applications. Available for both React and vanilla JavaScript.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,64 +8,238 @@ The Robylon SDK provides chatbot functionality that can be used in both React an
|
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install @robylon/web-react-sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @robylon/web-react-sdk
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
### Vanilla JavaScript
|
|
14
16
|
|
|
15
17
|
```html
|
|
16
|
-
<script src="https://
|
|
18
|
+
<script src="https://unpkg.com/@robylon/web-react-sdk/dist/umd/robylon-chatbot.js"></script>
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @robylon/web-react-sdk
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
21
|
+
## Quick Start
|
|
26
22
|
|
|
27
23
|
### React
|
|
28
24
|
|
|
29
25
|
```jsx
|
|
30
|
-
import { Chatbot } from
|
|
26
|
+
import { Chatbot } from "@robylon/web-react-sdk";
|
|
31
27
|
|
|
32
28
|
function App() {
|
|
29
|
+
const handleChatbotEvent = (event) => {
|
|
30
|
+
logger.log(`Chatbot event: ${event.type}`, event);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
33
|
return (
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
<Chatbot
|
|
35
|
+
api_key="your-api-key"
|
|
36
|
+
user_id="user-id"
|
|
37
|
+
user_token="optional-auth-token"
|
|
38
|
+
user_profile={{
|
|
39
|
+
email: "user@example.com",
|
|
40
|
+
name: "John Doe",
|
|
41
|
+
mobile: "1234567890",
|
|
42
|
+
}}
|
|
43
|
+
onEvent={handleChatbotEvent}
|
|
44
|
+
/>
|
|
41
45
|
);
|
|
42
46
|
}
|
|
43
47
|
```
|
|
44
48
|
|
|
45
49
|
### Vanilla JavaScript
|
|
46
50
|
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
```html
|
|
52
|
+
<!-- Include the SDK -->
|
|
53
|
+
<script src="https://unpkg.com/@robylon/web-react-sdk/dist/umd/robylon-chatbot.js"></script>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
// Initialize the chatbot
|
|
57
|
+
const chatbot = new RobylonChatbot.RobylonChatbot({
|
|
58
|
+
api_key: "your-api-key",
|
|
59
|
+
user_id: "optional-user-id", // Optional
|
|
60
|
+
user_token: "optional-token", // Optional
|
|
61
|
+
user_profile: {
|
|
62
|
+
// Optional
|
|
63
|
+
name: "John Doe",
|
|
64
|
+
email: "user@example.com",
|
|
65
|
+
mobile: "1234567890",
|
|
66
|
+
},
|
|
67
|
+
onEvent: function (event) {
|
|
68
|
+
// Handle events
|
|
69
|
+
console.log("Event:", event);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Control methods
|
|
74
|
+
// chatbot.show(); // Show the chatbot
|
|
75
|
+
// chatbot.hide(); // Hide the chatbot
|
|
76
|
+
// chatbot.toggle(); // Toggle visibility
|
|
77
|
+
// chatbot.destroy(); // Remove the chatbot
|
|
78
|
+
</script>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
### Required Props
|
|
84
|
+
|
|
85
|
+
- `api_key`: Your Robylon API key
|
|
86
|
+
- `user_id`: Unique identifier for the current user
|
|
87
|
+
|
|
88
|
+
### Optional Props
|
|
89
|
+
|
|
90
|
+
- `user_token`: Authentication token for the user
|
|
91
|
+
- `user_profile`: Object containing user information
|
|
92
|
+
- `email`: User's email address
|
|
93
|
+
- `name`: User's name
|
|
94
|
+
- `mobile`: User's mobile number
|
|
95
|
+
- `onEvent`: Callback function to handle chatbot events
|
|
96
|
+
|
|
97
|
+
### Event Handling
|
|
98
|
+
|
|
99
|
+
The SDK emits various events that you can listen to using the `onEvent` prop. Each event has the following structure:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
interface ChatbotEvent {
|
|
103
|
+
type: ChatbotEventType;
|
|
104
|
+
timestamp: number;
|
|
105
|
+
data?: any;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Available event types:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
enum ChatbotEventType {
|
|
113
|
+
CHATBOT_BUTTON_LOADED = "CHATBOT_BUTTON_LOADED", // When the chat button is rendered
|
|
114
|
+
CHATBOT_OPENED = "CHATBOT_OPENED", // When chat window is opened
|
|
115
|
+
CHATBOT_CLOSED = "CHATBOT_CLOSED", // When chat window is closed
|
|
116
|
+
CHATBOT_APP_READY = "CHATBOT_APP_READY", // When SDK is fully initialized
|
|
117
|
+
CHATBOT_LOADED = "CHATBOT_LOADED", // When chatbot iframe is loaded
|
|
118
|
+
CHAT_INITIALIZED = "CHAT_INITIALIZED", // When chat session is initialized
|
|
119
|
+
SESSION_REFRESHED = "SESSION_REFRESHED", // When chat session is refreshed
|
|
120
|
+
CHAT_INITIALIZATION_FAILED = "CHAT_INITIALIZATION_FAILED", // When initialization fails
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Example usage:
|
|
125
|
+
|
|
126
|
+
```jsx
|
|
127
|
+
function App() {
|
|
128
|
+
const handleChatbotEvent = (event) => {
|
|
129
|
+
switch (event.type) {
|
|
130
|
+
case "CHATBOT_BUTTON_CLICKED":
|
|
131
|
+
logger.log("Chat button clicked at:", new Date(event.timestamp));
|
|
132
|
+
break;
|
|
133
|
+
case "CHATBOT_OPENED":
|
|
134
|
+
logger.log("Chat window opened at:", new Date(event.timestamp));
|
|
135
|
+
break;
|
|
136
|
+
case "CHAT_INITIALIZED":
|
|
137
|
+
logger.log("Chat session initialized");
|
|
138
|
+
break;
|
|
139
|
+
case "CHAT_INITIALIZATION_FAILED":
|
|
140
|
+
console.error("Chat initialization failed:", event.data);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Chatbot
|
|
147
|
+
api_key="your-api-key"
|
|
148
|
+
user_id="user-id"
|
|
149
|
+
onEvent={handleChatbotEvent}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Automatically Included Information
|
|
156
|
+
|
|
157
|
+
The SDK automatically collects and includes the following system information:
|
|
158
|
+
|
|
159
|
+
- `platform`: Always set to "web"
|
|
160
|
+
- `os`: User's operating system
|
|
161
|
+
- `browser`: User's browser type
|
|
162
|
+
- `device`: Device type (desktop/mobile/tablet)
|
|
163
|
+
- `screen_size`: User's screen dimensions (width and height)
|
|
164
|
+
- `sdk_version`: Current version of the SDK
|
|
165
|
+
|
|
166
|
+
## Features
|
|
167
|
+
|
|
168
|
+
- Persistent chat interface
|
|
169
|
+
- Responsive design for all screen sizes
|
|
170
|
+
- Automatic system information collection
|
|
171
|
+
- Customizable chat bubble
|
|
172
|
+
- Session management
|
|
173
|
+
- Secure communication channel
|
|
174
|
+
- Cross-browser compatibility
|
|
175
|
+
- Comprehensive event system
|
|
176
|
+
|
|
177
|
+
## Browser Support
|
|
178
|
+
|
|
179
|
+
The SDK supports all modern browsers and includes fallbacks for:
|
|
180
|
+
|
|
181
|
+
- User agent detection
|
|
182
|
+
- Screen size detection
|
|
183
|
+
- Browser identification
|
|
184
|
+
- Device type detection
|
|
185
|
+
|
|
186
|
+
## Development
|
|
187
|
+
|
|
188
|
+
### Creating Branches
|
|
57
189
|
|
|
58
|
-
|
|
59
|
-
import { create } from '@robylon/web-react-sdk';
|
|
190
|
+
Always use the provided script to create new branches:
|
|
60
191
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
192
|
+
```bash
|
|
193
|
+
npm run branch
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
This ensures proper version control and naming conventions.
|
|
197
|
+
|
|
198
|
+
## Vanilla JavaScript API
|
|
199
|
+
|
|
200
|
+
The vanilla JavaScript version provides a simple API for controlling the chatbot:
|
|
201
|
+
|
|
202
|
+
### Initialization
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
const chatbot = new RobylonChatbot.RobylonChatbot({
|
|
206
|
+
api_key: "your-api-key",
|
|
207
|
+
user_id: "optional-user-id",
|
|
208
|
+
user_token: "optional-token",
|
|
209
|
+
user_profile: {
|
|
210
|
+
name: "John Doe",
|
|
211
|
+
email: "user@example.com",
|
|
212
|
+
},
|
|
213
|
+
onEvent: function (event) {
|
|
214
|
+
console.log("Event:", event);
|
|
215
|
+
},
|
|
66
216
|
});
|
|
67
217
|
```
|
|
68
218
|
|
|
69
|
-
|
|
219
|
+
### Methods
|
|
220
|
+
|
|
221
|
+
- `chatbot.show()` - Shows the chatbot
|
|
222
|
+
- `chatbot.hide()` - Hides the chatbot
|
|
223
|
+
- `chatbot.toggle()` - Toggles the chatbot visibility
|
|
224
|
+
- `chatbot.destroy()` - Removes the chatbot from the DOM
|
|
225
|
+
|
|
226
|
+
### Event Handling
|
|
227
|
+
|
|
228
|
+
Event handling works the same way as in the React version:
|
|
70
229
|
|
|
71
|
-
|
|
230
|
+
```javascript
|
|
231
|
+
const chatbot = new RobylonChatbot.RobylonChatbot({
|
|
232
|
+
api_key: "your-api-key",
|
|
233
|
+
onEvent: function (event) {
|
|
234
|
+
switch (event.type) {
|
|
235
|
+
case "CHATBOT_BUTTON_CLICKED":
|
|
236
|
+
console.log("Chat button clicked at:", new Date(event.timestamp));
|
|
237
|
+
break;
|
|
238
|
+
case "CHATBOT_OPENED":
|
|
239
|
+
console.log("Chat window opened at:", new Date(event.timestamp));
|
|
240
|
+
break;
|
|
241
|
+
// Handle other events...
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
```
|