Add AI fill to any HTML form with one script tag

Updated 2026-10-30

Your visitors are tired of typing into boxes. Let their AI do it. Paste one script tag right below your form. A button appears. Your visitor gives your questions to Claude, ChatGPT or any other AI, pastes the answer back, and the boxes fill. You need no account and no API key.

What you paste

Here is a small form with the script below it. Copy all of it, or only the last line.

html
<form id="contact-form" action="/thanks" method="post">
  <label for="name">Your name</label>
  <input id="name" name="name" required>

  <label for="email">Email</label>
  <input id="email" name="email" type="email" required>

  <label for="message">Message</label>
  <textarea id="message" name="message"></textarea>

  <button type="submit">Send</button>
</form>

<script src="https://aiformapi.com/agent-fill.js" data-form="#contact-form"></script>

The last line is the script. The data-form part says which form to use. #contact-form means "the form whose id is contact-form". Change it to the id of your own form.

What your visitor sees

  1. A button shows above your form: "Fill this form with my AI agent".
  2. They press it. A window opens with a prompt. They copy it and give it to their AI.
  3. The AI asks for anything it does not know. Then it replies with one block of text.
  4. They paste that block into the window and press "Fill the form".
  5. The boxes fill. The window says nothing was sent. They read the form and press your own Submit button.

Find your form's id

Open your page in a browser. Right-click the form and choose Inspect. Look for the line that starts with <form. If it has id="something", write #something in data-form. If it has a class, such as class="signup", write .signup. If it has neither, add an id to your form's HTML.

Options

Set these on the script tag. All of them are optional.

AttributeWhat it does
data-formA CSS selector for your form, such as #contact-form.
data-titleThe form name in the prompt. Default: the page title.
data-form-idThe id inside the prompt. Default: the form's id or name.
data-buttonThe words on the button.

When nothing shows up

I tested these cases. In each one the script stays silent.

  • The page has two forms and no data-form. A search box in the page header counts as a form. Add data-form.
  • data-form matches nothing. Check the id for typos.
  • The form is inside an iframe. The script cannot see into another frame. Read the iframe guide.
  • The form appears after the page has loaded. Call window.AgentFill.mount(form) from your own code once the form exists.

If your form has no label tags, the script uses the placeholder, then the field name. Real labels give your visitor's AI better questions.

What it never reads

Password fields, hidden fields, file uploads, and fields that ask for card numbers, codes, IBANs, passport or national ID numbers. The window lists them as "Not shared with the agent". The visitor types them by hand.

More detail is in the agent-fill.js docs. To pick between keeping your form and embedding ours, see the guides hub.

Sources (read 2026-10-30)

Questions

Where do I put the script tag?

Put it anywhere on the page that holds the form. Right below the form is the easiest place. The script waits until the page has loaded, so above or below both work. The button always appears above the form, not where the script sits.

Why do I see no button?

Three causes are common. The page has more than one form and the script has no data-form attribute. The data-form selector matches nothing. Or the form sits inside an iframe, which the script cannot read. In all three cases the script stays silent and shows no error.

Does the script send my visitors' answers anywhere?

No. After the browser has downloaded the script, it makes no network request. The labels, the prompt and the answers stay on your page. Your visitor presses your own Submit button, and your form sends the data as it does today.