Your First Workflow
Get familiar with the Cortex workflow by creating a simple workflow.
Getting Started
We are going to create a workflow that will extract fields from a document. You will specify the fields to extract in natural language.
As in the Introduction, you already have a blank workflow created.
Setting Up Inputs
To begin, we need to provide the workflow with two things: a document and the fields to extract. This is where Input steps come in. Input steps allow you to pass data (like files, text, etc) into your workflow for processing. When you share your workflow with others, they can provide their own inputs, and the workflow will process them accordingly. The same applies when calling the workflow through APIs or SDKs - you can pass the required data as body.
Let’s add an Input step to the workflow.
- Click the plus (+) button on the left toolbar to add a new step to your workflow.
- Click the Manual Input step from the list of steps.
You should now see the Input step added to the workflow.
Now, let’s rename the Input step key from input1 to form to be more descriptive. Then, let’s add two new fields to the input step:
- Documents: A file input that allows users to upload documents. We will enable multiple files to be uploaded.
- Fields to extract: A text input that allows users to specify the fields to extract from the documents.
Watch the video below to understand how to rename the step and add new fields to the input step:
As shown in the video, we created a new file field called Documents and assigned it the key name documents
. We enabled multiple file uploads in the field settings and activated the Extract images option to automatically extract images from uploaded documents. These extracted images will be passed to the model step later in the workflow, which we’ll cover in the upcoming sections.
We also added a text field called Fields to extract with the key name fields_to_extract
. These key names are important as they allow you to reference these fields in subsequent steps of your workflow.
Adding the Model Step
Now that we have the input step, we can add a Model step to the workflow to extract the fields from the documents.
Watch the video below to learn how to create a model step, update the user prompt, and set the response format to JSON:
- Click and drag the small connection circle on the top right of the input step
- Release the drag where you want to add the new step that connects to the input step
- After releasing, a modal will appear with a list of steps similar to when we added the input step
- Click on the Model step to add it to the workflow
After adding the model step, you will see it added to the workflow and connected to the input step.
This means the model step will receive the documents and fields to extract from the input step. This is the core concept of workflows - steps can be connected to each other to pass data between them.
Now, let’s update the model step’s user prompt to something like this:
Feel free to customize the user prompt based on your specific needs. You can add more detailed instructions to guide the model in extracting the information accurately.
The model step will process the uploaded documents and extract the fields you specified, returning the results as a structured JSON object.
Let’s understand the variables in the prompt:
{{form.output.fields_to_extract}}
- References the text input where users specify which fields to extract{{form.output.documents:images}}
- References the images extracted from the uploaded documents
These variables follow a consistent pattern used throughout Cortex workflows:
stepKey.output
accesses any step’s output (in this case, “form” is our input step’s key)- The
:images
suffix specifically retrieves images from the documents because we enabled the Extract images option in the field settings - Similarly, a
:content
suffix can be used to access document text when the Extract contents option is enabled
Additionally, you should set the response format in the model step settings to JSON. This ensures the model returns a properly structured JSON object that can be easily used in subsequent steps.
For more details on input field types and accessing their data, see the Input Step documentation.
Testing Your Workflow
It’s time to test the workflow 🚀. Try uploading a document and entering the fields to extract. Then run the workflow either by clicking the workflow’s Run button or clicking the run button on the Input step since the input step is the starting step of the fields extraction workflow.
You should see the workflow running and the extracted fields in the model step’s output.
Usage
You can interact with your workflow directly in the canvas by running it and providing inputs. However, there are additional ways to leverage your workflow:
API Usage
Learn how to integrate your workflow with applications via API and SDKs
Share
Learn how to share your workflow with others and integrate it in different ways
Next Steps
You now have a solid understanding of workflow steps, input steps, how to connect steps together, and how to access step outputs. Now you are able to try different use cases with workflows. But there are still more details to learn about steps and their configurations.
Steps
Deep dive into different step types, their configuration options, and working with step outputs, step output formats of different step types.