Digital transformation

How to automate paperwork with AI

Mang-Git Ng
By Mang-Git Ng
∙

A practical guide to using AI to set up document templates while APIs handle repeatable PDF filling, validation, review, and signing.

AI
PDF Fill
Workflows
Back to all articles
Post hero image

Summary

  • AI can identify fields in a new PDF and propose how they map to data your application already stores. You should review those mappings before using the template.
  • Document APIs can then fill PDFs, collect missing information, and route signature packets using rules you define.
  • For a recurring onboarding packet, you can map the forms once and run the approved workflow for each new hire.
  • Validation should check every submission for missing or malformed data. A reviewer should handle uncertain mappings, unexpected template changes, and final approval where required.
  • The guide shows how to build that workflow, where to keep sensitive data out of AI-assisted setup, and when manual template setup makes more sense.

Why paperwork automation needs both AI and deterministic systems

AI can help you understand a new form, but recurring paperwork needs fixed rules for each completed document. When an unfamiliar PDF arrives, AI can identify fields and propose that a box labeled “Start date” maps to the start-date field in your application. A person should confirm that mapping before you use it. On later submissions, a document API can put the validated value in the approved box without asking AI to interpret the label again.

That separation matters because an AI model may interpret an ambiguous field differently on another run. A form might contain both “Start date” and “Date signed.” If the model confuses them, a valid date could land in the wrong place. An approved field mapping gives each value a known destination, while validation can reject missing or incorrectly formatted data before the PDF is filled or sent for signature.

Document understanding also differs from OCR. OCR extracts text from a scanned page. AI-assisted document understanding uses a form’s labels and layout to propose what its fields mean and how they relate to your application data. If your incoming files are scans that need text extraction, you need a separate OCR provider. Anvil does not offer OCR as a core product.

Reference architecture: AI-assisted setup vs deterministic execution

Separate paperwork automation into two phases. Use AI when you add or change a document template, then use fixed rules and APIs each time someone submits data. The separation lets you review AI’s interpretation before it affects a live document.

SETUP: WHEN A TEMPLATE IS NEW OR CHANGES
Blank PDF → AI proposes fields and data-key mappings → Human verifies mapping → Approved, versioned template

EXECUTION: FOR EACH SUBMISSION
Structured data → Required-field and business-rule checks → Fill or generate PDF → Review exceptions → Send for signature → Store signed document

Record the approved template version with each submission so you can identify the mapping used to produce its document.

During template setup, you upload the PDF and define the application data the form should use. Anvil’s Document AI can propose fields and labels on a PDF template. Map the approved fields to your application’s data keys using aliasIds. For example, a new form’s “Employee surname” field can map to the lastName key your application already stores. A person should check the proposed mappings, field types, and required fields before approving the template.

For each submission, your application collects structured data and checks it against required fields and business rules. It can then send the approved data to Anvil’s PDF Filling API to populate the template, or generate a document when the use case calls for one. Anvil Workflows can support data collection and review, while Etch e-sign handles signature packets. Your application should hold a packet for review if a required value is missing or a validation rule fails.

An AI agent can help prepare a new template, but it need not interpret every submission. Once you approve the mapping, the same data key feeds the same field on each run. A reviewer must correct a mistaken suggestion before approving the template for use.

Worked example: onboarding a new form into an automated workflow

A company adds a new employee equipment agreement to its onboarding packet. HR uploads the blank PDF, and Anvil’s Document AI proposes fields such as the employee’s name, start date, and equipment description. HR separately checks that the PDF has a signature field and assigns it to the employee in the signing packet. Because the PDF contains no employee responses yet, the template setup step can run without sending submitted personal data through AI.

The proposed fields need to match the application’s existing data keys. For example, the detected “Employee name” field should map to employee.legalName, and “Start date” should map to employee.startDate. Anvil’s aliasIds support this mapping when you create the PDF template. A reviewer checks each match, including whether dates, text fields, and signature fields have the right types, before approving the template.

Field on agreement

Application data key

Expected value

Review before approval

Employee name

employee.legalName

Text

Use the legal name, not a preferred name.

Start date

employee.startDate

Date

Check date format and distinguish it from the signing date.

Equipment description

equipment.description

Text

Test long descriptions for overflow.

Employee signature

No application data key

Signature field

Confirm signer assignment and placement.

The application keys in this table are illustrative, not an API request. Check Anvil’s current API documentation for the aliasIds request format before implementation.

For each new hire, the HR application collects structured data through its existing intake flow. Its backend validates required values, then sends the approved keys and values to Anvil’s PDF Filling API. The PDF Filling API uses the submitted values to fill the approved template. The backend should check the resulting PDF before signature dispatch, particularly when an equipment description or other variable-length answer could overflow a field.

The backend then creates an Etch e-sign packet with the filled agreement and routes it to the employee. If HR must countersign, the packet includes the HR signer in the required order. After signing completes, the application retrieves the signed document and stores it in the company’s approved employee record system. The application also records the template version and employee record ID so staff can identify which agreement a new hire signed.

Where human review belongs in the workflow

Review the field mapping before a new template enters production. An AI-generated label may look plausible while pointing to the wrong box. For an employee onboarding form, a reviewer should confirm that “start date” maps to the start-date key rather than the signature-date key. The reviewer should also check which fields are required, whether optional fields can remain blank, and whether each field accepts the expected data type. Approve and save the mapping only after those checks pass.

Send uncertain field detections to a reviewer instead of guessing. A faint label or an unfamiliar template variant may leave the AI unable to identify a field reliably. The reviewer can correct the field and its mapping, then decide whether the change calls for a new approved template version. Submissions using an already approved template and mapping do not need that setup review again.

Before e-signature dispatch, review the completed document and recipient details when you first use a template or when a submission triggers an exception. Check that values landed in the right places, required content appears, and the right people will receive the signature request. For routine submissions that pass validation, you can allow dispatch without case-by-case approval if your policy permits it. Keep the review decision tied to a specific risk or change, rather than asking someone to approve every automated step.

Validation and exception handling

Run fixed validation checks on every submission before filling a PDF or sending it for signature. Your application should check required fields, data types, and business rules against the approved template mapping. For an insurance intake form, it might reject an invalid date format and require a policy number before creating a packet. A missing applicant address should go back to the person who can supply it, rather than leaving a blank in the PDF.

Handle failures according to their cause. Retry a temporary API or network failure with an identifier that prevents a second attempt from creating a duplicate signature packet. Queue an unfamiliar template variant or a field that no longer maps cleanly to your data for human review. Reject a submission outright when it fails a rule the submitter cannot correct within that workflow, such as a document type you do not accept. Record the reason so an operator can tell a rejected submission from one still awaiting review.

Failure

Response

Release condition

Temporary network or API failure

Retry with duplicate-packet protection in your application.

Confirm whether the request succeeded; stop and investigate after the retry limit.

Missing required value or malformed date

Return to the person or system that supplied the data.

Corrected value passes validation.

New template variant or uncertain field mapping

Pause processing and send the template to a reviewer.

Reviewer approves a new mapping and template version.

Unsupported document type

Reject the submission and record the reason.

Start a separate, supported workflow if appropriate.

Do not retry validation failures as though they were transient outages. A retry will not fix the source data or approve a changed template.

AI can help sort unusual cases, but it should not replace those checks. For example, an AI-assisted triage step could flag a new form whose field labels differ from the approved template. A reviewer should confirm the mapping before you use that variant for future submissions.

Privacy, security, and compliance boundaries

Keep submitted personal data out of the AI-assisted template setup step unless the task requires it. AI can inspect a blank form to identify field locations and propose labels such as “patient name” or “account number.” Remove filled-in examples before uploading a template. Once a reviewer approves the mapping, configure your application to send submissions to the document workflow without passing their contents to the AI service. Separating those steps limits which vendors and logs can hold personal, health, or financial data.

Before you route a form through any AI provider, check whether its terms permit training on uploaded documents, how long it retains inputs, where it processes them, and which subprocessors receive them. Review access controls and deletion procedures for both the AI service and the document service that handles completed paperwork. If the workflow involves protected health information, confirm that the required business associate agreements cover the services receiving it.

For Anvil, request its SOC 2 report and documentation for its stated GDPR, HIPAA, and eIDAS support. SOC 2 provides evidence about audited controls, while GDPR, HIPAA, and eIDAS impose different requirements that depend on your use case. Check the required signature type under eIDAS and your obligations for the data you collect. No vendor claim replaces that review.

Choosing AI-assisted setup vs fully automated execution

Use submission volume and template changes to decide where AI belongs. If you process hundreds of submissions against an unchanged form, approve its field mapping once. Your application can then use fixed field keys and validation rules for each submission without asking AI to interpret the form again.

Frequently changing forms make AI-assisted setup more useful. If an insurer sends a revised intake form each month, AI can propose how its fields map to your existing data keys. A reviewer should check those proposals and approve the template before the application fills it or sends it for signature. If every submission arrives on a different form, treat each form as a new template and review its proposed mapping before filling it. Approval of one template does not validate the next.

For a one-off document, manual setup may take less time than checking and correcting AI output. Compare the time needed to map each new template by hand with the time needed to review AI proposals. Then keep routine execution deterministic once you approve a template.

When not to use AI for paperwork

Skip AI-assisted mapping when a field error could cause harm and your review process cannot reliably catch it before use. A medical consent form, for example, might link a patient’s signature to the wrong authorization. In that case, configure and verify each field manually. You can still use fixed rules to fill approved templates and route them for signature.

Low document volume may not justify an AI-assisted workflow. If you process only a few submissions a year, manual handling could take less time than building an integration, testing its output, and managing exceptions.

Testing and rollout checklist

  • Build a test set of approved templates and expected field mappings. Include common form variants, similar-looking labels, checkboxes, and required fields. Compare each proposed mapping with a human-reviewed answer before you approve the template.
  • Test completed PDFs with representative data. Check that each value reaches the right field, dates and numbers retain the expected format, and blank optional fields do not shift other values.
  • Run invalid submissions through the same path. Confirm that missing required data and wrong data types stop before PDF creation, while an unfamiliar template goes to review rather than entering production automatically.
  • Test failure recovery before sending real signature requests. A retry after a timeout should not create a second document or signature packet. Confirm that your logs let you trace a failed submission without exposing sensitive field values.
  • Run the automated path alongside the current process without dispatching its documents. Compare filled PDFs and routing decisions against the approved process, then investigate mismatches before cutover.
  • Move a small, monitored group of submissions to the new path first. Keep a way to return those submissions to the previous process if validation failures or document mismatches increase.
  • Watch for source-template changes after launch. When a new version appears, pause automatic use of its mapping until someone checks field positions, labels, and required-field rules. Track validation failures and review-queue volume so smaller changes do not go unnoticed.

Anvil as the document layer for AI agents

An AI agent can use Anvil to turn an approved field mapping into repeatable document work. During template setup, Document AI detects fields and proposes labels. Anvil can map those fields to your application’s existing keys through aliasIds. You should review the mapping before using it for production submissions.

After approval, your application can send structured data to the PDF Filling API, use Workflows to collect additional information, and route documents through Etch e-sign. Those steps use defined fields and rules rather than asking an AI agent to interpret each submission. Anvil does not provide OCR for extracting text from scanned documents. If your input requires OCR, you need a separate provider before the data reaches this workflow.

Check Anvil’s current plans for AI schema mapping availability. For broader automation examples and case studies, see Anvil’s paperwork automation pages and customer stories. This guide focuses on how you can build and validate your own integration.

FAQs

How does AI schema mapping handle a template it has never seen? Anvil’s Document AI can detect fields and propose labels on a new PDF template. You can map those fields to existing application keys using aliasIds. A reviewer should confirm the mappings before you use the template for live submissions.

What happens when a field mapping is uncertain? Keep the template out of production until someone checks the field against the source PDF and your data schema. If a required field has no reliable match, correct the mapping or handle that field manually.

Is AI schema mapping the same as OCR? No. OCR extracts text from a scanned document. Schema mapping identifies the fields in a template and connects them to structured data keys. If your input requires OCR, use a separate provider for that step. Anvil does not offer OCR as a core product.

Does AI need to inspect every completed form? No, not when your application receives structured data for an approved template. After you approve a template, your application can validate submitted data and use document APIs to fill the PDF. Send exceptions for review when a submission fails validation or the source template changes.

Next steps

Pick a form you process regularly and try mapping its fields with Anvil. Compare the proposed fields with your existing data keys before using the template for live paperwork.

Get a demo
(from a real person)

Schedule some time on our calendar to talk through your specific use case and see which Anvil products can help.
    Want to try Anvil first?
    Want to try Anvil first?
    Marketing Mode