Skip to content

aimanzahar/googleform

Repository files navigation

Google Form Auto Submitter

This application automatically submits data to multiple Google Forms at scheduled intervals. It runs in a Docker container and can be configured to submit different data to different forms at regular intervals (default: every 5 hours).

Features

  • 🕒 Automatically submits to Google Forms at specified intervals
  • 📝 Supports multiple forms with different data
  • 🔄 Configurable submission schedule (using cron syntax)
  • 🎲 Optional randomization of submission times
  • 📊 Logs all submission attempts
  • 🔍 Includes a form inspector tool to help identify form field IDs
  • 🐳 Runs in a Docker container for easy deployment

Prerequisites

Setup

  1. Clone or download this repository
  2. Configure your form URLs and submission data in the .env file
  3. Build and run the Docker container

Configuration

Edit the .env file with your Google Form URLs and the data you want to submit:

# Google Form URLs (comma-separated list of form URLs)
GOOGLE_FORM_URLS=https://docs.google.com/forms/d/e/YOUR_FORM_ID_1/formResponse,https://docs.google.com/forms/d/e/YOUR_FORM_ID_2/formResponse

# Schedule (in cron format, default is every 5 hours)
SCHEDULE="0 */5 * * *"

# Submission Data (JSON format)
FORM_1_DATA={"entry.123456":"John Doe","entry.789012":"johndoe@example.com"}
FORM_2_DATA={"entry.345678":"Jane Smith","entry.901234":"janesmith@example.com"}

# Randomize submissions slightly (true/false)
RANDOMIZE_SUBMISSIONS=true

# Log submissions to file (true/false)
LOG_SUBMISSIONS=true

Finding Form Field IDs

To find the correct field IDs for your Google Form:

  1. Run the form inspector tool:
    npm run inspect
  2. Enter your Google Form URL when prompted
  3. The tool will display all form field IDs and provide an example configuration

Alternatively, you can:

  1. Open your Google Form in a browser
  2. Right-click and select "View Page Source"
  3. Search for "entry." in the page source
  4. Note the entry IDs (e.g., "entry.123456")

Running the Application

Using Docker Compose (recommended)

# Build and start the container
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the container
docker-compose down

Using Docker directly

# Build the Docker image
docker build -t googleform-auto-submitter .

# Run the container
docker run -d --name googleform-submitter -v $(pwd)/logs:/usr/src/app/logs -v $(pwd)/.env:/usr/src/app/.env googleform-auto-submitter

# Submit forms immediately (for testing)
docker run --rm -v $(pwd)/.env:/usr/src/app/.env googleform-auto-submitter npm run submit

Running without Docker

# Install dependencies
npm install

# Start the scheduler
npm start

# Submit forms immediately (for testing)
npm run submit

# Run the form inspector
npm run inspect

Logs

Submission logs are stored in the logs directory, with one file per day. Each log entry includes:

  • Timestamp
  • Form number
  • Success/failure status
  • HTTP status code
  • Any error messages

Advanced Configuration

Cron Schedule Syntax

The default schedule is every 5 hours. You can customize it using cron syntax:

  • 0 */5 * * * - Every 5 hours
  • 0 8,12,17 * * * - At 8am, 12pm, and 5pm every day
  • 0 9 * * 1-5 - At 9am on weekdays

Environment Variables

All configuration is done via environment variables in the .env file.

Troubleshooting

  • Form submission fails: Check if the form URLs are correct and end with /formResponse
  • Wrong form data: Use the form inspector to verify the correct field IDs
  • Container exits unexpectedly: Check the logs for error messages

Legal Considerations

This tool is intended for legitimate use cases. Please ensure you have permission to submit data to the forms in question and comply with all applicable laws and terms of service.

License

ISC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published