How to submit Airtable Form with Puppeteer
Learn how to submit your Airtable form automatically using Puppeteer
This is a simple Nodejs script sample that will show how you can programmatically submit Airtable Form automatically using Puppeteer(a Node library to control Chromium-based browser). In this tutorial, I will talk about Puppeteer and Airtable prefill methods to auto-submit forms.
I am assuming you have at least some knowledge of running the Nodejs script. You can use the same method to submit any Airtable data from other data sources (Google Sheets), the only thing you need to consider is to create it as a JSON array. If you are looking for advanced usage, please consider using Airtable API.
Personal Experience
I created this script and a Chrome extension (which I will talk about later) for my client when I saw they used to enter so many similar details from websites more than 100 times a day. I would like to let you know that there are some issues when submitting multiple forms simultaneously. If you are looking for prefilling and auto-submitting for so many pages, I would suggest reading this thread.
Requirements
Your Airtable Form
Node.js on your computer ( How to setup Nodejs )
A Good IDE (mine is VS Code)
Data in JSON format
Little JS knowledge (even on How to run Nodejs script would be helpful)
What is Puppeteer?
Puppeteer is a Nodejs library used to control headless Chromium browsers. In layman's terms, you can use this library to do things like making screenshots, browser actions, and many more without opening Chrome. If it doesn't ring a bell, then watch this useful video from Google and read this article.
Setup project
Create a folder (pick your name)
Open that folder in VS Code
From the VS Code terminal, npm init
Now, install Puppeteer, using npm install puppeteer
Create index.js
Copy & paste our code below
Make necessary changes
Code: index.js
Make necessary changes
Replace the Airtable URL by updating the URL on baseURL from the script.
Add prefill variable using prefill_"Variable from Airtable Form". Please note %20 is for space. You don't need it if there is no space. From the below Form image, you can see that prefill_Company%20Name, prefill_Company%20Domain is an example.
- That's it, run the code by node index.js
Useful Resources
CSV/Excel to JSON
If your data source is a CSV file, then it's better to use something like an online converter.
Google Sheet to JSON
If you have the details on Google Sheets and want to convert them into JSON, please check this article or use SheetDB. Please make the decision based on your requirements, if you just need to convert the sheet to JSON.
Conclusion
Finally, you got the working Nodejs script to automatically submit the Airtable form based on your data. I hope this is helpful for you. If you are stuck somewhere or need some help, please use the comment section below or contact us.