@@ -5,15 +5,15 @@ import { InputValidatorBlock } from "./types/InputValidatorBlock";
5
5
import { validateFile } from "./utils/validateFile" ;
6
6
7
7
const App = ( ) => {
8
- // initialize example plugin
8
+ // Initialize the plugin
9
9
const plugins = [ RcbPlugin ( ) ] ;
10
10
11
- // example flow for testing
11
+ // Example flow for testing
12
12
const flow : Flow = {
13
13
start : {
14
14
message : "Hey there! Please enter your age." ,
15
15
path : "age_validation" ,
16
- validateInput : ( userInput ?: string ) => {
16
+ validateTextInput : ( userInput ?: string ) => {
17
17
if ( userInput && ! Number . isNaN ( Number ( userInput ) ) ) {
18
18
return { success : true } ;
19
19
}
@@ -28,23 +28,23 @@ const App = () => {
28
28
} as InputValidatorBlock ,
29
29
30
30
age_validation : {
31
- message : "Great! Now please upload a profile picture (JPEG or PNG)." ,
31
+ message :
32
+ "Great! Now please upload a profile picture (JPEG or PNG) or provide a URL." ,
32
33
path : "file_upload_validation" ,
33
- validateInput : ( userInput ?: string ) => {
34
- console . log ( "validateInput called with userInput:" , userInput ) ;
34
+ chatDisabled : true , // Set to true if you want to disable text input
35
+ validateTextInput : ( userInput ?: string ) => {
36
+ console . log ( "validateTextInput called with userInput:" , userInput ) ;
35
37
36
-
37
- if (
38
- userInput &&
39
- / \. ( j p g | j p e g | p n g ) $ / i. test ( userInput . trim ( ) )
40
- ) {
38
+ if ( userInput && userInput . trim ( ) . length > 0 ) {
39
+ // Optionally, validate if the input is a valid URL
40
+ // For simplicity, we'll accept any non-empty text
41
41
return { success : true } ;
42
42
}
43
43
44
- // Disallow other text inputs
45
44
return {
46
45
success : false ,
47
- promptContent : "Please upload a valid file (JPEG or PNG). Empty inputs are not allowed." ,
46
+ promptContent :
47
+ "Please provide a valid URL or upload a file." ,
48
48
promptDuration : 3000 ,
49
49
promptType : "error" ,
50
50
} ;
@@ -54,7 +54,7 @@ const App = () => {
54
54
} ,
55
55
file : async ( { files } ) => {
56
56
console . log ( "Files received:" , files ) ;
57
-
57
+
58
58
if ( files && files [ 0 ] ) {
59
59
const validationResult = validateFile ( files [ 0 ] ) ;
60
60
if ( ! validationResult . success ) {
@@ -67,23 +67,18 @@ const App = () => {
67
67
console . error ( "No file provided." ) ;
68
68
}
69
69
} ,
70
-
71
70
} as InputValidatorBlock ,
72
71
73
72
file_upload_validation : {
74
73
message :
75
- "Thank you! Your picture has been uploaded successfully . You passed the file upload validation!" ,
74
+ "Thank you! Your input has been received . You passed the validation!" ,
76
75
path : "start" ,
77
76
} ,
78
- }
77
+ } ;
79
78
80
79
return (
81
- < ChatBot
82
- id = "chatbot-id"
83
- plugins = { plugins }
84
- flow = { flow }
85
- > </ ChatBot >
86
- ) ;
87
- }
80
+ < ChatBot id = "chatbot-id" plugins = { plugins } flow = { flow } > </ ChatBot >
81
+ ) ;
82
+ } ;
88
83
89
84
export default App ;
0 commit comments