@robylon/web-react-sdk 1.1.28-staging.7 → 1.1.30-staging.0

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