Extract data from documents in bulk
Build a workflow that reads several files and returns structured fields.
When the task is always the same, such as reading contracts and extracting parties, amounts and deadlines, a Workflow delivers more than an Agent. The path is fixed, the result is structured and every run is recorded.
This guide builds the bulk extraction flow, from upload to result.
Prerequisites
- The Owner, Curator or Editor role in the workspace.
- An enabled model, preferably a cheap one, since the task is repetitive.
- A few sample files that represent the real variation in the documents.
The flow design
Input: receive the list of files
In the Input node, declare a variable that receives the files. It becomes the form field the person running the workflow fills in.
Give it a readable name: the person running it reads that label on screen.
File extractor: convert to text
Connect a File extractor node to the Input. It turns the binaries into text and returns a list, accessible as {{ extrator_arquivos.contents }}.
Without this node, the files don't reach the model in a usable form.
Iteration: repeat per document
Add an Iteration node and point its input at the list of extracted texts.
Inside the loop, the Iteration start node provides item, the text of one document, and index.
LLM: extract the fields
Inside the Iteration, connect an LLM node to the Iteration start. In the prompt, ask for the fields and require the format.
Extract the fields below from the contract and answer only with valid JSON,
with no text before or after.
Fields: parties, total_amount, start_date, end_date, termination_notice.
Use null when the field isn't in the document.
Contract:
{{ inicio_da_iteracao.item }}The format instruction isn't optional. Without it, the model returns free text and nothing downstream can handle the output reliably.
Iteration output: collect the results
Under Output variables of the Iteration node, declare the name of the list that leaves the loop, for example extracted_contracts, and point the source variable at the inner LLM node's answer.
Output: return the result
Connect the list to the Output node. For a result another system will consume, declare separate fields; for human reading, a single field with the consolidated result is enough.
If the person running it needs a file, add a File generator node before the Output.
Before publishing
Run it from the studio with two or three real documents, including an atypical one. The run log shows what each node received and returned, step by step.
The most common failure point is the LLM node returning an inconsistent format on non-standard documents. You fix that in the prompt, not in the next node.
The cost
An LLM node inside an Iteration runs once per item. A hundred documents are a hundred calls.
Before releasing it to the team, estimate the cost of a typical batch in Observability and, if it matters, set a cap in Quotas.
Publish
Publish the Workflow. It then shows up in the Agents area of the Chat module, where people run it without needing Admin access.
Next steps
- Choose the right node for each step in Node catalog.
- Investigate a run that went wrong in Runs.