@@ -5,15 +5,15 @@ import { InputValidatorBlock } from "./types/InputValidatorBlock";
55import { validateFile } from "./utils/validateFile" ;
66
77const App = ( ) => {
8- // initialize example plugin
8+ // Initialize the plugin
99 const plugins = [ RcbPlugin ( ) ] ;
1010
11- // example flow for testing
11+ // Example flow for testing
1212 const flow : Flow = {
1313 start : {
1414 message : "Hey there! Please enter your age." ,
1515 path : "age_validation" ,
16- validateInput : ( userInput ?: string ) => {
16+ validateTextInput : ( userInput ?: string ) => {
1717 if ( userInput && ! Number . isNaN ( Number ( userInput ) ) ) {
1818 return { success : true } ;
1919 }
@@ -28,23 +28,23 @@ const App = () => {
2828 } as InputValidatorBlock ,
2929
3030 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." ,
3233 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 ) ;
3537
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
4141 return { success : true } ;
4242 }
4343
44- // Disallow other text inputs
4544 return {
4645 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." ,
4848 promptDuration : 3000 ,
4949 promptType : "error" ,
5050 } ;
@@ -54,7 +54,7 @@ const App = () => {
5454 } ,
5555 file : async ( { files } ) => {
5656 console . log ( "Files received:" , files ) ;
57-
57+
5858 if ( files && files [ 0 ] ) {
5959 const validationResult = validateFile ( files [ 0 ] ) ;
6060 if ( ! validationResult . success ) {
@@ -67,23 +67,18 @@ const App = () => {
6767 console . error ( "No file provided." ) ;
6868 }
6969 } ,
70-
7170 } as InputValidatorBlock ,
7271
7372 file_upload_validation : {
7473 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!" ,
7675 path : "start" ,
7776 } ,
78- }
77+ } ;
7978
8079 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+ } ;
8883
8984export default App ;
0 commit comments