@robylon/web-react-sdk 1.1.35-staging.3 → 1.1.35
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 +195 -256
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ChatbotContainer/ChatbotContainer.d.ts +5 -0
- package/dist/cjs/types/components/ChatbotFloatingButton.d.ts +3 -0
- package/dist/cjs/types/components/ChatbotIframe.d.ts +2 -0
- package/dist/cjs/types/components/RobylonChatbot.d.ts +7 -3
- package/dist/cjs/types/constants/fontStyles.d.ts +2 -0
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/cjs/types/types/events.d.ts +8 -1
- package/dist/cjs/types/types.d.ts +30 -0
- package/dist/cjs/types/utils/fetchData.d.ts +16 -0
- package/dist/cjs/types/vanilla/components/ChatbotContainer.d.ts +3 -1
- package/dist/cjs/types/vanilla/components/ChatbotFloatingButton.d.ts +6 -0
- package/dist/cjs/types/vanilla/components/ChatbotIframe.d.ts +2 -0
- package/dist/cjs/types/vanilla/index.d.ts +7 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ChatbotContainer/ChatbotContainer.d.ts +5 -0
- package/dist/esm/types/components/ChatbotFloatingButton.d.ts +3 -0
- package/dist/esm/types/components/ChatbotIframe.d.ts +2 -0
- package/dist/esm/types/components/RobylonChatbot.d.ts +7 -3
- package/dist/esm/types/constants/fontStyles.d.ts +2 -0
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/esm/types/types/events.d.ts +8 -1
- package/dist/esm/types/types.d.ts +30 -0
- package/dist/esm/types/utils/fetchData.d.ts +16 -0
- package/dist/esm/types/vanilla/components/ChatbotContainer.d.ts +3 -1
- package/dist/esm/types/vanilla/components/ChatbotFloatingButton.d.ts +6 -0
- package/dist/esm/types/vanilla/components/ChatbotIframe.d.ts +2 -0
- package/dist/esm/types/vanilla/index.d.ts +7 -4
- package/dist/index.d.ts +50 -7
- package/dist/umd/robylon-chatbot.js +1 -1
- package/dist/umd/robylon-chatbot.js.map +1 -1
- package/dist/umd/types/components/ChatbotContainer/ChatbotContainer.d.ts +5 -0
- package/dist/umd/types/components/ChatbotFloatingButton.d.ts +3 -0
- package/dist/umd/types/components/ChatbotIframe.d.ts +2 -0
- package/dist/umd/types/components/RobylonChatbot.d.ts +7 -3
- package/dist/umd/types/constants/fontStyles.d.ts +2 -0
- package/dist/umd/types/index.d.ts +3 -1
- package/dist/umd/types/types/events.d.ts +8 -1
- package/dist/umd/types/types.d.ts +30 -0
- package/dist/umd/types/utils/fetchData.d.ts +16 -0
- package/dist/umd/types/vanilla/components/ChatbotContainer.d.ts +3 -1
- package/dist/umd/types/vanilla/components/ChatbotFloatingButton.d.ts +6 -0
- package/dist/umd/types/vanilla/components/ChatbotIframe.d.ts +2 -0
- package/dist/umd/types/vanilla/index.d.ts +7 -4
- package/package.json +2 -2
- package/dist/cjs/types/types/config.d.ts +0 -33
- package/dist/cjs/types/types/index.d.ts +0 -16
- package/dist/esm/types/types/config.d.ts +0 -33
- package/dist/esm/types/types/index.d.ts +0 -16
- package/dist/umd/types/types/config.d.ts +0 -33
- package/dist/umd/types/types/index.d.ts +0 -16
package/README.md
CHANGED
|
@@ -6,20 +6,17 @@ The Robylon SDK provides an easy way to integrate a customizable chatbot into yo
|
|
|
6
6
|
|
|
7
7
|
- [Installation](#installation)
|
|
8
8
|
- [React SDK Usage](#react-sdk-usage)
|
|
9
|
+
- [Basic Implementation](#react-basic-implementation)
|
|
10
|
+
- [External Triggers](#react-external-triggers)
|
|
11
|
+
- [Event Handling](#react-event-handling)
|
|
9
12
|
- [Plain JavaScript & No-Code Integration](#plain-javascript--no-code-integration)
|
|
13
|
+
- [Quick Embed (Easiest Method)](#quick-embed-easiest-method)
|
|
14
|
+
- [ES5/Google Tag Manager](#es5google-tag-manager)
|
|
10
15
|
- [Option 1: Quick Setup - Load with Page](#option-1-quick-setup---load-with-page)
|
|
11
16
|
- [Option 2: Reliable Loading - After DOM is Ready](#option-2-reliable-loading---after-dom-is-ready)
|
|
12
17
|
- [Option 3: User Context - Initialize After User Data](#option-3-user-context---initialize-after-user-data)
|
|
13
18
|
- [Configuration Options](#configuration-options)
|
|
14
19
|
- [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)
|
|
23
20
|
|
|
24
21
|
## Installation
|
|
25
22
|
|
|
@@ -121,11 +118,150 @@ The React component accepts an `onEvent` prop for handling chatbot events:
|
|
|
121
118
|
|
|
122
119
|
The `Chatbot` component renders a floating button that opens a chat interface when clicked. It handles all the communication with the Robylon backend services.
|
|
123
120
|
|
|
121
|
+
### React: External Triggers
|
|
122
|
+
|
|
123
|
+
You can control the chatbot iframe from outside the component using a ref. This allows you to trigger open, close, or toggle actions from anywhere in your application:
|
|
124
|
+
|
|
125
|
+
```jsx
|
|
126
|
+
import React, { useRef, useState, useEffect } from "react";
|
|
127
|
+
import { Chatbot, ChatbotRef } from "@robylon/web-react-sdk";
|
|
128
|
+
|
|
129
|
+
function App() {
|
|
130
|
+
const chatbotRef = useRef < ChatbotRef > null;
|
|
131
|
+
const [isChatbotReady, setIsChatbotReady] = useState(false);
|
|
132
|
+
|
|
133
|
+
// Method 1: Check readiness state before calling methods
|
|
134
|
+
const showChatbot = () => {
|
|
135
|
+
if (chatbotRef.current?.isReady) {
|
|
136
|
+
chatbotRef.current.show();
|
|
137
|
+
} else {
|
|
138
|
+
console.log("Chatbot not ready yet");
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const hideChatbot = () => {
|
|
143
|
+
chatbotRef.current?.hide();
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const toggleChatbot = () => {
|
|
147
|
+
chatbotRef.current?.toggle();
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Method 2: Listen for ready event
|
|
151
|
+
const handleChatbotEvent = (event) => {
|
|
152
|
+
if (event.type === "CHATBOT_READY") {
|
|
153
|
+
setIsChatbotReady(true);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<div className="App">
|
|
159
|
+
<h1>My Website</h1>
|
|
160
|
+
|
|
161
|
+
{/* External control buttons with readiness state */}
|
|
162
|
+
<button onClick={showChatbot} disabled={!isChatbotReady}>
|
|
163
|
+
Show Chatbot
|
|
164
|
+
</button>
|
|
165
|
+
<button onClick={hideChatbot}>Hide Chatbot</button>
|
|
166
|
+
<button onClick={toggleChatbot}>Toggle Chatbot</button>
|
|
167
|
+
|
|
168
|
+
<Chatbot
|
|
169
|
+
ref={chatbotRef}
|
|
170
|
+
api_key="YOUR_API_KEY"
|
|
171
|
+
user_id="optional-user-id"
|
|
172
|
+
onEvent={handleChatbotEvent}
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Available External Methods & Properties
|
|
180
|
+
|
|
181
|
+
| Method/Property | Type | Description |
|
|
182
|
+
| --------------- | -------- | ------------------------------------------------------ |
|
|
183
|
+
| `show()` | function | Opens the chatbot iframe if it's currently closed |
|
|
184
|
+
| `hide()` | function | Closes the chatbot iframe if it's currently open |
|
|
185
|
+
| `toggle()` | function | Toggles the chatbot iframe visibility |
|
|
186
|
+
| `isReady` | boolean | Indicates if the chatbot is ready for external control |
|
|
187
|
+
|
|
188
|
+
#### Event Handling with External Triggers
|
|
189
|
+
|
|
190
|
+
External trigger methods emit the same events as internal triggers:
|
|
191
|
+
|
|
192
|
+
- `CHATBOT_BUTTON_CLICKED` - When `show()` or `toggle()` opens the chatbot
|
|
193
|
+
- `CHATBOT_CLOSED` - When `hide()` or `toggle()` closes the chatbot
|
|
194
|
+
- `CHATBOT_READY` - When the chatbot is ready for external control (emitted once after initialization)
|
|
195
|
+
|
|
196
|
+
This ensures consistent event handling regardless of how the chatbot is triggered.
|
|
197
|
+
|
|
198
|
+
#### Readiness Handling
|
|
199
|
+
|
|
200
|
+
The SDK provides multiple ways to handle chatbot readiness:
|
|
201
|
+
|
|
202
|
+
1. **Check `isReady` property** - Synchronous check before calling methods
|
|
203
|
+
2. **Listen for `CHATBOT_READY` event** - Event-based notification when ready
|
|
204
|
+
3. **Guard clauses** - Methods safely handle early calls with console warnings
|
|
205
|
+
|
|
206
|
+
This prevents race conditions and provides a smooth user experience.
|
|
207
|
+
|
|
124
208
|
## Plain JavaScript & No-Code Integration
|
|
125
209
|
|
|
126
210
|
> **IMPORTANT:** You will need an API key from Robylon for any integration to work.
|
|
127
211
|
|
|
128
|
-
|
|
212
|
+
### Quick Embed (Easiest Method)
|
|
213
|
+
|
|
214
|
+
This is the simplest way to add the Robylon chatbot to any website with a single line of code. Just copy and paste this script tag into your HTML:
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
<script>(function(k){window.R=window.R||function(){(window.R.q=window.R.q||[]).push(arguments)};window.R=new Proxy(window.R,{get:(t,p)=>p==="q"?t.q:(...a)=>t(p,...a)});function l(){var s=document.createElement("script");s.src="https://cdn.robylon.ai/sdk/latest/chatbot.js";s.onload=()=>k&&window.RobylonChatbot.create({api_key:k});document.body.appendChild(s)}document.readyState==="complete"?l():window.addEventListener("load",l)})("YOUR_API_KEY_HERE");</script>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Just replace `YOUR_API_KEY_HERE` with your actual Robylon API key, and you're done! No additional code is needed.
|
|
221
|
+
|
|
222
|
+
### ES5/Google Tag Manager
|
|
223
|
+
|
|
224
|
+
#### ES5 Compatible Version
|
|
225
|
+
|
|
226
|
+
For older browsers that don't support ES6 features, use this ES5 compatible version:
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
<script>(function(a){window.R=window.R||function(){(window.R.q=window.R.q||[]).push(Array.prototype.slice.call(arguments))};window.R.show=function(){window.R('show')};window.R.hide=function(){window.R('hide')};window.R.toggle=function(){window.R('toggle')};window.R.track=function(){window.R('track',Array.prototype.slice.call(arguments))};var o=function(){var s=document.createElement("script");s.src="https://cdn.robylon.ai/sdk/latest/chatbot.js";s.id="robylon-chatbot-sdk";s.onload=function(){if(a){window.RobylonChatbot.create({api_key:a})}};document.body.appendChild(s)};if(document.readyState==="complete"){o()}else{window.addEventListener("load",o)}})("YOUR_API_KEY_HERE");</script>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
This version is compatible with Internet Explorer 11 and other older browsers that don't support ES6 features like arrow functions, `const`/`let`, and Proxy objects.
|
|
233
|
+
|
|
234
|
+
#### Quick Embed with Custom Position and Spacing
|
|
235
|
+
|
|
236
|
+
If you want to customize the position and spacing of the chatbot button, you can use this alternative version:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
<script>(function(k,p,side,bottom){window.R=window.R||function(){(window.R.q=window.R.q||[]).push(arguments)};window.R=new Proxy(window.R,{get:(t,p)=>p==="q"?t.q:(...a)=>t(p,...a)});function l(){var s=document.createElement("script");s.src="https://cdn.robylon.ai/sdk/latest/chatbot.js";s.onload=()=>k&&window.RobylonChatbot.create({api_key:k,position:p,sideSpacing:side,bottomSpacing:bottom});document.body.appendChild(s)}document.readyState==="complete"?l():window.addEventListener("load",l)})("YOUR_API_KEY_HERE","Left",30,25);</script>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Just replace:
|
|
243
|
+
|
|
244
|
+
- `YOUR_API_KEY_HERE` with your actual API key
|
|
245
|
+
- `"Left"` with `"Left"` or `"Right"` for button position
|
|
246
|
+
- `30` with your desired side spacing in pixels
|
|
247
|
+
- `25` with your desired bottom spacing in pixels
|
|
248
|
+
|
|
249
|
+
##### ES5 Compatible Version with Custom Position and Spacing
|
|
250
|
+
|
|
251
|
+
For older browsers, use this ES5 compatible version with custom positioning:
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
<script>(function(a,p,s,b){window.R=window.R||function(){(window.R.q=window.R.q||[]).push(Array.prototype.slice.call(arguments))};window.R.show=function(){window.R('show')};window.R.hide=function(){window.R('hide')};window.R.toggle=function(){window.R('toggle')};window.R.track=function(){window.R('track',Array.prototype.slice.call(arguments))};var o=function(){var s=document.createElement("script");s.src="https://cdn.robylon.ai/sdk/latest/chatbot.js";s.id="robylon-chatbot-sdk";s.onload=function(){if(a){window.RobylonChatbot.create({api_key:a,position:p,sideSpacing:s,bottomSpacing:b})}};document.body.appendChild(s)};if(document.readyState==="complete"){o()}else{window.addEventListener("load",o)}})("YOUR_API_KEY_HERE","Left",30,25);</script>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Replace the same parameters as above for the ES5 compatible version.
|
|
258
|
+
|
|
259
|
+
#### Where to place the script:
|
|
260
|
+
|
|
261
|
+
- At the end of your HTML `<body>` section for best performance
|
|
262
|
+
- Or anywhere in your HTML code if you're using a website builder
|
|
263
|
+
|
|
264
|
+
There are several other ways to add the Robylon chatbot to your website or no-code platform, depending on your needs:
|
|
129
265
|
|
|
130
266
|
### Option 1: Quick Setup - Load with Page
|
|
131
267
|
|
|
@@ -379,19 +515,59 @@ const chatbot = RobylonChatbot.create({
|
|
|
379
515
|
// chatbot.hide(); // Hide the chatbot
|
|
380
516
|
// chatbot.toggle(); // Toggle visibility
|
|
381
517
|
// chatbot.destroy(); // Remove the chatbot from the page
|
|
518
|
+
|
|
519
|
+
> **Note:** The plain JavaScript SDK provides direct instance methods for external control. The React SDK provides similar functionality through refs (see [React External Triggers](#react-external-triggers) section above).
|
|
382
520
|
```
|
|
383
521
|
|
|
384
522
|
## Configuration Options
|
|
385
523
|
|
|
386
|
-
The SDK supports the following configuration options for both React and plain JavaScript implementations
|
|
524
|
+
The SDK supports the following configuration options for both React and plain JavaScript implementations. **Note:** The React SDK also supports external triggers via refs for programmatic control of the chatbot iframe.
|
|
525
|
+
|
|
526
|
+
| Option | Type | Description | Required/Optional |
|
|
527
|
+
| ------------- | -------- | ------------------------------------------------- | ----------------- |
|
|
528
|
+
| api_key | string | Your Robylon API key | Required |
|
|
529
|
+
| user_id | string | User identifier for conversation tracking | Optional |
|
|
530
|
+
| user_token | string | Authentication token | Optional |
|
|
531
|
+
| user_profile | object | Additional user information | Optional |
|
|
532
|
+
| onEvent | function | Event handler for chatbot interactions | Optional |
|
|
533
|
+
| position | string | Position of the chatbot button ("Left"/"Right") | Optional |
|
|
534
|
+
| sideSpacing | number | Distance from the side of the screen (in px) | Optional |
|
|
535
|
+
| bottomSpacing | number | Distance from the bottom of the screen (in px) | Optional |
|
|
536
|
+
| show_launcher | boolean | Show the floating launcher button (default: true) | Optional |
|
|
537
|
+
|
|
538
|
+
### Position and Spacing Configuration
|
|
539
|
+
|
|
540
|
+
You can control the position and spacing of the chatbot button either through the API configuration or directly in the SDK. If both are provided, the SDK configuration takes precedence.
|
|
541
|
+
|
|
542
|
+
#### React Example:
|
|
543
|
+
|
|
544
|
+
```jsx
|
|
545
|
+
<Chatbot
|
|
546
|
+
api_key="YOUR_API_KEY"
|
|
547
|
+
position="Left"
|
|
548
|
+
sideSpacing={30}
|
|
549
|
+
bottomSpacing={25}
|
|
550
|
+
/>
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
#### React: Hide Floating Launcher Button
|
|
554
|
+
|
|
555
|
+
To hide the floating launcher and manage visibility via external triggers or custom UI, set `show_launcher` to `false` (defaults to `true`):
|
|
387
556
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
557
|
+
```jsx
|
|
558
|
+
<Chatbot api_key="YOUR_API_KEY" show_launcher={false} />
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
#### Plain JavaScript Example:
|
|
562
|
+
|
|
563
|
+
```javascript
|
|
564
|
+
RobylonChatbot.create({
|
|
565
|
+
api_key: "YOUR_API_KEY",
|
|
566
|
+
position: "Left",
|
|
567
|
+
sideSpacing: 30,
|
|
568
|
+
bottomSpacing: 25,
|
|
569
|
+
});
|
|
570
|
+
```
|
|
395
571
|
|
|
396
572
|
## Event Handling
|
|
397
573
|
|
|
@@ -405,6 +581,7 @@ The SDK emits the following events that you can listen for in both React and pla
|
|
|
405
581
|
| `CHATBOT_LOADED` | The chatbot iframe has been loaded | - |
|
|
406
582
|
| `CHATBOT_OPENED` | The chatbot has been opened | - |
|
|
407
583
|
| `CHATBOT_CLOSED` | The chatbot has been closed | - |
|
|
584
|
+
| `CHATBOT_READY` | The chatbot is ready for external control | - |
|
|
408
585
|
| `CHAT_INITIALIZED` | The chat session has been initialized | - |
|
|
409
586
|
| `CHAT_INITIALIZATION_FAILED` | The chat session failed to initialize | `{ error: string }` |
|
|
410
587
|
| `SESSION_REFRESHED` | The chat session has been refreshed | - |
|
|
@@ -418,243 +595,5 @@ The SDK emits the following events that you can listen for in both React and pla
|
|
|
418
595
|
| `FILE_UPLOAD_STARTED` | A file upload has started | `{ fileName: string, fileSize: number }` |
|
|
419
596
|
| `FILE_UPLOAD_COMPLETED` | A file upload has completed | `{ fileName: string, fileUrl: string }` |
|
|
420
597
|
| `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
|
-

|
|
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>
|
|
536
|
-
```
|
|
537
|
-
|
|
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
|
-
```
|
|
562
|
-
|
|
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
|
-
```
|
|
591
|
-
|
|
592
|
-
5. Save the changes
|
|
593
|
-
|
|
594
|
-
> **Note:** For WordPress, if you're using a caching plugin, you may need to clear the cache after adding the code.
|
|
595
|
-
|
|
596
|
-
## Using the SDK from CDN
|
|
597
|
-
|
|
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.
|
|
599
|
-
|
|
600
|
-
### Latest Version
|
|
601
|
-
|
|
602
|
-
To use the latest version of the SDK, include the following script tag in your HTML:
|
|
603
|
-
|
|
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
|
-
```
|
|
627
|
-
|
|
628
|
-
### Specific Version
|
|
629
|
-
|
|
630
|
-
If you need to use a specific version of the SDK (recommended for production), use:
|
|
631
|
-
|
|
632
|
-
```html
|
|
633
|
-
<script src="https://cdn.robylon.ai/sdk/v1.1.30/chatbot.js"></script>
|
|
634
|
-
```
|
|
635
|
-
|
|
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
598
|
|
|
656
|
-
|
|
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
|
|
599
|
+
| `CHATBOT_ERROR`
|