> For the complete documentation index, see [llms.txt](https://docs.ai.insly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ai.insly.com/nora/agentic-workflows/agentic-extraction.md).

# Agentic extraction

Agentic extraction takes documents in, turns them into a checked submission, and exports it to Insly Ledger. Along the way it asks the sender for anything that is missing. It does the same work as [classic submission processing](https://docs.ai.insly.com/nora/configuration-guide/process-a-submission-via-api.md): the same templates, the same extraction, the same validation and the same Ledger export. The difference is that each stage is a separate agent in a workflow. That makes the workflow flexible: Insly can add steps, for example an agent that enriches the data from another source, or remove steps your process doesn't need.

### The steps

Every step after the first needs only the `submissionId`, which the first step creates and passes on.

<table><thead><tr><th width="150">Step</th><th width="210">Needs</th><th>What it does</th></tr></thead><tbody><tr><td><strong>Conversion</strong></td><td><code>templateName</code>, <code>files</code></td><td>Creates a submission from the run's documents against the chosen template and converts the files for processing. Passes <code>submissionId</code> to every later step.</td></tr><tr><td><strong>Extraction</strong></td><td><code>submissionId</code></td><td>Reads the documents into the submission's payload. On a <a href="https://docs.ai.insly.com/nora/agentic-workflows/agentic-extraction.md#the-follow-up-loop">follow-up run</a> it applies the sender's reply as an edit instead.</td></tr><tr><td><strong>Grounding (fact check)</strong></td><td><code>submissionId</code></td><td>Checks each extracted value against the documents and removes values it cannot support, using your organisation's grounding threshold. Skipped when the threshold is 0.</td></tr><tr><td><strong>Reference</strong> <em>(optional)</em></td><td><code>submissionId</code></td><td>Records where in the documents each value came from.</td></tr><tr><td><strong>Metadata</strong> <em>(optional)</em></td><td><code>submissionId</code></td><td>Names the submission and gives its files readable names.</td></tr><tr><td><strong>Validation</strong></td><td><code>submissionId</code></td><td>Checks the payload against the template and the export rules. If it doesn't pass, for example because a required field is missing, the run <strong>stops here as completed</strong> (see below).</td></tr><tr><td><strong>Export</strong></td><td><code>submissionId</code></td><td>Exports the submission to Insly Ledger using your organisation's Ledger integration, under the same rules as classic processing (see <a href="https://docs.ai.insly.com/nora/agentic-workflows/agentic-extraction.md#when-export-is-skipped">below</a>).</td></tr></tbody></table>

If an **optional** step reports a failure, the run carries on without that step's result.

The table above shows the standard extraction workflow. Your organisation's workflow may have more steps or fewer.

### Where the inputs come from

* **`templateName`**: on email and chat, the sender names the template, by its name or its email alias. Insly can also fix the template on the workflow, so that the sender never has to name it. On the API, you pass a `templateId`.
* **`files`**: always the documents actually on the conversation, never the message text. If the sender says "quote attached" but nothing is attached, Nora asks for the documents.

### When validation stops the run

If the submission doesn't pass validation, the run ends with status `completed` and export does not run. This is a normal result: the submission isn't ready yet. What happens next depends on the channel:

* **Email:** Nora sends the sender the missing-fields email, the same one classic processing sends. The sender's reply starts the follow-up loop below.
* **Chat:** the reply lists what is missing. The sender's next message starts the follow-up loop.
* **API:** the poll result lists the fields in `missingFields`. See [Run agentic extraction via API](https://docs.ai.insly.com/nora/agentic-workflows/run-agentic-extraction-via-api.md#missing-fields-over-the-api).

You can also complete the submission by hand in the Nora web app and export it from there. If the sender replies later, the next validation includes your edits.

### When export is skipped

The export step uses the rules of classic processing. The run still ends as `completed`, and its reply says the submission was not exported, when:

* the submission was picked for a [human spot check](https://docs.ai.insly.com/nora/configuration-guide/set-up-human-spot-checks.md) and is held for review,
* it fails the final export checks,
* email follow-ups are not enabled for your organisation, or it has no Ledger integration,
* the submission has no email sender. **This applies to every run started over the API or in chat.** Only runs started by email are exported automatically. Export the others from the web app or with the [Submissions API](https://docs.ai.insly.com/nora/api-documentation/submissions.md).

### The follow-up loop

When the sender answers a missing-fields question, the original run is not resumed. Nora starts a **new run** of the same workflow for the same submission, with the sender's reply as input.

1. **Conversion** does not create a new submission. It reuses the existing one and adds any new documents the reply brought.
2. **Extraction** treats the reply as an edit. It works out whether the sender is adding, changing or removing values, then applies only those changes. The submission is not extracted again from scratch. Nora knows which fields it asked about, so a reply like "SO16 0AS" goes to the postal code that was asked for.
3. **Grounding, Reference and Metadata are skipped.** Re-checking an edit could remove a value the sender has just supplied.
4. **Validation** runs again. If the submission now passes, **Export** follows. If not, Nora asks again and the loop repeats.

Each round is a separate run, linked to the one before it. In the Nora web app you see one conversation with all of its rounds.

{% hint style="info" %}
If the sender writes in the same conversation while a run is still working, Nora does not start a second run on top of it.

* **Email:** Nora confirms receipt and uses the message once the current run finishes. If the run ended with a missing-fields email, the message counts as the answer to it.
* **Chat:** Nora asks the sender to wait for its reply and to include any additions in the answer to it.
  {% endhint %}

Related: [Email Follow Up](https://docs.ai.insly.com/nora/skills/email-follow-up.md), [Fields + required/optional](https://docs.ai.insly.com/nora/onboarding/fields-+-required-optional.md)
