Loopfour
WorkflowsSteps

Read, extract and classify with AI

Learn what the AI Agent step does, such as pulling fields from a document or sorting items, and how to check its output before it is used.

The AI Agent step reads information and gives back an answer in the shape you ask for. It is the step to use when the input is written for people, not systems: a vendor bill, a remittance email, a contract.

Before you start

Choose a sample bill or contract you may process. Decide which fields you need and who will check them before the result is used.

What it is good for

  • Extracting fields: vendor, invoice number, date, total and line items from a bill.
  • Classifying: sorting an email as a bill, a remittance or something else; suggesting an expense category.
  • Matching help: suggesting which open invoice a payment is for when the reference is unclear.
  • Drafting text: a first draft of a collection email for a person to review.
  1. TriggerBill arrives by email
  2. StepAI Agent: read the bill
    Returns vendor, number, date and total.
  3. DecisionTotal found and under the limit?
  4. ApprovalOtherwise a person reviews
  5. OutputBill created in the ledger

Set it up

Add the AI Agent block

Drag AI Agent from Core Blocks onto the canvas, after the step that brings in the document or text.

Say what you want

Under Prompt, write the instruction as you would to a colleague, for example "Extract the vendor name, invoice number, invoice date and total from this bill." System Prompt holds standing instructions, such as "Use ISO dates. If a value is not on the document, leave it blank."

Give it the document

Input Data (JSON) passes the document or the earlier results to the step. Ask chat to fill this in for you, for example "give the AI step the PDF from the email".

Fix the answer's shape

Output Schema (JSON Schema) lists the fields the answer must have, so later steps can rely on them. Ask chat to set it from your list of fields.

Provider and Model choose which AI service answers. Temperature starts at 0, which keeps answers as consistent as possible from run to run; leave it there for extraction.

Check its output

AI output can be wrong even when it has the required fields. Loopfour can check the answer's shape, but you must check its accounting meaning. Build the checks into the workflow:

  • Add a decision after it. Check that the key fields are there and make sense, such as a total that exists and is more than 0. See Make a decision.
  • Add an approval where it matters. Send anything that will post to your ledger or pay money past a person first. See Add an approval step.
  • Review runs. Open a run under Runs, choose the AI step, and compare its Input and Output with the document. Do this for the first runs and then from time to time.

Check it worked

Open the AI step under Runs. Check that Output contains the fields you asked for, then compare the figures with the source document.

If something goes wrong

If fields are missing or incorrect, improve the instruction and check the document given to the step. If the step fails, read its error and see Error messages explained.

On this page