I’m having some difficulty with a custom interface (User Input) designed to gather the following:
-
Job posting – single file upload
-
Candidate resumes – multiple file upload
Below is the generated code for the setup. I’m encountering two issues:
-
For the job posting (single file), I correctly receive the extracted text from the file. However, for the resumes (multiple files), I only get back an array of URLs. I need this to return an array of extracted texts instead.
-
I can’t figure out how to configure the Cancel action so that the workflow continues from the block specified as the “On Cancel” block in the User Input configuration.
Any insights or examples on how to handle these two cases would be greatly appreciated.
P.S. This works perfectly with the native interface.
// Handles the submission of all files
const handleSubmit = useCallback(async () => {
setError(null);
if (!jobPostingFile) {
setError('Please upload a job posting.');
return;
}
if (resumesFiles.length === 0) {
setError('Please upload at least one resume.');
return;
}
setIsLoading(true); // Start loading state
try {
// Upload job posting file
const jobPostingUrl = await uploadFile(jobPostingFile);
// Upload all resume files in parallel
const resumeUploadPromises = resumesFiles.map(file => uploadFile(file));
const resumeUrls = await Promise.all(resumeUploadPromises);
// Submit the CDN URLs of the uploaded files
submit({
job_posting: jobPostingUrl,
resumes: resumeUrls,
});
} catch (err) {
console.error('Submission error:', err);
// Display a user-friendly error message
setError('Failed to upload files or submit data. Please check your files and try again.');
} finally {
setIsLoading(false); // End loading state
}
}, [jobPostingFile, resumesFiles]); // Dependencies for useCallback
// Handles the cancel action
const handleCancel = useCallback(() => {
// Submitting initialVariables or an empty object allows the workflow to proceed
// with previously set values or default values, effectively "cancelling" new input.
submit(initialVariables);
}, [initialVariables]); // Dependency for useCallback