Welcome to Portal
Let's explore Input/Output Processing further by building a circuit using the example of an Employee Onboarding process.
We initiate the process with the following state input which contains information about the employee details for employee onboarding:
{"employee_details": {"emp_name": "John Doe","emp_id": "357","department": "Engineering","role": "Software Engineer"},"onboarding": {"phase": "Employee Onboarding","start_date": "2023-08-01","manager": "Jane Smith","location": "NewYork"}}
{"onboard_employee": {"type": "function","next": "End","start": true,"function_id": "function_emp_onboard_1","parameters": {"name": "$.employee_details.emp_name","ID": "$.employee_details.emp_id","department": "$.employee_details.department"},"input_path": "$.employee_details","result_selector": {"task_status": "$.SdkResponseMetadata.HttpStatusCode"},"result_path": "$.onboarding_result","on_error": [{"error_type": "timeout_error","fallback": {"next": "End","error_path": "$.error","error_selector": {"error_code": "EXC_TME_EXC","error_message": "Execution Time Limit Exceeded"}}}],"output_path": "$.employee_details"}}
The below images illustrate how the I/O processing fields are configured for the above example in both builder view and code view.
In this setup:
Input Path: Initially filters the JSON to retain only the $.employee_info object, focusing on employee details.
Parameters: Passes specific employee-related data (employee_id, employee_name, department, role) to the onboarding function.
Result Selector: Extracts the HTTP status code from the response of the Function state, providing insights into the success or failure of the onboarding process.
Result Path: Appends the onboarding result as a child of the employee_info node in the original input JSON ($.onboarding_result).
Error Selector and Error Path: Capture and store error details in case of any issues during the onboarding process.
Output Path: Specifies that the final result passed to the next state is $.employee_info, ensuring only relevant employee information is carried forward.
{"role": "Software Engineer","emp_name": "John Doe","department": "Engineering","emp_id": "357"}
In case of a timeout error during execution, the output JSON would be:
{"error_code": "EXC_TME_EXC","error_message": "Execution Time Limit Exceeded"}