AWS Public Sector Blog

Build an AI-powered form filling assistant with Strands Agents

Build an AI-powered form filling assistant with Strands Agents

If you’re building software for public sector organizations, you know the pain: Stacks of paper applications, confusing PDFs, and frustrated users who abandon online forms halfway through. What if an AI agent could analyze fillable PDF forms, pull existing customer data from your database, and map it intelligently to the right fields on the form? What if it could also converse with users and help them fill in missing information on the form?

This post explains how to build exactly that using Strands Agents and Amazon Bedrock. The entire solution runs in about 200 lines of Python code, and you can have it working on your computer after completing the pre-requisite steps.

The problem: Complex forms and missing data

This as a recurring problem across industries and public sector verticals. When users deal with an agency or a service provider, they often have to enter the same information across multiple forms. Data processors need to verify the data and make sure all fields are filled correctly.

What if the same form needs to be filed periodically, such as every year or each quarter? What if the official form gets updated, and data needs to be re-entered? Can the data be re-used? The usual answer is no. The data often can’t be re-used across different forms.

The cost is more than work duplication; it’s time, errors, and delays in decision-making that impact people who need fast turnarounds.

A few areas where public sector organizations face this the most:

  • Incident reporting – Workers need to structure information into proper reports manually
  • Permit applications – Citizens navigate complex forms when they could use plain language
  • Benefits enrollment – Applicants answer eligibility questions across multiple programs
  • Licensing renewals – Businesses re-submit information that hasn’t changed since last year

The solution: AI agent to organize forms and collect data

The solution I walk you through addresses the problem of confusing forms and missing data with three capabilities:

  1. Template library – Analyze fillable PDFs once, store their structure, and reuse them across hundreds of customers
  2. Intelligent data matching – Find needed data records and map fields automatically
  3. Conversational fill – An AI agent that identifies missing fields, asks targeted questions, and tracks progress until the form is complete

Prerequisites

Before getting started, you need the following:

  • Python 3.10 or later
  • An Amazon Web Services (AWS) account with Amazon Bedrock and Anthropic Claude model access enabled
  • AWS CLI configured with valid credentials
  • Any fillable PDF form to test with (you can use sample PDFs provided with the solution)
  • Download the solution from the GitHub repository

Note: Amazon Bedrock charges apply based on the number of input and output tokens processed. Monitor your usage in the AWS Billing console to track costs.

Architecture overview

The solution uses a single Strands Agent backed by Anthropic’s Claude Sonnet model in Amazon Bedrock. The agent orchestrates six purpose-built tools and chooses a tool based on the conversation. The following diagram shows the architecture:

A diagram of the AI-powered form-filling assistant architecture. A user interacts with the Strands Agent Python application, which contains an Agent orchestrator that calls six tools: Create Form, List Forms, Update Answers, Lookup Customer, Analyze Form, and Update PDF Form. The orchestrator uses Amazon Bedrock as the reasoning engine. The tools read from and write to three data sources: a SQLite database for form templates and answers, customer data in CSV or Excel files, and a folder of fillable PDF templates.

Figure 1: Architecture diagram showing the Strands Agent orchestrating six tools with Amazon Bedrock as the reasoning engine

Each component plays one of the following roles:

  • Analyze Form – Extracts each field’s name, type, description, and constraint from a PDF file
  • Create Form – Stores a form template or filled form instance in the SQLite database
  • Lookup Customer – Fuzzy-searches CSV and Excel files for matching people or businesses
  • Update Answers – Incrementally saves field values as the user provides them
  • Update PDF Form – Generates the final PDF, correctly handling text fields and checkboxes
  • List Forms – Shows all templates and filled forms in the database

Unlike traditional chatbots that follow rigid scripts, this agent adjusts to each conversation. It tracks context and previous answers, validates data immediately, and selects which tool to call next based on the current state.

Getting started

The complete code from this post is available in the GitHub repository.

Begin by downloading the project and running the setup script, which will install dependencies:

git clone https://github.com/aws-samples/sample-ai-form-filling-agent.git
cd sample-ai-form-filling-agent
bash run.sh

Edit a constants.py file to define your configuration. Specify where form templates and filled PDF files will be stored locally. You can copy PDF forms that you want to re-use and fill out to the local folder:

TEMPLATES_PATH = _PROJECT_ROOT / "sample_pdfs"
FORMS_PATH = _PROJECT_ROOT / "filled_pdf_forms"

Making sense of the tools

Each tool is a Python function decorated with @tool from Strands Agents. The decorator exposes the function to the agent with its docstring as the tool description so the agent can determine when and how to use it.

Tool 1: Analyze a PDF form

This tool extracts every fillable field from a PDF, including field names, types (text, checkbox, choice), descriptions, and constraints. The field names returned by this tool are the exact keys that will be used by agent when filling in the PDF later. The agent reads this rule and applies it throughout the conversation.

Tool 2: Look up customer data

This tool performs fuzzy matching against CSV or Excel files to find existing customer records. Import your customer data and save it into the CSV files. The fuzzy matching is critical for real-world use. Customers might type “Mary Major,” but the database has separate first_name and last_name columns. The tool handles substring matches, prefix matches, and similarity scoring, then presents ranked results for the user to confirm.

Tool 3: Update answers and generate PDFs

The update_answers tool incrementally saves field values, and update_pdf_form generates the final filled PDF. The incremental approach matters here because users rarely have all the information at once. They can fill what they know, close the session, and come back later. The agent will pick up where they left off.

Wiring all tools together: The agent

The main application file creates the Strands Agent using Strands SDK with a system prompt that defines the workflow:

import os
from strands import Agent
from strands.models import BedrockModel
from forms_tools import (analyze_form, analyze_and_save, create_form,
                         list_forms, lookup_customer, update_pdf_form, update_answers)

os.environ["STRANDS_TOOL_CONSOLE_MODE"] = "enabled"

system_prompt = """You are a helpful form-filling assistant. You analyze PDF forms, identify required fields, and guide users through providing the information needed to complete them.

Your workflow:
1. When given a PDF, use analyze_form to extract all fields and their types.
2. Ask the user for the person or business this form is for.
3. Use lookup_customer to search for existing customer data.
4. Map the customer data to the PDF's actual field names.
5. Save mapped data with update_answers using exact PDF field names as keys.
6. Identify remaining unfilled fields and ask the user for missing values.
7. Once complete, generate the filled PDF with update_pdf_form.

CRITICAL: The keys passed to update_answers must be the exact PDF field names
returned by analyze_form — NOT the CSV column names."""

model = BedrockModel(model_id="anthropic.claude-sonnet-4-6")

agent = Agent(
    model=model,
    system_prompt=system_prompt,
    tools=[analyze_form, analyze_and_save, create_form,
           list_forms, lookup_customer, update_pdf_form, update_answers],
)

if __name__ == "__main__":
    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in ["exit", "quit"]:
            break
        response = agent(user_input)
        print("\n")

Notice the system prompt’s critical rule about field name mapping. This is where the AI reasoning is applied: The agent maps a PDF field called applicantname to the combined value of first_name and last_name from the customer CSV. It uses the field descriptions and tooltips to make accurate mapping decisions.

Also, notice the Amazon Bedrock model ID referenced here: "anthropic.claude-sonnet-4-6" You can change it to a different model from a variety of Amazon Bedrock models, which include open weight and proprietary large language models (LLMs) from Amazon, Anthropic, OpenAI, Meta and others. To switch the model, enable model access in the AWS Management Console and replace the model_id in the code. The model_id can be looked up in Amazon Bedrock documentation for each model. For example, check this documentation page for Anthropic Claude Sonnet 4.6.

Running the assistant

Start the assistant and point it at a PDF form that you want to analyze and fill out:

cd sample-ai-form-filling-agent
bash run.sh

Once the command completes, you should see a prompt from the agent: "You:". To verify that agent is properly setup and it can talk to Amazon Bedrock, as well as it can connect to SQLite database, run this prompt: "List my forms". The expected output should be like "You don't have any filled forms yet".

The following is what a typical interaction looks like for creating a new form template from a pdf file and filling it out:

You: Analyze samples_pdf/sba7.pdf

I have analyzed the SBA Form 1919. It contains 47 fields:
   - 32 text fields (such as business name, address, and EIN)
   - 12 checkboxes (business type, loan purpose)
   - 3 choice fields (state selections)

   Who is this form for? I can look up existing customer data.

You: Mary Major

I found 2 matches for "Mary Major":
   Match 1 (exact, score: 1.00) - people.csv
   Match 2 (high, score: 0.85) - businesses.csv (AnyCompany Services, Senior Partner)

   Which record should I use, or both?

You: Use both - she is applying for a business loan through AnyCompany Services

Mapped 28 fields from existing data. Here is what I filled:
   - Business: AnyCompany Services, 200 Spruce Boulevard, Anytown VA 22101
   - Applicant: Mary Major, tax ID ending in 1234
   - Contact: mary_major@example.com, 555-0101

   19 fields remain. Here are the groups:

Loan Details (7 fields):
   - Loan amount requested
   - Loan purpose
   - Term length...

You: Loan amount $500,000, purpose is working capital, 10-year term

Updated 3 fields. Progress: 31/47 fields filled.
   ...

The agent handles the cognitive load of mapping between data sources and PDF field names. It groups remaining questions logically, validates progressively as information is collected, tracks progress, and updates the form. When the user is done answering questions, the agent generates a properly filled PDF in one command.

Taking this to production

This proof of concept uses local CSV files and SQLite to store the customer and forms’ data, but the pattern scales naturally to production workloads. The following are key considerations for a production AI-powered form filling assistant:

Infrastructure and integration

  • Replace CSVs with API calls – Connect to your CRM, ERP, or customer database using additional Strands tools
  • Add document storage – Save filled PDFs to Amazon Simple Storage Service (Amazon S3) with metadata tags for retrieval and audit
  • Build a web interface – Wrap the agent in a FastAPI endpoint and connect a React frontend
  • Workflow routing – Integrate with notification services to alert relevant staff when forms are complete

Security and compliance

  • Encrypt sensitive data – Personally identifiable information (PII) such as Social Security numbers and EINs should be encrypted at rest and in transit
  • Implement authentication – Use Amazon Cognito to control access to solution
  • Follow data retention policies – Archive completed forms appropriately and clean up temporary data
  • Human-in-the-loop review – Add approval workflows for high-value or complex submissions

Cost optimization

  • Smart routing – Use rule-based logic for straightforward field mappings and AI processing only for ambiguous cases
  • Efficient prompting – The system prompt is designed to gather information in fewer exchanges by grouping related fields
  • Serverless deployment – Use AWS Lambda to handle compute needs while Amazon DynamoDB stores conversation state, scaling to zero when idle

Advanced features to consider

  • Multi-document agents – Collect information across multiple related forms, understanding relationships between different applications
  • Predictive pre-filling – Use historical data to suggest likely answers, reducing user effort further
  • Voice interaction – Add speech-to-text for accessibility, letting users speak their responses naturally
  • Analytics and insights – Track conversation patterns to identify common pain points and optimize the experience

For guidance on deploying the agent to production using Amazon Bedrock AgentCore, see this blog post or reference this AWS example solution for practical patterns.

Cleanup

Warning: Before deleting the project directory, back up any filled PDF forms or customer data you want to retain. The following commands will permanently delete all project files, including filled out forms.

If you deployed this solution and want to remove it, delete the project directory:

deactivate
cd ..
rm -rf sample-ai-form-filling-agent

If you enabled Amazon Bedrock model access for this project and no longer need it, you can disable model access from the Amazon Bedrock console.

Your next steps

Ready to transform your data collection process? Start with these concrete actions:

  1. Identify your pilot form – Choose a frequently used PDF that causes user frustration or high error rates
  2. Build a prototype – Focus on one form and one customer data source to prove the concept
  3. Test with real users – Gather feedback early on actual usage patterns
  4. Iterate on the solution – Refine the agent based on user feedback
  5. Plan your production deployment – Consider the infrastructure, security, and integration requirements outlined in this article

Conclusion

This post illustrated how to build an AI-powered form-filling assistant using Strands Agents and Amazon Bedrock. The solution analyzes fillable PDFs, matches customer data from existing sources, intelligently maps fields, and generates completed forms through a conversational interface that handles the complexity so your users don’t have to.

For public sector ISVs, this pattern eliminates one of the most persistent pain points in government technology: repetitive, error-prone form-filling. The approach is the same for any form: Analyze once, fill many, and update when regulations change.

The future of data collection is conversational. Your users want to describe their needs naturally rather than navigating complex forms. With Strands Agents and Amazon Bedrock, you can build that experience in one afternoon.

Start small, learn from user feedback, and gradually expand your agent’s capabilities. To get started, contact your AWS representative.

Ralph Gimash

Ralph Gimash

Ralph is a seasoned solutions architect at AWS working with government technology ISVs. He holds a master’s degree in both software engineering and business administration. He has deep technical understanding and expertise from working with worldwide energy, financial services, cloud monitoring, and public sector companies. In his free time, Ralph enjoys traveling and immersing himself in new cultures and experiences with his friends and family.