@robylon/react-native-sdk 2.0.23-staging.3 → 2.0.25-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.
- package/README.md +163 -8
- package/lib/commonjs/constants.js +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/openChatbot.js +2 -1
- package/lib/commonjs/versions/version.staging.js +1 -1
- package/lib/module/constants.js +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/openChatbot.js.map +1 -1
- package/lib/module/versions/version.staging.js +1 -1
- package/lib/typescript/versions/version.staging.d.ts +1 -1
- package/package.json +1 -1
- package/src/versions/version.staging.ts +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,20 @@ npm install @robylon/react-native-sdk react-native-webview
|
|
|
12
12
|
yarn add @robylon/react-native-sdk react-native-webview
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Available Exports
|
|
16
|
+
|
|
17
|
+
The SDK exports the following types and components:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import {
|
|
21
|
+
Chatbot, // Main chatbot component
|
|
22
|
+
ChatbotRef, // Ref interface for imperative control
|
|
23
|
+
ChatbotProps, // Props interface
|
|
24
|
+
ChatbotEventType, // Event types enum
|
|
25
|
+
ChatbotEventHandler, // Event handler type
|
|
26
|
+
} from "@robylon/react-native-sdk";
|
|
27
|
+
```
|
|
28
|
+
|
|
15
29
|
## Prerequisites
|
|
16
30
|
|
|
17
31
|
- React Native project
|
|
@@ -25,7 +39,7 @@ yarn add @robylon/react-native-sdk react-native-webview
|
|
|
25
39
|
```typescript
|
|
26
40
|
import React from "react";
|
|
27
41
|
import { View } from "react-native";
|
|
28
|
-
import { Chatbot } from "@robylon/react-native-sdk";
|
|
42
|
+
import { Chatbot, ChatbotRef } from "@robylon/react-native-sdk";
|
|
29
43
|
|
|
30
44
|
const App = () => {
|
|
31
45
|
return (
|
|
@@ -60,12 +74,15 @@ export default App;
|
|
|
60
74
|
|
|
61
75
|
### Optional Props
|
|
62
76
|
|
|
63
|
-
| Prop | Type
|
|
64
|
-
| -------------- |
|
|
65
|
-
| `user_id` | string \| null \| number
|
|
66
|
-
| `user_token` | string
|
|
67
|
-
| `user_profile` | { email?: string; name?: string; mobile?: string; } | User profile information |
|
|
68
|
-
| `onEvent` | ChatbotEventHandler
|
|
77
|
+
| Prop | Type | Description |
|
|
78
|
+
| -------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
79
|
+
| `user_id` | string \| null \| number | Unique identifier for the user. If not provided, an anonymous ID will be generated |
|
|
80
|
+
| `user_token` | string | Authentication token for the user |
|
|
81
|
+
| `user_profile` | { email?: string; name?: string; mobile?: string; is_test_user?: boolean; } | User profile information |
|
|
82
|
+
| `onEvent` | ChatbotEventHandler | Callback for chatbot events |
|
|
83
|
+
| `onOpen` | () => void | Callback when chatbot opens |
|
|
84
|
+
| `onClose` | () => void | Callback when chatbot closes |
|
|
85
|
+
| `onReady` | () => void | Callback when chatbot is fully initialized and ready for external triggers |
|
|
69
86
|
|
|
70
87
|
### User Profile Properties
|
|
71
88
|
|
|
@@ -74,6 +91,135 @@ The `user_profile` object can include:
|
|
|
74
91
|
- `email`: User's email address (optional)
|
|
75
92
|
- `name`: User's full name (optional)
|
|
76
93
|
- `mobile`: User's mobile number (optional)
|
|
94
|
+
- `is_test_user`: Mark user as test user for development/testing purposes (optional)
|
|
95
|
+
|
|
96
|
+
## External Trigger API
|
|
97
|
+
|
|
98
|
+
The SDK now supports external triggering of the chatbot through both controlled component patterns and imperative ref methods.
|
|
99
|
+
|
|
100
|
+
### Ref-based Imperative API
|
|
101
|
+
|
|
102
|
+
You can control the chatbot programmatically using a ref:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import React, { useRef } from "react";
|
|
106
|
+
import { View, Button } from "react-native";
|
|
107
|
+
import { Chatbot, ChatbotRef } from "@robylon/react-native-sdk";
|
|
108
|
+
|
|
109
|
+
const App = () => {
|
|
110
|
+
const chatbotRef = useRef<ChatbotRef>(null);
|
|
111
|
+
|
|
112
|
+
const handleCustomButtonPress = () => {
|
|
113
|
+
if (chatbotRef.current?.isReady()) {
|
|
114
|
+
chatbotRef.current.open();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleToggle = () => {
|
|
119
|
+
chatbotRef.current?.toggle();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const handleClose = () => {
|
|
123
|
+
chatbotRef.current?.close();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<View>
|
|
128
|
+
<Button title="Open Chat" onPress={handleCustomButtonPress} />
|
|
129
|
+
<Button title="Toggle Chat" onPress={handleToggle} />
|
|
130
|
+
<Button title="Close Chat" onPress={handleClose} />
|
|
131
|
+
|
|
132
|
+
<Chatbot
|
|
133
|
+
ref={chatbotRef}
|
|
134
|
+
api_key="YOUR_API_KEY"
|
|
135
|
+
show_floating_button={false} // Hide default button
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Ref Methods
|
|
143
|
+
|
|
144
|
+
| Method | Description |
|
|
145
|
+
| ----------- | ----------------------------------------------- |
|
|
146
|
+
| `open()` | Programmatically open the chatbot |
|
|
147
|
+
| `close()` | Programmatically close the chatbot |
|
|
148
|
+
| `toggle()` | Toggle chatbot visibility |
|
|
149
|
+
| `isReady()` | Check if chatbot is ready for external triggers |
|
|
150
|
+
|
|
151
|
+
### Callback Props
|
|
152
|
+
|
|
153
|
+
| Prop | Type | Description |
|
|
154
|
+
| --------- | ---------- | ---------------------------------------- |
|
|
155
|
+
| `onOpen` | () => void | Called when chatbot opens |
|
|
156
|
+
| `onClose` | () => void | Called when chatbot closes |
|
|
157
|
+
| `onReady` | () => void | Called when chatbot is fully initialized |
|
|
158
|
+
|
|
159
|
+
## Advanced Usage Examples
|
|
160
|
+
|
|
161
|
+
### Custom UI Integration
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import React, { useRef, useState } from "react";
|
|
165
|
+
import { View, Button } from "react-native";
|
|
166
|
+
import { Chatbot, ChatbotRef } from "@robylon/react-native-sdk";
|
|
167
|
+
|
|
168
|
+
const App = () => {
|
|
169
|
+
const chatbotRef = useRef<ChatbotRef>(null);
|
|
170
|
+
const [isReady, setIsReady] = useState(false);
|
|
171
|
+
|
|
172
|
+
const handleCustomButtonPress = () => {
|
|
173
|
+
if (isReady) {
|
|
174
|
+
chatbotRef.current?.open();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const handleDeepLink = () => {
|
|
179
|
+
// Programmatic control for deep links, notifications, etc.
|
|
180
|
+
chatbotRef.current?.open();
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<View>
|
|
185
|
+
<Button
|
|
186
|
+
title="Open Support Chat"
|
|
187
|
+
onPress={handleCustomButtonPress}
|
|
188
|
+
disabled={!isReady}
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
<Button
|
|
192
|
+
title="Deep Link Trigger"
|
|
193
|
+
onPress={handleDeepLink}
|
|
194
|
+
disabled={!isReady}
|
|
195
|
+
/>
|
|
196
|
+
|
|
197
|
+
<Chatbot
|
|
198
|
+
ref={chatbotRef}
|
|
199
|
+
api_key="YOUR_API_KEY"
|
|
200
|
+
onReady={() => setIsReady(true)}
|
|
201
|
+
onOpen={() => console.log("Chatbot opened")}
|
|
202
|
+
onClose={() => console.log("Chatbot closed")}
|
|
203
|
+
show_floating_button={true} // Keep default button too
|
|
204
|
+
/>
|
|
205
|
+
</View>
|
|
206
|
+
);
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Safety Features
|
|
211
|
+
|
|
212
|
+
- All external triggers are blocked until the chatbot is fully initialized
|
|
213
|
+
- The `onReady` callback ensures safe timing for external actions
|
|
214
|
+
- Ref methods include safety checks to prevent premature calls
|
|
215
|
+
|
|
216
|
+
### Use Cases
|
|
217
|
+
|
|
218
|
+
- Custom UI integration
|
|
219
|
+
- Conditional triggers (form errors, help requests)
|
|
220
|
+
- Programmatic control (deep links, notifications)
|
|
221
|
+
- A/B testing different trigger mechanisms
|
|
222
|
+
- Accessibility improvements
|
|
77
223
|
|
|
78
224
|
### Automatically Collected Information
|
|
79
225
|
|
|
@@ -164,20 +310,29 @@ errorTracker.initialize(api_key, user_id);
|
|
|
164
310
|
|
|
165
311
|
- Provide `user_id` when possible for consistent user experience
|
|
166
312
|
- Let the SDK handle anonymous users when no ID is available
|
|
313
|
+
- Use `is_test_user` flag in user profile for development/testing
|
|
167
314
|
|
|
168
315
|
2. **Event Handling**:
|
|
169
316
|
|
|
170
317
|
- Implement the `onEvent` handler for important user interactions
|
|
171
318
|
- Use events for analytics and user experience tracking
|
|
319
|
+
- Use `onReady` callback to ensure chatbot is initialized before external triggers
|
|
172
320
|
|
|
173
321
|
3. **User Profile**:
|
|
174
322
|
|
|
175
323
|
- Provide relevant user information in `user_profile`
|
|
176
324
|
- Update user profile when information changes
|
|
177
325
|
|
|
178
|
-
4. **
|
|
326
|
+
4. **External Triggers**:
|
|
327
|
+
|
|
328
|
+
- Always check `isReady()` before calling ref methods
|
|
329
|
+
- Use `onReady` callback to enable custom trigger buttons
|
|
330
|
+
- Implement proper error handling for external trigger scenarios
|
|
331
|
+
|
|
332
|
+
5. **Error Handling**:
|
|
179
333
|
- Monitor for error events in development
|
|
180
334
|
- Implement appropriate fallbacks for error cases
|
|
335
|
+
- Handle cases where external triggers are called before initialization
|
|
181
336
|
|
|
182
337
|
## Support
|
|
183
338
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_LAUNCHER_IMAGE=exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_LAUNCHER_IMAGE=exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"http://192.168.1.92"||"";var CHATBOT_PATH=process&&process.env&&process.env.CHATBOT_PATH||"chatbot-plugin"||"";var BASE_CHATBOT_URL=exports.BASE_CHATBOT_URL=`${BASE_CHATBOT_DOMAIN}/${CHATBOT_PATH}`;var API_URL=exports.API_URL=process&&process.env&&process.env.API_URL||"https://stage-api.robylon.ai";var DEFAULT_LAUNCHER_IMAGE=exports.DEFAULT_LAUNCHER_IMAGE=`${BASE_CHATBOT_DOMAIN}/chatbubble.png`;
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL","DEFAULT_LAUNCHER_IMAGE"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"wIAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,
|
|
1
|
+
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL","DEFAULT_LAUNCHER_IMAGE"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"wIAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,yBAA8B,EAAE,CAC5D,GAAM,CAAAC,YAAY,CAAGJ,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAE,YAAA,oBAA4B,EAAE,CAC5C,GAAM,CAAAC,gBAAgB,CAAAC,OAAA,CAAAD,gBAAA,CAAG,GAAGN,mBAAmB,IAAIK,YAAY,EAAE,CACjE,GAAM,CAAAG,OAAO,CAAAD,OAAA,CAAAC,OAAA,CAAAP,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAK,OAAA,gCAAsB,CACnC,GAAM,CAAAC,sBAAsB,CAAAF,OAAA,CAAAE,sBAAA,CAAG,GAAGT,mBAAmB,iBAAiB","ignoreList":[]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//# sourceMappingURL=openChatbot.js.mape",{value:true});exports.openChatbot=void 0;var _reactNative=require("react-native");var _constants=require("./constants");var openChatbot=exports.openChatbot=function openChatbot(chatbotId){var additionalParams=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=new URLSearchParams(Object.assign({id:chatbotId},additionalParams));var url=`${_constants.BASE_CHATBOT_URL}?${params.toString()}`;_reactNative.Linking.openURL(url);};
|
|
2
3
|
//# sourceMappingURL=openChatbot.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.25-staging.0';
|
|
2
2
|
//# sourceMappingURL=version.staging.js.map
|
package/lib/module/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_LAUNCHER_IMAGE=exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_LAUNCHER_IMAGE=exports.BASE_CHATBOT_URL=exports.API_URL=void 0;var BASE_CHATBOT_DOMAIN=process&&process.env&&process.env.CHATBOT_DOMAIN||"http://192.168.1.92"||"";var CHATBOT_PATH=process&&process.env&&process.env.CHATBOT_PATH||"chatbot-plugin"||"";var BASE_CHATBOT_URL=exports.BASE_CHATBOT_URL=`${BASE_CHATBOT_DOMAIN}/${CHATBOT_PATH}`;var API_URL=exports.API_URL=process&&process.env&&process.env.API_URL||"https://stage-api.robylon.ai";var DEFAULT_LAUNCHER_IMAGE=exports.DEFAULT_LAUNCHER_IMAGE=`${BASE_CHATBOT_DOMAIN}/chatbubble.png`;
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL","DEFAULT_LAUNCHER_IMAGE"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"wIAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,
|
|
1
|
+
{"version":3,"names":["BASE_CHATBOT_DOMAIN","process","env","process.env","CHATBOT_DOMAIN","CHATBOT_PATH","BASE_CHATBOT_URL","exports","API_URL","DEFAULT_LAUNCHER_IMAGE"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"wIAAA,GAAM,CAAAA,mBAAmB,CAAGC,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAC,cAAA,yBAA8B,EAAE,CAC5D,GAAM,CAAAC,YAAY,CAAGJ,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAE,YAAA,oBAA4B,EAAE,CAC5C,GAAM,CAAAC,gBAAgB,CAAAC,OAAA,CAAAD,gBAAA,CAAG,GAAGN,mBAAmB,IAAIK,YAAY,EAAE,CACjE,GAAM,CAAAG,OAAO,CAAAD,OAAA,CAAAC,OAAA,CAAAP,OAAA,EAAAA,OAAA,CAAAC,GAAA,EAAAC,WAAA,CAAAK,OAAA,gCAAsB,CACnC,GAAM,CAAAC,sBAAsB,CAAAF,OAAA,CAAAE,sBAAA,CAAG,GAAGT,mBAAmB,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["openChatbot.
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_constants","openChatbot","exports","chatbotId","additionalParams","arguments","length","undefined","params","URLSearchParams","Object","assign","id","url","BASE_CHATBOT_URL","toString","Linking","openURL"],"sourceRoot":"../../src","sources":["openChatbot.ts"],"mappings":"oFAAA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,UAAA,CAAAD,OAAA,gBAEO,GAAM,CAAAE,WAAW,CAAAC,OAAA,CAAAD,WAAA,CAAG,QAAd,CAAAA,WAAWA,CACtBE,SAAiB,CAER,IADT,CAAAC,gBAAwC,CAAAC,SAAA,CAAAC,MAAA,IAAAD,SAAA,MAAAE,SAAA,CAAAF,SAAA,IAAG,CAAC,CAAC,CAE7C,GAAM,CAAAG,MAAM,CAAG,GAAI,CAAAC,eAAe,CAAAC,MAAA,CAAAC,MAAA,EAAGC,EAAE,CAAET,SAAS,EAAKC,gBAAgB,CAAE,CAAC,CAC1E,GAAM,CAAAS,GAAG,CAAG,GAAGC,2BAAgB,IAAIN,MAAM,CAACO,QAAQ,CAAC,CAAC,EAAE,CACtDC,oBAAO,CAACC,OAAO,CAACJ,GAAG,CAAC,CACtB,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;var SDK_VERSION=exports.SDK_VERSION='2.0.25-staging.0';
|
|
2
2
|
//# sourceMappingURL=version.staging.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.25-staging.0";
|
|
2
2
|
//# sourceMappingURL=version.staging.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not modify it manually.
|
|
2
|
-
export const SDK_VERSION = '2.0.
|
|
2
|
+
export const SDK_VERSION = '2.0.25-staging.0';
|