@robylon/web-react-sdk 1.1.32-staging.1 → 1.1.33-staging.2

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