Find details in documents
To pull the supplier, the date and the total out of a document, add an AI agent step and list those details as its fields. Each field becomes a value that later steps read, such as {details.total} in a file name or an email.
There is no separate "find details" step any more. Find the details is retired: a flow that still has it is rewritten at start to an AI agent step with the same id and the same fields, so {details.supplier} keeps working. The same holds for Sort into a category, Summarize it and Read a scan or photo. AI in a flow runs only through the AI agent step (chat-agent).
How it works
An AI agent step with fields reads the document and answers in exactly those fields.
- Every field is an output of the step, named after the field. A later step reads it as
{stepId.fieldName}in text and asstepId.fieldNamein a condition. - A detail the document does not have comes back empty (null), not guessed. A later Branch or Filter can test for that.
- With fields and no tools, the step runs on the platform's fast model (if there is one) unless you name a model or your workspace default is a model on its own key. It weighs 1 credit as a step (an agent with tools weighs 3) plus the tokens it uses, charged at the model's rate. See Models and cost.
Describe the details
Each field has a name, an optional hint and an optional type.
| Setting | What it does |
|---|---|
name | The field's name. Up to 64 characters, no braces, unique in the step, and not reply (that is the agent's own answer). |
hint | More words the document may use for it, comma separated: Amount due, סכום. The hint is told to the model. |
type | string (the default), number, date (written YYYY-MM-DD) or money (an amount and a currency). A few well known names keep their own type when you give none: date is a date and total is money. |
A step takes up to 50 fields.
Read the text first, the file only for scans
A PDF with a text layer needs no model to read. Put Read the text (read-text) before the agent: it reads the text layer for 1 credit and calls no model. A scan or a photo has no text layer, so the step reports scanned: true.
Then tell the agent how to treat the file with files.mode:
| Mode | The agent gets |
|---|---|
ifNoText | The text when there is some, and the file itself only when there is none. The usual choice after Read the text. |
attach | Each file whole when its model can read files, otherwise its text. This is the default. |
text | Only the text read out of each file. |
none | No file at all. |
Reading a file whole is what makes a scan or a photo work, and it uses more tokens. ifNoText pays for that only when it must. The other limits are maxFiles (default 10, at most 100), maxPages (across all files, default 100, at most 1000) and maxBytes (all files together, default 20 MB).
Add the step in the console
- In a flow with a document on the path, click + after the step that reads the text and choose Action.
- Search
agentand choose AI agent. - In its settings, write the instructions, for example
Find these details in the invoice. - Add the fields to find: a name, an optional hint and a type.
- Set how it reads files to read them only when there is no text.
- Click Done, then Save and enable.
The editor shows the step's estimate beside it.
Use the details
A field is an output, so any later step can read it.
- In a text setting, such as a file name pattern or an email subject, click the
{x}button and pick the field, or type{details.supplier}. - In a Branch or Filter, write the condition on
details.total.
The same flow as YAML
This is the invoice intake pattern: read the text, find three details, name the file by them and keep it.
- YAML
- Console
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: finddetails-invoice-intake
namespace: tenant-acme
spec:
displayName: Invoice intake
triggers:
- id: email
ref: {name: email-arrives}
connectorRef: {name: invoices-inbox}
config: {requireAttachment: true}
next: [text]
nodes:
- id: text
stepRef: {name: read-text}
next: [details]
- id: details
stepRef: {name: chat-agent}
config:
instructions: Find these details in the invoice.
fields:
- {name: supplier}
- {name: date, type: date}
- {name: total, hint: "Amount due", type: money}
files: {mode: ifNoText}
next: [rename]
- id: rename
stepRef: {name: rename-file}
config: {pattern: "{supplier} {date}.pdf"}
next: [keep]
- id: keep
stepRef: {name: save-file}
config: {destination: lumen}
Follow Add the step in the console. The instructions, the fields and the file setting are all on the step's settings panel.
Sort a document into a category
What Sort into a category did is an agent with a field. Name the categories in the instructions and ask for the category and the reason:
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: finddetails-sort-documents
namespace: tenant-acme
spec:
displayName: Sort documents
triggers:
- id: email
ref: {name: email-arrives}
connectorRef: {name: invoices-inbox}
config: {requireAttachment: true}
next: [text]
nodes:
- id: text
stepRef: {name: read-text}
next: [sort]
- id: sort
stepRef: {name: chat-agent}
config:
instructions: >-
Sort the document into one category: invoice, receipt, quote or other.
Say in one sentence why.
fields:
- {name: category, hint: "invoice, receipt, quote or other"}
- {name: reason}
files: {mode: ifNoText}
next: [keep]
- id: keep
stepRef: {name: save-file}
config: {destination: lumen}
A summary is the same with the instruction Write a short summary of the document. and one field named summary.
Reading the text costs one credit and calls no model. Put Read the text first and keep the file setting on ifNoText: only a real scan makes the agent read the file itself.
Limits
An agent reads at most the files, pages and bytes set above. What it left out is said to the model and shown in the step's activity. A document of which nothing fits fails the step.