@robylon/whatsapp-react-sdk 1.0.0-staging.1
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/CONTRIBUTING.md +133 -0
- package/README.md +736 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/components/ChatWidgetPopup.d.ts +8 -0
- package/dist/cjs/types/components/ChatbotContainer/ChatbotContainer.d.ts +15 -0
- package/dist/cjs/types/components/ChatbotContainer/index.d.ts +1 -0
- package/dist/cjs/types/components/ChatbotFloatingButton.d.ts +19 -0
- package/dist/cjs/types/components/ErrorBoundary.d.ts +15 -0
- package/dist/cjs/types/components/RobylonChatbot.d.ts +28 -0
- package/dist/cjs/types/config.d.ts +5 -0
- package/dist/cjs/types/constants/errorConstants.d.ts +60 -0
- package/dist/cjs/types/constants/fontStyles.d.ts +4 -0
- package/dist/cjs/types/core/api.d.ts +10 -0
- package/dist/cjs/types/core/config.d.ts +41 -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 +34 -0
- package/dist/cjs/types/hooks/useChatbot.d.ts +2 -0
- package/dist/cjs/types/hooks/useChatbotEvents.d.ts +12 -0
- package/dist/cjs/types/hooks/useChatbotState.d.ts +16 -0
- package/dist/cjs/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
- package/dist/cjs/types/index.d.ts +6 -0
- package/dist/cjs/types/services/ErrorTrackingService.d.ts +38 -0
- package/dist/cjs/types/types/events.d.ts +29 -0
- package/dist/cjs/types/types/state.d.ts +5 -0
- package/dist/cjs/types/types.d.ts +137 -0
- package/dist/cjs/types/utils/chatbotSdk.d.ts +23 -0
- package/dist/cjs/types/utils/colorUtils.d.ts +1 -0
- package/dist/cjs/types/utils/cookieUtils.d.ts +6 -0
- package/dist/cjs/types/utils/environment.d.ts +12 -0
- package/dist/cjs/types/utils/fetchData.d.ts +53 -0
- package/dist/cjs/types/utils/launcherInfo.d.ts +11 -0
- package/dist/cjs/types/utils/logger.d.ts +6 -0
- package/dist/cjs/types/utils/misc.d.ts +1 -0
- package/dist/cjs/types/utils/originalFetchDataFile.d.ts +1 -0
- package/dist/cjs/types/utils/proactive.d.ts +25 -0
- package/dist/cjs/types/utils/sanitize.d.ts +4 -0
- package/dist/cjs/types/utils/systemInfo.d.ts +12 -0
- package/dist/cjs/types/utils/textDirection.d.ts +7 -0
- package/dist/cjs/types/utils/url.d.ts +8 -0
- package/dist/cjs/types/utils/version.d.ts +1 -0
- package/dist/cjs/types/vanilla/components/ChatWidgetPopup.d.ts +17 -0
- package/dist/cjs/types/vanilla/components/ChatbotContainer.d.ts +45 -0
- package/dist/cjs/types/vanilla/components/ChatbotFloatingButton.d.ts +83 -0
- package/dist/cjs/types/vanilla/index.d.ts +42 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/components/ChatWidgetPopup.d.ts +8 -0
- package/dist/esm/types/components/ChatbotContainer/ChatbotContainer.d.ts +15 -0
- package/dist/esm/types/components/ChatbotContainer/index.d.ts +1 -0
- package/dist/esm/types/components/ChatbotFloatingButton.d.ts +19 -0
- package/dist/esm/types/components/ErrorBoundary.d.ts +15 -0
- package/dist/esm/types/components/RobylonChatbot.d.ts +28 -0
- package/dist/esm/types/config.d.ts +5 -0
- package/dist/esm/types/constants/errorConstants.d.ts +60 -0
- package/dist/esm/types/constants/fontStyles.d.ts +4 -0
- package/dist/esm/types/core/api.d.ts +10 -0
- package/dist/esm/types/core/config.d.ts +41 -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 +34 -0
- package/dist/esm/types/hooks/useChatbot.d.ts +2 -0
- package/dist/esm/types/hooks/useChatbotEvents.d.ts +12 -0
- package/dist/esm/types/hooks/useChatbotState.d.ts +16 -0
- package/dist/esm/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
- package/dist/esm/types/index.d.ts +6 -0
- package/dist/esm/types/services/ErrorTrackingService.d.ts +38 -0
- package/dist/esm/types/types/events.d.ts +29 -0
- package/dist/esm/types/types/state.d.ts +5 -0
- package/dist/esm/types/types.d.ts +137 -0
- package/dist/esm/types/utils/chatbotSdk.d.ts +23 -0
- package/dist/esm/types/utils/colorUtils.d.ts +1 -0
- package/dist/esm/types/utils/cookieUtils.d.ts +6 -0
- package/dist/esm/types/utils/environment.d.ts +12 -0
- package/dist/esm/types/utils/fetchData.d.ts +53 -0
- package/dist/esm/types/utils/launcherInfo.d.ts +11 -0
- package/dist/esm/types/utils/logger.d.ts +6 -0
- package/dist/esm/types/utils/misc.d.ts +1 -0
- package/dist/esm/types/utils/originalFetchDataFile.d.ts +1 -0
- package/dist/esm/types/utils/proactive.d.ts +25 -0
- package/dist/esm/types/utils/sanitize.d.ts +4 -0
- package/dist/esm/types/utils/systemInfo.d.ts +12 -0
- package/dist/esm/types/utils/textDirection.d.ts +7 -0
- package/dist/esm/types/utils/url.d.ts +8 -0
- package/dist/esm/types/utils/version.d.ts +1 -0
- package/dist/esm/types/vanilla/components/ChatWidgetPopup.d.ts +17 -0
- package/dist/esm/types/vanilla/components/ChatbotContainer.d.ts +45 -0
- package/dist/esm/types/vanilla/components/ChatbotFloatingButton.d.ts +83 -0
- package/dist/esm/types/vanilla/index.d.ts +42 -0
- package/dist/index.d.ts +235 -0
- package/dist/umd/robylon-chatbot.js +2 -0
- package/dist/umd/robylon-chatbot.js.map +1 -0
- package/dist/umd/types/components/ChatWidgetPopup.d.ts +8 -0
- package/dist/umd/types/components/ChatbotContainer/ChatbotContainer.d.ts +15 -0
- package/dist/umd/types/components/ChatbotContainer/index.d.ts +1 -0
- package/dist/umd/types/components/ChatbotFloatingButton.d.ts +19 -0
- package/dist/umd/types/components/ErrorBoundary.d.ts +15 -0
- package/dist/umd/types/components/RobylonChatbot.d.ts +28 -0
- package/dist/umd/types/config.d.ts +5 -0
- package/dist/umd/types/constants/errorConstants.d.ts +60 -0
- package/dist/umd/types/constants/fontStyles.d.ts +4 -0
- package/dist/umd/types/core/api.d.ts +10 -0
- package/dist/umd/types/core/config.d.ts +41 -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 +34 -0
- package/dist/umd/types/hooks/useChatbot.d.ts +2 -0
- package/dist/umd/types/hooks/useChatbotEvents.d.ts +12 -0
- package/dist/umd/types/hooks/useChatbotState.d.ts +16 -0
- package/dist/umd/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
- package/dist/umd/types/index.d.ts +6 -0
- package/dist/umd/types/services/ErrorTrackingService.d.ts +38 -0
- package/dist/umd/types/types/events.d.ts +29 -0
- package/dist/umd/types/types/state.d.ts +5 -0
- package/dist/umd/types/types.d.ts +137 -0
- package/dist/umd/types/utils/chatbotSdk.d.ts +23 -0
- package/dist/umd/types/utils/colorUtils.d.ts +1 -0
- package/dist/umd/types/utils/cookieUtils.d.ts +6 -0
- package/dist/umd/types/utils/environment.d.ts +12 -0
- package/dist/umd/types/utils/fetchData.d.ts +53 -0
- package/dist/umd/types/utils/launcherInfo.d.ts +11 -0
- package/dist/umd/types/utils/logger.d.ts +6 -0
- package/dist/umd/types/utils/misc.d.ts +1 -0
- package/dist/umd/types/utils/originalFetchDataFile.d.ts +1 -0
- package/dist/umd/types/utils/proactive.d.ts +25 -0
- package/dist/umd/types/utils/sanitize.d.ts +4 -0
- package/dist/umd/types/utils/systemInfo.d.ts +12 -0
- package/dist/umd/types/utils/textDirection.d.ts +7 -0
- package/dist/umd/types/utils/url.d.ts +8 -0
- package/dist/umd/types/utils/version.d.ts +1 -0
- package/dist/umd/types/vanilla/components/ChatWidgetPopup.d.ts +17 -0
- package/dist/umd/types/vanilla/components/ChatbotContainer.d.ts +45 -0
- package/dist/umd/types/vanilla/components/ChatbotFloatingButton.d.ts +83 -0
- package/dist/umd/types/vanilla/index.d.ts +42 -0
- package/package.json +110 -0
package/README.md
ADDED
|
@@ -0,0 +1,736 @@
|
|
|
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
|
+
- [Basic Implementation](#react-basic-implementation)
|
|
10
|
+
- [External Triggers](#react-external-triggers)
|
|
11
|
+
- [Event Handling](#react-event-handling)
|
|
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)
|
|
15
|
+
- [Option 1: Quick Setup - Load with Page](#option-1-quick-setup---load-with-page)
|
|
16
|
+
- [Option 2: Reliable Loading - After DOM is Ready](#option-2-reliable-loading---after-dom-is-ready)
|
|
17
|
+
- [Option 3: User Context - Initialize After User Data](#option-3-user-context---initialize-after-user-data)
|
|
18
|
+
- [Configuration Options](#configuration-options)
|
|
19
|
+
- [Event Handling](#event-handling)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### For React applications:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @robylon/whatsapp-react-sdk
|
|
27
|
+
# or
|
|
28
|
+
yarn add @robylon/whatsapp-react-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### For plain JavaScript and no-code websites:
|
|
32
|
+
|
|
33
|
+
Add this script to your website by copying and pasting the following code into the `<head>` section of your HTML:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<script src="https://cdn.robylon.ai/whatsapp-sdk/latest/chatbot.js"></script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Where to place the script:
|
|
40
|
+
|
|
41
|
+
1. **For website builders (Wix, Squarespace, etc.):**
|
|
42
|
+
|
|
43
|
+
- Find your site editor or dashboard
|
|
44
|
+
- Look for "Custom Code", "Header Code", or "Site Settings" options
|
|
45
|
+
- Paste the script there, usually in a section labeled "Header" or "Head"
|
|
46
|
+
|
|
47
|
+
2. **For custom HTML sites:**
|
|
48
|
+
|
|
49
|
+
- Open your website's HTML file in your editor
|
|
50
|
+
- Find the `<head>` section (it's near the top, between `<html>` and `<body>` tags)
|
|
51
|
+
- Paste the script tag just before the closing `</head>` tag
|
|
52
|
+
|
|
53
|
+
3. **For WordPress:**
|
|
54
|
+
- Go to your WordPress dashboard
|
|
55
|
+
- Navigate to Appearance → Theme Editor or use a header/footer plugin
|
|
56
|
+
- Add the script to the header.php file before the closing `</head>` tag
|
|
57
|
+
|
|
58
|
+
> **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.
|
|
59
|
+
|
|
60
|
+
## React SDK Usage
|
|
61
|
+
|
|
62
|
+
### React: Basic Implementation
|
|
63
|
+
|
|
64
|
+
To use the Robylon SDK in a React application:
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
import { Chatbot } from "@robylon/whatsapp-react-sdk";
|
|
68
|
+
|
|
69
|
+
function App() {
|
|
70
|
+
const handleChatbotEvent = (event) => {
|
|
71
|
+
console.log("Chatbot event:", event.type, event.data);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div className="App">
|
|
76
|
+
<h1>My Website</h1>
|
|
77
|
+
|
|
78
|
+
<Chatbot
|
|
79
|
+
api_key="YOUR_API_KEY"
|
|
80
|
+
user_id="optional-user-id"
|
|
81
|
+
user_token="optional-auth-token"
|
|
82
|
+
user_profile={{
|
|
83
|
+
name: "Optional User Name",
|
|
84
|
+
email: "optional.email@example.com",
|
|
85
|
+
}}
|
|
86
|
+
onEvent={handleChatbotEvent}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default App;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### React: Event Handling
|
|
96
|
+
|
|
97
|
+
The React component accepts an `onEvent` prop for handling chatbot events:
|
|
98
|
+
|
|
99
|
+
```jsx
|
|
100
|
+
<Chatbot
|
|
101
|
+
api_key="YOUR_API_KEY"
|
|
102
|
+
onEvent={(event) => {
|
|
103
|
+
switch (event.type) {
|
|
104
|
+
case "CHATBOT_LOADED":
|
|
105
|
+
console.log("Chatbot loaded");
|
|
106
|
+
break;
|
|
107
|
+
case "CHATBOT_OPENED":
|
|
108
|
+
console.log("Chatbot opened");
|
|
109
|
+
break;
|
|
110
|
+
case "CHATBOT_CLOSED":
|
|
111
|
+
console.log("Chatbot closed");
|
|
112
|
+
break;
|
|
113
|
+
// See the Supported Events section for all available events
|
|
114
|
+
}
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
```
|
|
118
|
+
|
|
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.
|
|
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/whatsapp-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
|
+
|
|
208
|
+
## Plain JavaScript & No-Code Integration
|
|
209
|
+
|
|
210
|
+
> **IMPORTANT:** You will need an API key from Robylon for any integration to work.
|
|
211
|
+
|
|
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/whatsapp-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/whatsapp-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/whatsapp-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/whatsapp-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:
|
|
265
|
+
|
|
266
|
+
### Option 1: Quick Setup - Load with Page
|
|
267
|
+
|
|
268
|
+
This is the simplest approach for any website. The chatbot loads while the page is loading but doesn't block the page from appearing.
|
|
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/whatsapp-sdk/latest/robylon-chatbot.js"
|
|
277
|
+
defer
|
|
278
|
+
></script>
|
|
279
|
+
<script>
|
|
280
|
+
// Initialize when page is ready
|
|
281
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
282
|
+
RobylonChatbot.create({
|
|
283
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
284
|
+
user_id: "optional-user-id", // Optional: remove if not needed
|
|
285
|
+
user_profile: {
|
|
286
|
+
name: "Optional User Name", // Optional: remove if not needed
|
|
287
|
+
email: "optional.email@example.com", // Optional: remove if not needed
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
</script>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### Complete example:
|
|
295
|
+
|
|
296
|
+
```html
|
|
297
|
+
<!DOCTYPE html>
|
|
298
|
+
<html>
|
|
299
|
+
<head>
|
|
300
|
+
<title>Robylon SDK - Quick Setup</title>
|
|
301
|
+
<!-- COPY FROM HERE -->
|
|
302
|
+
<script
|
|
303
|
+
src="https://cdn.robylon.ai/whatsapp-sdk/latest/robylon-chatbot.js"
|
|
304
|
+
defer
|
|
305
|
+
></script>
|
|
306
|
+
<script>
|
|
307
|
+
// Initialize when page is ready
|
|
308
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
309
|
+
RobylonChatbot.create({
|
|
310
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
311
|
+
user_id: "optional-user-id", // Optional: remove if not needed
|
|
312
|
+
user_profile: {
|
|
313
|
+
name: "Optional User Name", // Optional: remove if not needed
|
|
314
|
+
email: "optional.email@example.com", // Optional: remove if not needed
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
</script>
|
|
319
|
+
<!-- COPY UNTIL HERE -->
|
|
320
|
+
</head>
|
|
321
|
+
<body>
|
|
322
|
+
<h1>Your Website Content</h1>
|
|
323
|
+
<!-- Your website content here -->
|
|
324
|
+
</body>
|
|
325
|
+
</html>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Option 2: Reliable Loading - After DOM is Ready
|
|
329
|
+
|
|
330
|
+
This approach ensures the chatbot only initializes after your page is fully loaded, making it more reliable for websites with complex layouts.
|
|
331
|
+
|
|
332
|
+
#### What to copy:
|
|
333
|
+
|
|
334
|
+
1️⃣ **Add this to your HTML `<head>` section:**
|
|
335
|
+
|
|
336
|
+
```html
|
|
337
|
+
<script src="https://cdn.robylon.ai/whatsapp-sdk/latest/robylon-chatbot.js"></script>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
2️⃣ **Add this at the end of your HTML `<body>` section:**
|
|
341
|
+
|
|
342
|
+
```html
|
|
343
|
+
<script>
|
|
344
|
+
// Wait for page to be fully loaded before showing chatbot
|
|
345
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
346
|
+
RobylonChatbot.create({
|
|
347
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
348
|
+
user_id: "optional-user-id", // Optional: remove if not needed
|
|
349
|
+
user_profile: {
|
|
350
|
+
name: "Optional User Name", // Optional: remove if not needed
|
|
351
|
+
email: "optional.email@example.com", // Optional: remove if not needed
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
</script>
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
#### Complete example:
|
|
359
|
+
|
|
360
|
+
```html
|
|
361
|
+
<!DOCTYPE html>
|
|
362
|
+
<html>
|
|
363
|
+
<head>
|
|
364
|
+
<title>Robylon SDK - Reliable Loading</title>
|
|
365
|
+
<!-- COPY FROM HERE -->
|
|
366
|
+
<script src="https://cdn.robylon.ai/whatsapp-sdk/latest/robylon-chatbot.js"></script>
|
|
367
|
+
<!-- COPY UNTIL HERE -->
|
|
368
|
+
</head>
|
|
369
|
+
<body>
|
|
370
|
+
<h1>Your Website Content</h1>
|
|
371
|
+
<!-- Your website content here -->
|
|
372
|
+
|
|
373
|
+
<script>
|
|
374
|
+
// Wait for page to be fully loaded before showing chatbot
|
|
375
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
376
|
+
RobylonChatbot.create({
|
|
377
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
378
|
+
user_id: "optional-user-id", // Optional: remove if not needed
|
|
379
|
+
user_profile: {
|
|
380
|
+
name: "Optional User Name", // Optional: remove if not needed
|
|
381
|
+
email: "optional.email@example.com", // Optional: remove if not needed
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
</script>
|
|
386
|
+
</body>
|
|
387
|
+
</html>
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Option 3: User Context - Initialize After User Data
|
|
391
|
+
|
|
392
|
+
This approach loads the chatbot after user data is available. Great for websites where you want to personalize the chat experience.
|
|
393
|
+
|
|
394
|
+
#### What to copy:
|
|
395
|
+
|
|
396
|
+
1️⃣ **Add this to your HTML `<head>` section:**
|
|
397
|
+
|
|
398
|
+
```html
|
|
399
|
+
<script
|
|
400
|
+
src="https://cdn.robylon.ai/whatsapp-sdk/latest/robylon-chatbot.js"
|
|
401
|
+
defer
|
|
402
|
+
></script>
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
2️⃣ **Add this script at the end of your HTML `<body>` section:**
|
|
406
|
+
|
|
407
|
+
```html
|
|
408
|
+
<script>
|
|
409
|
+
// Wait for page to be ready
|
|
410
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
411
|
+
// Get your user data (replace this with your own method)
|
|
412
|
+
getUserData().then((user) => {
|
|
413
|
+
// Initialize chatbot with user info
|
|
414
|
+
RobylonChatbot.create({
|
|
415
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
416
|
+
user_id: user.id,
|
|
417
|
+
user_profile: {
|
|
418
|
+
name: user.name,
|
|
419
|
+
email: user.email,
|
|
420
|
+
},
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Example function to get user data - replace with your own
|
|
426
|
+
function getUserData() {
|
|
427
|
+
// This is just a placeholder - replace with your actual code
|
|
428
|
+
return Promise.resolve({
|
|
429
|
+
id: "user123",
|
|
430
|
+
name: "Jane Smith",
|
|
431
|
+
email: "jane@example.com",
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
</script>
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
#### Complete example:
|
|
438
|
+
|
|
439
|
+
```html
|
|
440
|
+
<!DOCTYPE html>
|
|
441
|
+
<html>
|
|
442
|
+
<head>
|
|
443
|
+
<title>My Website</title>
|
|
444
|
+
<!-- COPY FROM HERE -->
|
|
445
|
+
<script
|
|
446
|
+
src="https://cdn.robylon.ai/whatsapp-sdk/latest/robylon-chatbot.js"
|
|
447
|
+
defer
|
|
448
|
+
></script>
|
|
449
|
+
<!-- COPY UNTIL HERE -->
|
|
450
|
+
</head>
|
|
451
|
+
<body>
|
|
452
|
+
<h1>Your Website Content</h1>
|
|
453
|
+
<!-- Your website content here -->
|
|
454
|
+
|
|
455
|
+
<!-- COPY FROM HERE -->
|
|
456
|
+
<script>
|
|
457
|
+
// Wait for page to be ready
|
|
458
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
459
|
+
// Get your user data (replace this with your own method)
|
|
460
|
+
getUserData().then((user) => {
|
|
461
|
+
// Initialize chatbot with user info
|
|
462
|
+
RobylonChatbot.create({
|
|
463
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
464
|
+
user_id: user.id,
|
|
465
|
+
user_profile: {
|
|
466
|
+
name: user.name,
|
|
467
|
+
email: user.email,
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// Example function to get user data - replace with your own
|
|
474
|
+
function getUserData() {
|
|
475
|
+
// This is just a placeholder - replace with your actual code
|
|
476
|
+
return Promise.resolve({
|
|
477
|
+
id: "user123",
|
|
478
|
+
name: "Jane Smith",
|
|
479
|
+
email: "jane@example.com",
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
</script>
|
|
483
|
+
<!-- COPY UNTIL HERE -->
|
|
484
|
+
</body>
|
|
485
|
+
</html>
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Plain JS & No-Code: Event Handling
|
|
489
|
+
|
|
490
|
+
You can handle chatbot events in plain JavaScript using the `onEvent` callback:
|
|
491
|
+
|
|
492
|
+
#### What to copy:
|
|
493
|
+
|
|
494
|
+
```javascript
|
|
495
|
+
const chatbot = RobylonChatbot.create({
|
|
496
|
+
api_key: "YOUR_API_KEY", // Replace with your actual API key
|
|
497
|
+
onEvent: function (event) {
|
|
498
|
+
switch (event.type) {
|
|
499
|
+
case "CHATBOT_LOADED":
|
|
500
|
+
console.log("Chatbot loaded");
|
|
501
|
+
break;
|
|
502
|
+
case "CHATBOT_OPENED":
|
|
503
|
+
console.log("Chatbot opened");
|
|
504
|
+
break;
|
|
505
|
+
case "CHATBOT_CLOSED":
|
|
506
|
+
console.log("Chatbot closed");
|
|
507
|
+
break;
|
|
508
|
+
// See the Supported Events section for all available events
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// The chatbot instance provides methods to control the chatbot
|
|
514
|
+
// chatbot.show(); // Show the chatbot
|
|
515
|
+
// chatbot.hide(); // Hide the chatbot
|
|
516
|
+
// chatbot.toggle(); // Toggle visibility
|
|
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).
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
## Configuration Options
|
|
523
|
+
|
|
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
|
+
| launcher_size | number | Override button size in pixels (default: 48px) | Optional |
|
|
538
|
+
| overrides | object | Customize chatbot header appearance | Optional |
|
|
539
|
+
|
|
540
|
+
### Position and Spacing Configuration
|
|
541
|
+
|
|
542
|
+
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.
|
|
543
|
+
|
|
544
|
+
#### React Example:
|
|
545
|
+
|
|
546
|
+
```jsx
|
|
547
|
+
<Chatbot
|
|
548
|
+
api_key="YOUR_API_KEY"
|
|
549
|
+
position="Left"
|
|
550
|
+
sideSpacing={30}
|
|
551
|
+
bottomSpacing={25}
|
|
552
|
+
launcher_size={64}
|
|
553
|
+
/>
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
#### React: Hide Floating Launcher Button
|
|
557
|
+
|
|
558
|
+
To hide the floating launcher and manage visibility via external triggers or custom UI, set `show_launcher` to `false` (defaults to `true`):
|
|
559
|
+
|
|
560
|
+
```jsx
|
|
561
|
+
<Chatbot api_key="YOUR_API_KEY" show_launcher={false} />
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
#### Plain JavaScript Example:
|
|
565
|
+
|
|
566
|
+
```javascript
|
|
567
|
+
RobylonChatbot.create({
|
|
568
|
+
api_key: "YOUR_API_KEY",
|
|
569
|
+
position: "Left",
|
|
570
|
+
sideSpacing: 30,
|
|
571
|
+
bottomSpacing: 25,
|
|
572
|
+
launcher_size: 64,
|
|
573
|
+
});
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Launcher Size Configuration
|
|
577
|
+
|
|
578
|
+
The `launcher_size` prop allows you to customize the size of the floating button. This is useful for matching your design requirements or creating more prominent call-to-action buttons.
|
|
579
|
+
|
|
580
|
+
#### React Example:
|
|
581
|
+
|
|
582
|
+
```jsx
|
|
583
|
+
<Chatbot api_key="YOUR_API_KEY" launcher_size={64} />
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
#### Plain JavaScript Example:
|
|
587
|
+
|
|
588
|
+
```javascript
|
|
589
|
+
RobylonChatbot.create({
|
|
590
|
+
api_key: "YOUR_API_KEY",
|
|
591
|
+
launcher_size: 64, // Override default 48 button size
|
|
592
|
+
});
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
**Notes:**
|
|
596
|
+
|
|
597
|
+
- Default size is 48 if not specified
|
|
598
|
+
- Only applies to IMAGE launcher type (TEXT and TEXTUAL_IMAGE launchers have fixed heights)
|
|
599
|
+
- Size is specified in pixels
|
|
600
|
+
- Affects both button width and height (creates square button)
|
|
601
|
+
|
|
602
|
+
### Overrides Configuration
|
|
603
|
+
|
|
604
|
+
The `overrides` prop allows you to customize the chatbot header appearance, including avatars, titles, and styling. This is useful for branding or personalizing the chatbot interface.
|
|
605
|
+
|
|
606
|
+
#### Overrides Options
|
|
607
|
+
|
|
608
|
+
| Option | Type | Description |
|
|
609
|
+
| ---------------------------- | ------ | ------------------------------------------ |
|
|
610
|
+
| `header_avatar` | string | URL for the header avatar image |
|
|
611
|
+
| `agent_avatar` | string | URL for the agent avatar image |
|
|
612
|
+
| `header_title` | string | Custom header title text |
|
|
613
|
+
| `header_subtitle` | string | Custom header subtitle text |
|
|
614
|
+
| `header_title_text_color` | string | CSS color value for the title text |
|
|
615
|
+
| `header_subtitle_text_color` | string | CSS color value for the subtitle text |
|
|
616
|
+
| `header_bg` | string | CSS color or URL for the header background |
|
|
617
|
+
|
|
618
|
+
#### React Example:
|
|
619
|
+
|
|
620
|
+
```jsx
|
|
621
|
+
<Chatbot
|
|
622
|
+
api_key="YOUR_API_KEY"
|
|
623
|
+
overrides={{
|
|
624
|
+
header_avatar: "https://example.com/header-avatar.png",
|
|
625
|
+
agent_avatar: "https://example.com/agent-avatar.png",
|
|
626
|
+
header_title: "Support Team",
|
|
627
|
+
header_subtitle: "We're here to help",
|
|
628
|
+
header_title_text_color: "#1a1a1a",
|
|
629
|
+
header_subtitle_text_color: "#666666",
|
|
630
|
+
header_bg: "#ffffff",
|
|
631
|
+
}}
|
|
632
|
+
/>
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
#### React: Partial Overrides
|
|
636
|
+
|
|
637
|
+
You can provide only the overrides you want to customize. Omitted properties will use their default values:
|
|
638
|
+
|
|
639
|
+
```jsx
|
|
640
|
+
<Chatbot
|
|
641
|
+
api_key="YOUR_API_KEY"
|
|
642
|
+
overrides={{
|
|
643
|
+
header_title: "Custom Title",
|
|
644
|
+
header_title_text_color: "#007bff",
|
|
645
|
+
}}
|
|
646
|
+
/>
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
#### Plain JavaScript Example:
|
|
650
|
+
|
|
651
|
+
```javascript
|
|
652
|
+
RobylonChatbot.create({
|
|
653
|
+
api_key: "YOUR_API_KEY",
|
|
654
|
+
overrides: {
|
|
655
|
+
header_avatar: "https://example.com/header-avatar.png",
|
|
656
|
+
agent_avatar: "https://example.com/agent-avatar.png",
|
|
657
|
+
header_title: "Support Team",
|
|
658
|
+
header_subtitle: "We're here to help",
|
|
659
|
+
header_title_text_color: "#1a1a1a",
|
|
660
|
+
header_subtitle_text_color: "#666666",
|
|
661
|
+
header_bg: "#ffffff",
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
#### Plain JavaScript: Updating Overrides
|
|
667
|
+
|
|
668
|
+
To update overrides after initialization, you'll need to recreate the chatbot instance with new overrides:
|
|
669
|
+
|
|
670
|
+
```javascript
|
|
671
|
+
let chatbot = RobylonChatbot.create({
|
|
672
|
+
api_key: "YOUR_API_KEY",
|
|
673
|
+
overrides: {
|
|
674
|
+
header_title: "Initial Title",
|
|
675
|
+
},
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
// Later, destroy and recreate with new overrides
|
|
679
|
+
chatbot.destroy();
|
|
680
|
+
chatbot = RobylonChatbot.create({
|
|
681
|
+
api_key: "YOUR_API_KEY",
|
|
682
|
+
overrides: {
|
|
683
|
+
header_title: "Updated Title",
|
|
684
|
+
header_title_text_color: "#ff0000",
|
|
685
|
+
},
|
|
686
|
+
});
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
#### Color Format Examples
|
|
690
|
+
|
|
691
|
+
Colors can be specified in any valid CSS color format:
|
|
692
|
+
|
|
693
|
+
```jsx
|
|
694
|
+
<Chatbot
|
|
695
|
+
api_key="YOUR_API_KEY"
|
|
696
|
+
overrides={{
|
|
697
|
+
// Hex color
|
|
698
|
+
header_title_text_color: "#1a1a1a",
|
|
699
|
+
// RGB
|
|
700
|
+
header_subtitle_text_color: "rgb(102, 102, 102)",
|
|
701
|
+
// RGBA
|
|
702
|
+
header_bg: "rgba(255, 255, 255, 0.95)",
|
|
703
|
+
// Named color
|
|
704
|
+
header_title_text_color: "navy",
|
|
705
|
+
}}
|
|
706
|
+
/>
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
## Event Handling
|
|
710
|
+
|
|
711
|
+
### Supported Events
|
|
712
|
+
|
|
713
|
+
The SDK emits the following events that you can listen for in both React and plain JavaScript implementations:
|
|
714
|
+
|
|
715
|
+
| Event Type | Description | Data |
|
|
716
|
+
| ---------------------------- | ----------------------------------------------- | ---------------------------------------- |
|
|
717
|
+
| `CHATBOT_BUTTON_LOADED` | The chatbot button has been loaded and rendered | - |
|
|
718
|
+
| `CHATBOT_LOADED` | The chatbot iframe has been loaded | - |
|
|
719
|
+
| `CHATBOT_OPENED` | The chatbot has been opened | - |
|
|
720
|
+
| `CHATBOT_CLOSED` | The chatbot has been closed | - |
|
|
721
|
+
| `CHATBOT_READY` | The chatbot is ready for external control | - |
|
|
722
|
+
| `CHAT_INITIALIZED` | The chat session has been initialized | - |
|
|
723
|
+
| `CHAT_INITIALIZATION_FAILED` | The chat session failed to initialize | `{ error: string }` |
|
|
724
|
+
| `SESSION_REFRESHED` | The chat session has been refreshed | - |
|
|
725
|
+
| `MESSAGE_SENT` | User has sent a message | `{ message: string }` |
|
|
726
|
+
| `MESSAGE_RECEIVED` | A message was received from the chatbot | `{ message: string }` |
|
|
727
|
+
| `CONVERSATION_STARTED` | A new conversation has started | `{ conversationId: string }` |
|
|
728
|
+
| `CONVERSATION_ENDED` | The current conversation has ended | `{ conversationId: string }` |
|
|
729
|
+
| `USER_AUTHENTICATED` | The user has been authenticated | `{ userId: string }` |
|
|
730
|
+
| `USER_PROFILE_UPDATED` | The user profile has been updated | `{ profile: object }` |
|
|
731
|
+
| `USER_FEEDBACK_SUBMITTED` | The user has submitted feedback | `{ rating: number, comment: string }` |
|
|
732
|
+
| `FILE_UPLOAD_STARTED` | A file upload has started | `{ fileName: string, fileSize: number }` |
|
|
733
|
+
| `FILE_UPLOAD_COMPLETED` | A file upload has completed | `{ fileName: string, fileUrl: string }` |
|
|
734
|
+
| `FILE_UPLOAD_FAILED` | A file upload has failed | `{ fileName: string, error: string }` |
|
|
735
|
+
|
|
736
|
+
| `CHATBOT_ERROR`
|