Skip to main content
Manually filling out multiple web forms can be repetitive and time-consuming. With the Agent Platform JavaScript SDK, you can automate this process using the fillForms() function. This function lets AI agents:
  • Find and fill multiple web forms automatically.
  • Add user-provided data efficiently and accurately.
  • Track the status of each submission in real time.
  • Complete all tasks without manual intervention.

Example

The sample below shows you how to fill and automate forms:
async function fillForms() {
  for (const form of forms) {
    const task = await agent.fillForm(form);

    task.onStatusChange((status) => {
      console.log(`Form ${form.url}: ${status}`);
    });

    await task.waitForCompletion();
    console.log(`Form ${form.url} submission completed!`);
  }
}

fillForms().catch(console.error);

Fill and automate forms

The steps below show you how to fill and automate forms using the Agent Platform JavaScript SDK:

Step 1: Define the forms

Create an array of forms with the URL and data you want to submit.
const forms = [
  {
    url: 'https://example1.com/contact',
    fields: {
      name: 'John Doe',
      email: 'john@example.com',
      message: 'Hello!'
    }
  },
  {
    url: 'https://example2.com/signup',
    fields: {
      username: 'johndoe',
      email: 'john@example.com',
      password: 'SecurePass123'
    }
  }
];

Step 2: Start a form-filling task

For each form, call agent.fillForm(url, data) to let the agent fill the form automatically.
const task = await agent.fillForm(form);

Step 3: Track task status

Use task.onStatusChange to monitor updates and see progress in real time.
task.onStatusChange((status) => {
  console.log(`Form ${form.url}: ${status}`);
});

Step 4: Wait for completion

Call await task.waitForCompletion() to ensure the agent finishes before moving on to the next form.
await task.waitForCompletion();
I