@robylon/web-react-sdk 1.1.35-staging.0 → 1.1.36-staging.4

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.
Files changed (73) hide show
  1. package/README.md +603 -97
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/components/ChatbotContainer/ChatbotContainer.d.ts +10 -0
  5. package/dist/cjs/types/components/ChatbotContainer/index.d.ts +1 -0
  6. package/dist/cjs/types/core/api.d.ts +8 -0
  7. package/dist/cjs/types/core/config.d.ts +34 -0
  8. package/dist/cjs/types/core/events.d.ts +22 -0
  9. package/dist/cjs/types/core/index.d.ts +4 -0
  10. package/dist/cjs/types/core/state.d.ts +34 -0
  11. package/dist/cjs/types/index.d.ts +1 -0
  12. package/dist/cjs/types/types.d.ts +3 -0
  13. package/dist/cjs/types/vanilla/components/ChatbotContainer.d.ts +43 -0
  14. package/dist/cjs/types/vanilla/components/ChatbotFloatingButton.d.ts +66 -0
  15. package/dist/cjs/types/vanilla/components/ChatbotIframe.d.ts +71 -0
  16. package/dist/cjs/types/vanilla/index.d.ts +32 -0
  17. package/dist/esm/index.js +1 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/types/components/ChatbotContainer/ChatbotContainer.d.ts +10 -0
  20. package/dist/esm/types/components/ChatbotContainer/index.d.ts +1 -0
  21. package/dist/esm/types/core/api.d.ts +8 -0
  22. package/dist/esm/types/core/config.d.ts +34 -0
  23. package/dist/esm/types/core/events.d.ts +22 -0
  24. package/dist/esm/types/core/index.d.ts +4 -0
  25. package/dist/esm/types/core/state.d.ts +34 -0
  26. package/dist/esm/types/index.d.ts +1 -0
  27. package/dist/esm/types/types.d.ts +3 -0
  28. package/dist/esm/types/vanilla/components/ChatbotContainer.d.ts +43 -0
  29. package/dist/esm/types/vanilla/components/ChatbotFloatingButton.d.ts +66 -0
  30. package/dist/esm/types/vanilla/components/ChatbotIframe.d.ts +71 -0
  31. package/dist/esm/types/vanilla/index.d.ts +32 -0
  32. package/dist/index.d.ts +37 -2
  33. package/dist/umd/robylon-chatbot.js +2 -0
  34. package/dist/umd/robylon-chatbot.js.map +1 -0
  35. package/dist/umd/types/components/ChatbotContainer/ChatbotContainer.d.ts +10 -0
  36. package/dist/umd/types/components/ChatbotContainer/index.d.ts +1 -0
  37. package/dist/umd/types/components/ChatbotFloatingButton.d.ts +12 -0
  38. package/dist/umd/types/components/ChatbotIframe.d.ts +12 -0
  39. package/dist/umd/types/components/ErrorBoundary.d.ts +15 -0
  40. package/dist/umd/types/components/RobylonChatbot.d.ts +11 -0
  41. package/dist/umd/types/config.d.ts +5 -0
  42. package/dist/umd/types/constants/errorConstants.d.ts +60 -0
  43. package/dist/umd/types/core/api.d.ts +8 -0
  44. package/dist/umd/types/core/config.d.ts +34 -0
  45. package/dist/umd/types/core/events.d.ts +22 -0
  46. package/dist/umd/types/core/index.d.ts +4 -0
  47. package/dist/umd/types/core/state.d.ts +34 -0
  48. package/dist/umd/types/hooks/useChatbot.d.ts +2 -0
  49. package/dist/umd/types/hooks/useChatbotEvents.d.ts +12 -0
  50. package/dist/umd/types/hooks/useChatbotState.d.ts +16 -0
  51. package/dist/umd/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
  52. package/dist/umd/types/index.d.ts +4 -0
  53. package/dist/umd/types/services/ErrorTrackingService.d.ts +38 -0
  54. package/dist/umd/types/types/config.d.ts +33 -0
  55. package/dist/umd/types/types/events.d.ts +22 -0
  56. package/dist/umd/types/types/index.d.ts +16 -0
  57. package/dist/umd/types/types/state.d.ts +5 -0
  58. package/dist/umd/types/types.d.ts +41 -0
  59. package/dist/umd/types/utils/chatbotSdk.d.ts +23 -0
  60. package/dist/umd/types/utils/colorUtils.d.ts +1 -0
  61. package/dist/umd/types/utils/cookieUtils.d.ts +6 -0
  62. package/dist/umd/types/utils/environment.d.ts +12 -0
  63. package/dist/umd/types/utils/fetchData.d.ts +30 -0
  64. package/dist/umd/types/utils/logger.d.ts +6 -0
  65. package/dist/umd/types/utils/misc.d.ts +1 -0
  66. package/dist/umd/types/utils/originalFetchDataFile.d.ts +1 -0
  67. package/dist/umd/types/utils/systemInfo.d.ts +13 -0
  68. package/dist/umd/types/utils/version.d.ts +1 -0
  69. package/dist/umd/types/vanilla/components/ChatbotContainer.d.ts +43 -0
  70. package/dist/umd/types/vanilla/components/ChatbotFloatingButton.d.ts +66 -0
  71. package/dist/umd/types/vanilla/components/ChatbotIframe.d.ts +71 -0
  72. package/dist/umd/types/vanilla/index.d.ts +32 -0
  73. package/package.json +28 -9
package/README.md CHANGED
@@ -1,154 +1,660 @@
1
- # Robylon Web React SDK
2
-
3
- A lightweight React SDK for integrating Robylon's AI-powered chatbot into your web applications.
1
+ # Robylon SDK
2
+
3
+ The Robylon SDK provides an easy way to integrate a customizable chatbot into your application. This SDK supports both React applications and plain JavaScript/no-code websites.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [React SDK Usage](#react-sdk-usage)
9
+ - [Plain JavaScript & No-Code Integration](#plain-javascript--no-code-integration)
10
+ - [Option 1: Quick Setup - Load with Page](#option-1-quick-setup---load-with-page)
11
+ - [Option 2: Reliable Loading - After DOM is Ready](#option-2-reliable-loading---after-dom-is-ready)
12
+ - [Option 3: User Context - Initialize After User Data](#option-3-user-context---initialize-after-user-data)
13
+ - [Configuration Options](#configuration-options)
14
+ - [Event Handling](#event-handling)
15
+ - [Customization](#customization)
16
+ - [Troubleshooting](#troubleshooting)
17
+ - [Platform-Specific Integration Guides](#platform-specific-integration-guides)
18
+ - [Webflow](#webflow-integration)
19
+ - [Wix](#wix-integration)
20
+ - [Shopify](#shopify-integration)
21
+ - [WordPress](#wordpress-integration)
22
+ - [Using the SDK from CDN](#using-the-sdk-from-cdn)
4
23
 
5
24
  ## Installation
6
25
 
26
+ ### For React applications:
27
+
7
28
  ```bash
8
29
  npm install @robylon/web-react-sdk
9
30
  # or
10
31
  yarn add @robylon/web-react-sdk
11
32
  ```
12
33
 
13
- ## Quick Start
34
+ ### For plain JavaScript and no-code websites:
35
+
36
+ Add this script to your website by copying and pasting the following code into the `<head>` section of your HTML:
37
+
38
+ ```html
39
+ <script src="https://cdn.robylon.ai/sdk/latest/chatbot.js"></script>
40
+ ```
41
+
42
+ #### Where to place the script:
43
+
44
+ 1. **For website builders (Wix, Squarespace, etc.):**
45
+
46
+ - Find your site editor or dashboard
47
+ - Look for "Custom Code", "Header Code", or "Site Settings" options
48
+ - Paste the script there, usually in a section labeled "Header" or "Head"
49
+
50
+ 2. **For custom HTML sites:**
51
+
52
+ - Open your website's HTML file in your editor
53
+ - Find the `<head>` section (it's near the top, between `<html>` and `<body>` tags)
54
+ - Paste the script tag just before the closing `</head>` tag
55
+
56
+ 3. **For WordPress:**
57
+ - Go to your WordPress dashboard
58
+ - Navigate to Appearance → Theme Editor or use a header/footer plugin
59
+ - Add the script to the header.php file before the closing `</head>` tag
60
+
61
+ > **Note:** Some of the integration options later in this guide will show different placements of this script - follow the specific example that best matches your needs.
62
+
63
+ ## React SDK Usage
64
+
65
+ ### React: Basic Implementation
66
+
67
+ To use the Robylon SDK in a React application:
14
68
 
15
69
  ```jsx
16
70
  import { Chatbot } from "@robylon/web-react-sdk";
17
71
 
18
72
  function App() {
19
73
  const handleChatbotEvent = (event) => {
20
- logger.log(`Chatbot event: ${event.type}`, event);
74
+ console.log("Chatbot event:", event.type, event.data);
21
75
  };
22
76
 
23
77
  return (
24
- <Chatbot
25
- api_key="your-api-key"
26
- user_id="user-id"
27
- user_token="optional-auth-token"
28
- user_profile={{
29
- email: "user@example.com",
30
- name: "John Doe",
31
- mobile: "1234567890",
32
- }}
33
- onEvent={handleChatbotEvent}
34
- />
78
+ <div className="App">
79
+ <h1>My Website</h1>
80
+
81
+ <Chatbot
82
+ api_key="YOUR_API_KEY"
83
+ user_id="optional-user-id"
84
+ user_token="optional-auth-token"
85
+ user_profile={{
86
+ name: "Optional User Name",
87
+ email: "optional.email@example.com",
88
+ }}
89
+ onEvent={handleChatbotEvent}
90
+ />
91
+ </div>
35
92
  );
36
93
  }
94
+
95
+ export default App;
96
+ ```
97
+
98
+ ### React: Event Handling
99
+
100
+ The React component accepts an `onEvent` prop for handling chatbot events:
101
+
102
+ ```jsx
103
+ <Chatbot
104
+ api_key="YOUR_API_KEY"
105
+ onEvent={(event) => {
106
+ switch (event.type) {
107
+ case "CHATBOT_LOADED":
108
+ console.log("Chatbot loaded");
109
+ break;
110
+ case "CHATBOT_OPENED":
111
+ console.log("Chatbot opened");
112
+ break;
113
+ case "CHATBOT_CLOSED":
114
+ console.log("Chatbot closed");
115
+ break;
116
+ // See the Supported Events section for all available events
117
+ }
118
+ }}
119
+ />
37
120
  ```
38
121
 
39
- ## Configuration
122
+ The `Chatbot` component renders a floating button that opens a chat interface when clicked. It handles all the communication with the Robylon backend services.
40
123
 
41
- ### Required Props
124
+ ## Plain JavaScript & No-Code Integration
42
125
 
43
- - `api_key`: Your Robylon API key
44
- - `user_id`: Unique identifier for the current user
126
+ > **IMPORTANT:** You will need an API key from Robylon for any integration to work.
45
127
 
46
- ### Optional Props
128
+ There are several ways to add the Robylon chatbot to your website or no-code platform, depending on your needs:
47
129
 
48
- - `user_token`: Authentication token for the user
49
- - `user_profile`: Object containing user information
50
- - `email`: User's email address
51
- - `name`: User's name
52
- - `mobile`: User's mobile number
53
- - `onEvent`: Callback function to handle chatbot events
130
+ ### Option 1: Quick Setup - Load with Page
54
131
 
55
- ### Event Handling
132
+ This is the simplest approach for any website. The chatbot loads while the page is loading but doesn't block the page from appearing.
56
133
 
57
- The SDK emits various events that you can listen to using the `onEvent` prop. Each event has the following structure:
134
+ #### What to copy:
58
135
 
59
- ```typescript
60
- interface ChatbotEvent {
61
- type: ChatbotEventType;
62
- timestamp: number;
63
- data?: any;
64
- }
136
+ 1️⃣ **Add this to your HTML `<head>` section:**
137
+
138
+ ```html
139
+ <script
140
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
141
+ defer
142
+ ></script>
143
+ <script>
144
+ // Initialize when page is ready
145
+ document.addEventListener("DOMContentLoaded", () => {
146
+ RobylonChatbot.create({
147
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
148
+ user_id: "optional-user-id", // Optional: remove if not needed
149
+ user_profile: {
150
+ name: "Optional User Name", // Optional: remove if not needed
151
+ email: "optional.email@example.com", // Optional: remove if not needed
152
+ },
153
+ });
154
+ });
155
+ </script>
65
156
  ```
66
157
 
67
- Available event types:
158
+ #### Complete example:
159
+
160
+ ```html
161
+ <!DOCTYPE html>
162
+ <html>
163
+ <head>
164
+ <title>Robylon SDK - Quick Setup</title>
165
+ <!-- COPY FROM HERE -->
166
+ <script
167
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
168
+ defer
169
+ ></script>
170
+ <script>
171
+ // Initialize when page is ready
172
+ document.addEventListener("DOMContentLoaded", () => {
173
+ RobylonChatbot.create({
174
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
175
+ user_id: "optional-user-id", // Optional: remove if not needed
176
+ user_profile: {
177
+ name: "Optional User Name", // Optional: remove if not needed
178
+ email: "optional.email@example.com", // Optional: remove if not needed
179
+ },
180
+ });
181
+ });
182
+ </script>
183
+ <!-- COPY UNTIL HERE -->
184
+ </head>
185
+ <body>
186
+ <h1>Your Website Content</h1>
187
+ <!-- Your website content here -->
188
+ </body>
189
+ </html>
190
+ ```
68
191
 
69
- ```typescript
70
- enum ChatbotEventType {
71
- CHATBOT_BUTTON_LOADED = "CHATBOT_BUTTON_LOADED", // When the chat button is rendered
72
- CHATBOT_OPENED = "CHATBOT_OPENED", // When chat window is opened
73
- CHATBOT_CLOSED = "CHATBOT_CLOSED", // When chat window is closed
74
- CHATBOT_APP_READY = "CHATBOT_APP_READY", // When SDK is fully initialized
75
- CHATBOT_LOADED = "CHATBOT_LOADED", // When chatbot iframe is loaded
76
- CHAT_INITIALIZED = "CHAT_INITIALIZED", // When chat session is initialized
77
- SESSION_REFRESHED = "SESSION_REFRESHED", // When chat session is refreshed
78
- CHAT_INITIALIZATION_FAILED = "CHAT_INITIALIZATION_FAILED", // When initialization fails
79
- }
192
+ ### Option 2: Reliable Loading - After DOM is Ready
193
+
194
+ This approach ensures the chatbot only initializes after your page is fully loaded, making it more reliable for websites with complex layouts.
195
+
196
+ #### What to copy:
197
+
198
+ 1️⃣ **Add this to your HTML `<head>` section:**
199
+
200
+ ```html
201
+ <script src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"></script>
80
202
  ```
81
203
 
82
- Example usage:
204
+ 2️⃣ **Add this at the end of your HTML `<body>` section:**
205
+
206
+ ```html
207
+ <script>
208
+ // Wait for page to be fully loaded before showing chatbot
209
+ document.addEventListener("DOMContentLoaded", () => {
210
+ RobylonChatbot.create({
211
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
212
+ user_id: "optional-user-id", // Optional: remove if not needed
213
+ user_profile: {
214
+ name: "Optional User Name", // Optional: remove if not needed
215
+ email: "optional.email@example.com", // Optional: remove if not needed
216
+ },
217
+ });
218
+ });
219
+ </script>
220
+ ```
83
221
 
84
- ```jsx
85
- function App() {
86
- const handleChatbotEvent = (event) => {
222
+ #### Complete example:
223
+
224
+ ```html
225
+ <!DOCTYPE html>
226
+ <html>
227
+ <head>
228
+ <title>Robylon SDK - Reliable Loading</title>
229
+ <!-- COPY FROM HERE -->
230
+ <script src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"></script>
231
+ <!-- COPY UNTIL HERE -->
232
+ </head>
233
+ <body>
234
+ <h1>Your Website Content</h1>
235
+ <!-- Your website content here -->
236
+
237
+ <script>
238
+ // Wait for page to be fully loaded before showing chatbot
239
+ document.addEventListener("DOMContentLoaded", () => {
240
+ RobylonChatbot.create({
241
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
242
+ user_id: "optional-user-id", // Optional: remove if not needed
243
+ user_profile: {
244
+ name: "Optional User Name", // Optional: remove if not needed
245
+ email: "optional.email@example.com", // Optional: remove if not needed
246
+ },
247
+ });
248
+ });
249
+ </script>
250
+ </body>
251
+ </html>
252
+ ```
253
+
254
+ ### Option 3: User Context - Initialize After User Data
255
+
256
+ This approach loads the chatbot after user data is available. Great for websites where you want to personalize the chat experience.
257
+
258
+ #### What to copy:
259
+
260
+ 1️⃣ **Add this to your HTML `<head>` section:**
261
+
262
+ ```html
263
+ <script
264
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
265
+ defer
266
+ ></script>
267
+ ```
268
+
269
+ 2️⃣ **Add this script at the end of your HTML `<body>` section:**
270
+
271
+ ```html
272
+ <script>
273
+ // Wait for page to be ready
274
+ document.addEventListener("DOMContentLoaded", () => {
275
+ // Get your user data (replace this with your own method)
276
+ getUserData().then((user) => {
277
+ // Initialize chatbot with user info
278
+ RobylonChatbot.create({
279
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
280
+ user_id: user.id,
281
+ user_profile: {
282
+ name: user.name,
283
+ email: user.email,
284
+ },
285
+ });
286
+ });
287
+ });
288
+
289
+ // Example function to get user data - replace with your own
290
+ function getUserData() {
291
+ // This is just a placeholder - replace with your actual code
292
+ return Promise.resolve({
293
+ id: "user123",
294
+ name: "Jane Smith",
295
+ email: "jane@example.com",
296
+ });
297
+ }
298
+ </script>
299
+ ```
300
+
301
+ #### Complete example:
302
+
303
+ ```html
304
+ <!DOCTYPE html>
305
+ <html>
306
+ <head>
307
+ <title>My Website</title>
308
+ <!-- COPY FROM HERE -->
309
+ <script
310
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
311
+ defer
312
+ ></script>
313
+ <!-- COPY UNTIL HERE -->
314
+ </head>
315
+ <body>
316
+ <h1>Your Website Content</h1>
317
+ <!-- Your website content here -->
318
+
319
+ <!-- COPY FROM HERE -->
320
+ <script>
321
+ // Wait for page to be ready
322
+ document.addEventListener("DOMContentLoaded", () => {
323
+ // Get your user data (replace this with your own method)
324
+ getUserData().then((user) => {
325
+ // Initialize chatbot with user info
326
+ RobylonChatbot.create({
327
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
328
+ user_id: user.id,
329
+ user_profile: {
330
+ name: user.name,
331
+ email: user.email,
332
+ },
333
+ });
334
+ });
335
+ });
336
+
337
+ // Example function to get user data - replace with your own
338
+ function getUserData() {
339
+ // This is just a placeholder - replace with your actual code
340
+ return Promise.resolve({
341
+ id: "user123",
342
+ name: "Jane Smith",
343
+ email: "jane@example.com",
344
+ });
345
+ }
346
+ </script>
347
+ <!-- COPY UNTIL HERE -->
348
+ </body>
349
+ </html>
350
+ ```
351
+
352
+ ### Plain JS & No-Code: Event Handling
353
+
354
+ You can handle chatbot events in plain JavaScript using the `onEvent` callback:
355
+
356
+ #### What to copy:
357
+
358
+ ```javascript
359
+ const chatbot = RobylonChatbot.create({
360
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
361
+ onEvent: function (event) {
87
362
  switch (event.type) {
88
- case "CHATBOT_BUTTON_CLICKED":
89
- logger.log("Chat button clicked at:", new Date(event.timestamp));
363
+ case "CHATBOT_LOADED":
364
+ console.log("Chatbot loaded");
90
365
  break;
91
366
  case "CHATBOT_OPENED":
92
- logger.log("Chat window opened at:", new Date(event.timestamp));
367
+ console.log("Chatbot opened");
93
368
  break;
94
- case "CHAT_INITIALIZED":
95
- logger.log("Chat session initialized");
96
- break;
97
- case "CHAT_INITIALIZATION_FAILED":
98
- console.error("Chat initialization failed:", event.data);
369
+ case "CHATBOT_CLOSED":
370
+ console.log("Chatbot closed");
99
371
  break;
372
+ // See the Supported Events section for all available events
100
373
  }
101
- };
374
+ },
375
+ });
376
+
377
+ // The chatbot instance provides methods to control the chatbot
378
+ // chatbot.show(); // Show the chatbot
379
+ // chatbot.hide(); // Hide the chatbot
380
+ // chatbot.toggle(); // Toggle visibility
381
+ // chatbot.destroy(); // Remove the chatbot from the page
382
+ ```
102
383
 
103
- return (
104
- <Chatbot
105
- api_key="your-api-key"
106
- user_id="user-id"
107
- onEvent={handleChatbotEvent}
108
- />
109
- );
110
- }
384
+ ## Configuration Options
385
+
386
+ The SDK supports the following configuration options for both React and plain JavaScript implementations:
387
+
388
+ | Option | Type | Description | Required/Optional |
389
+ | ------------ | -------- | ----------------------------------------- | ----------------- |
390
+ | api_key | string | Your Robylon API key | Required |
391
+ | user_id | string | User identifier for conversation tracking | Optional |
392
+ | user_token | string | Authentication token | Optional |
393
+ | user_profile | object | Additional user information | Optional |
394
+ | onEvent | function | Event handler for chatbot interactions | Optional |
395
+
396
+ ## Event Handling
397
+
398
+ ### Supported Events
399
+
400
+ The SDK emits the following events that you can listen for in both React and plain JavaScript implementations:
401
+
402
+ | Event Type | Description | Data |
403
+ | ---------------------------- | ----------------------------------------------- | ---------------------------------------- |
404
+ | `CHATBOT_BUTTON_LOADED` | The chatbot button has been loaded and rendered | - |
405
+ | `CHATBOT_LOADED` | The chatbot iframe has been loaded | - |
406
+ | `CHATBOT_OPENED` | The chatbot has been opened | - |
407
+ | `CHATBOT_CLOSED` | The chatbot has been closed | - |
408
+ | `CHAT_INITIALIZED` | The chat session has been initialized | - |
409
+ | `CHAT_INITIALIZATION_FAILED` | The chat session failed to initialize | `{ error: string }` |
410
+ | `SESSION_REFRESHED` | The chat session has been refreshed | - |
411
+ | `MESSAGE_SENT` | User has sent a message | `{ message: string }` |
412
+ | `MESSAGE_RECEIVED` | A message was received from the chatbot | `{ message: string }` |
413
+ | `CONVERSATION_STARTED` | A new conversation has started | `{ conversationId: string }` |
414
+ | `CONVERSATION_ENDED` | The current conversation has ended | `{ conversationId: string }` |
415
+ | `USER_AUTHENTICATED` | The user has been authenticated | `{ userId: string }` |
416
+ | `USER_PROFILE_UPDATED` | The user profile has been updated | `{ profile: object }` |
417
+ | `USER_FEEDBACK_SUBMITTED` | The user has submitted feedback | `{ rating: number, comment: string }` |
418
+ | `FILE_UPLOAD_STARTED` | A file upload has started | `{ fileName: string, fileSize: number }` |
419
+ | `FILE_UPLOAD_COMPLETED` | A file upload has completed | `{ fileName: string, fileUrl: string }` |
420
+ | `FILE_UPLOAD_FAILED` | A file upload has failed | `{ fileName: string, error: string }` |
421
+ | `CHATBOT_ERROR` | An error occurred in the chatbot | `{ code: string, message: string }` |
422
+
423
+ Events can be handled through the `onEvent` callback in both React and plain JavaScript implementations. Each event includes a `timestamp` field indicating when the event occurred.
424
+
425
+ ## Customization
426
+
427
+ The Robylon SDK can be customized through the management console. Visit [app.robylon.ai](https://app.robylon.ai) to:
428
+
429
+ - Customize the chatbot appearance
430
+ - Set up chatbot behavior
431
+ - Configure message flows
432
+ - Manage AI capabilities
433
+
434
+ ## Troubleshooting
435
+
436
+ If you encounter issues with the SDK:
437
+
438
+ 1. Ensure your API key is correct
439
+ 2. Check browser console for errors
440
+ 3. Verify that your domain is whitelisted in the Robylon console
441
+ 4. Make sure the script is loading correctly (no CORS or network issues)
442
+ 5. For vanilla JS implementation, ensure you're using `RobylonChatbot.create()` and not `new RobylonChatbot()`
443
+
444
+ For further assistance, contact [support@robylon.com](mailto:support@robylon.com)
445
+
446
+ ## Platform-Specific Integration Guides
447
+
448
+ ### <a id="webflow-integration"></a>Webflow Integration
449
+
450
+ Webflow is a popular no-code website builder that allows custom code injection. Here's how to add the Robylon chatbot to your Webflow site:
451
+
452
+ 1. Log in to your Webflow account and open your project
453
+ 2. Go to **Project Settings** (gear icon) in the left sidebar
454
+ 3. Click on **Custom Code** tab
455
+ 4. In the **Head Code** section, paste the following code:
456
+
457
+ ```html
458
+ <script
459
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
460
+ defer
461
+ ></script>
462
+ <script>
463
+ document.addEventListener("DOMContentLoaded", function () {
464
+ RobylonChatbot.create({
465
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
466
+ });
467
+ });
468
+ </script>
469
+ ```
470
+
471
+ 5. Click **Save Changes** at the bottom of the page
472
+ 6. Publish your site to apply the changes
473
+
474
+ ![Webflow Custom Code](https://cdn.robylon.ai/docs/webflow-integration.png)
475
+
476
+ ### <a id="wix-integration"></a>Wix Integration
477
+
478
+ To add the Robylon chatbot to your Wix website:
479
+
480
+ 1. Log in to your Wix account and open your site in the Editor
481
+ 2. Click on the **+ Add** button on the left sidebar
482
+ 3. Search for and select **Dev Tools** > **Custom Code**
483
+ 4. Click **Add to Site**
484
+ 5. In the popup, select **Head** as the placement
485
+ 6. Paste the following code:
486
+
487
+ ```html
488
+ <script
489
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
490
+ defer
491
+ ></script>
492
+ <script>
493
+ document.addEventListener("DOMContentLoaded", function () {
494
+ RobylonChatbot.create({
495
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
496
+ });
497
+ });
498
+ </script>
499
+ ```
500
+
501
+ 7. Click **Apply** and then **Save**
502
+ 8. Publish your site to apply the changes
503
+
504
+ ### <a id="shopify-integration"></a>Shopify Integration
505
+
506
+ To add the Robylon chatbot to your Shopify store:
507
+
508
+ 1. Log in to your Shopify admin dashboard
509
+ 2. Go to **Online Store** > **Themes**
510
+ 3. Find your current theme and click **Actions** > **Edit code**
511
+ 4. In the left sidebar, under the **Layout** section, click on `theme.liquid`
512
+ 5. Find the closing `</head>` tag
513
+ 6. Just before the `</head>` tag, paste the following code:
514
+
515
+ ```html
516
+ <script
517
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
518
+ defer
519
+ ></script>
520
+ <script>
521
+ document.addEventListener("DOMContentLoaded", function() {
522
+ RobylonChatbot.create({
523
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
524
+ user_profile: {% if customer %}
525
+ {
526
+ name: {{ customer.name | json }},
527
+ email: {{ customer.email | json }},
528
+ id: {{ customer.id | json }}
529
+ }
530
+ {% else %}
531
+ {}
532
+ {% endif %}
533
+ });
534
+ });
535
+ </script>
111
536
  ```
112
537
 
113
- ### Automatically Included Information
538
+ 7. Click **Save**
539
+ 8. Your chatbot will now appear on all pages of your Shopify store
540
+
541
+ ### <a id="wordpress-integration"></a>WordPress Integration
542
+
543
+ #### Option 1: Using a Header/Footer Plugin
544
+
545
+ 1. Install and activate a header/footer plugin like "Insert Headers and Footers" or "Header Footer Code Manager"
546
+ 2. Go to the plugin settings (usually under **Settings** or its own menu item)
547
+ 3. Add the following code to the **Header** section:
548
+
549
+ ```html
550
+ <script
551
+ src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js"
552
+ defer
553
+ ></script>
554
+ <script>
555
+ document.addEventListener("DOMContentLoaded", function () {
556
+ RobylonChatbot.create({
557
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
558
+ });
559
+ });
560
+ </script>
561
+ ```
114
562
 
115
- The SDK automatically collects and includes the following system information:
563
+ 4. Save the changes
564
+
565
+ #### Option 2: Editing Theme Files
566
+
567
+ If you're comfortable editing theme files:
568
+
569
+ 1. Go to **Appearance** > **Theme Editor**
570
+ 2. Select **Theme Header** (`header.php`)
571
+ 3. Find the closing `</head>` tag
572
+ 4. Just before the `</head>` tag, paste the following code:
573
+
574
+ ```php
575
+ <script src="https://cdn.robylon.ai/sdk/latest/robylon-chatbot.js" defer></script>
576
+ <script>
577
+ document.addEventListener("DOMContentLoaded", function() {
578
+ RobylonChatbot.create({
579
+ api_key: "YOUR_API_KEY", // Replace with your actual API key
580
+ <?php if (is_user_logged_in()): ?>
581
+ user_id: "<?php echo get_current_user_id(); ?>",
582
+ user_profile: {
583
+ name: "<?php echo esc_js(wp_get_current_user()->display_name); ?>",
584
+ email: "<?php echo esc_js(wp_get_current_user()->user_email); ?>"
585
+ }
586
+ <?php endif; ?>
587
+ });
588
+ });
589
+ </script>
590
+ ```
116
591
 
117
- - `platform`: Always set to "web"
118
- - `os`: User's operating system
119
- - `browser`: User's browser type
120
- - `device`: Device type (desktop/mobile/tablet)
121
- - `screen_size`: User's screen dimensions (width and height)
122
- - `sdk_version`: Current version of the SDK
592
+ 5. Save the changes
123
593
 
124
- ## Features
594
+ > **Note:** For WordPress, if you're using a caching plugin, you may need to clear the cache after adding the code.
125
595
 
126
- - Persistent chat interface
127
- - Responsive design for all screen sizes
128
- - Automatic system information collection
129
- - Customizable chat bubble
130
- - Session management
131
- - Secure communication channel
132
- - Cross-browser compatibility
133
- - Comprehensive event system
596
+ ## Using the SDK from CDN
134
597
 
135
- ## Browser Support
598
+ You can use the Robylon Chatbot SDK directly from our CDN without installing it via npm. This is useful for quick integration or when you're not using a build system.
136
599
 
137
- The SDK supports all modern browsers and includes fallbacks for:
600
+ ### Latest Version
138
601
 
139
- - User agent detection
140
- - Screen size detection
141
- - Browser identification
142
- - Device type detection
602
+ To use the latest version of the SDK, include the following script tag in your HTML:
143
603
 
144
- ## Development
604
+ ```html
605
+ <script src="https://cdn.robylon.ai/sdk/latest/chatbot.js"></script>
606
+ <script>
607
+ document.addEventListener("DOMContentLoaded", function () {
608
+ // Initialize the chatbot
609
+ const chatbot = RobylonChatbot.create({
610
+ api_key: "YOUR_API_KEY",
611
+ // Optional configuration
612
+ user_id: "user-123",
613
+ user_profile: {
614
+ name: "John Doe",
615
+ email: "john@example.com",
616
+ },
617
+ onEvent: function (event) {
618
+ console.log("Chatbot event:", event);
619
+ },
620
+ });
621
+
622
+ // Show the chatbot
623
+ chatbot.show();
624
+ });
625
+ </script>
626
+ ```
145
627
 
146
- ### Creating Branches
628
+ ### Specific Version
147
629
 
148
- Always use the provided script to create new branches:
630
+ If you need to use a specific version of the SDK (recommended for production), use:
149
631
 
150
- ```bash
151
- npm run branch
632
+ ```html
633
+ <script src="https://cdn.robylon.ai/sdk/v1.1.30/chatbot.js"></script>
152
634
  ```
153
635
 
154
- This ensures proper version control and naming conventions.
636
+ Replace `1.1.30` with the version you want to use.
637
+
638
+ ### Staging Version
639
+
640
+ For testing with our staging environment:
641
+
642
+ ```html
643
+ <script src="https://cdn.robylon.ai/sdk/staging/latest/chatbot.js"></script>
644
+ ```
645
+
646
+ Or for a specific staging version:
647
+
648
+ ```html
649
+ <script src="https://cdn.robylon.ai/sdk/staging/v1.1.30-staging.4/chatbot.js"></script>
650
+ ```
651
+
652
+ ### API Reference
653
+
654
+ The CDN version provides the same API as the npm package:
655
+
656
+ - `RobylonChatbot.create(config)`: Creates a new chatbot instance
657
+ - `chatbot.show()`: Shows the chatbot
658
+ - `chatbot.hide()`: Hides the chatbot
659
+ - `chatbot.toggle()`: Toggles the chatbot visibility
660
+ - `chatbot.destroy()`: Removes the chatbot from the DOM