Skip to main content

Process contact form submissions with validation and MongoDB storage

Workflow preview

Workflow preview
100%
Process contact form submissions with validation and MongoDB storage preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This n8n workflow securely processes contact form submissions by validating user input, formatting the data, and storing it in a MongoDB database. The flow ensures data consistency, prevents unsafe...

Best for

  • Document Extraction automation workflows
  • Lead Generation automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.code, n8n-nodes-base.formtrigger, n8n-nodes-base.mongodb, n8n-nodes-base.set, n8n-nodes-base.form

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Samuel Heredia.

Original n8n.io source

1.1 Workflow description

Title
Process contact form submissions with validation and MongoDB storage
Workflow name
Process contact form submissions with validation and MongoDB storage

This n8n workflow securely processes contact form submissions by validating user input, formatting the data, and storing it in a MongoDB database. The flow ensures data consistency, prevents unsafe entries, and provides a confirmation response back to the user.

Workflow

1. Form Submission Node

Purpose: Serves as the workflow’s entry point.

Functionality: Captures user input from the contact form, which typically includes:

name
last name
email
phone number

2. Code Node (Validation Layer)

Purpose: Ensures that collected data is valid and secure.

Validations performed:

  • Removes suspicious characters to mitigate risks like SQL injection or script injection.

  • Validates the phone_number field format (numeric, correct length, etc.).

  • If any field fails validation, the entry is marked as “is_not_valid” to block it from database insertion.

3. Edit Fields Node (Data Formatting)

Purpose: Normalizes data before database insertion.

Transformations applied:

  • Converts field names to snake_case (first_name, last_name, phone_number).

  • Standardizes field naming convention for consistency in MongoDB storage.

4. MongoDB Node (Insert Documents)

Purpose: Persists validated data in MongoDB Atlas.

Process:

  • Inserts documents into the target collection with the cleaned and formatted fields.

  • Connection is established securely using a MongoDB Atlas connection string (URI).

🔧 How to Set Up MongoDB Atlas Connection URL

a. Create a Cluster

b. Log in to MongoDB Atlas and create a new cluster.

c. Configure Database Access: Add a database user with a secure username and password, Assign appropriate roles (e.g., Atlas Admin for full access or Read/Write for limited).

d. Obtain Connection String (URI)

From Atlas, go to Clusters → Connect → Drivers.

Copy the provided connection string, which looks like:

mongodb+srv://<username>:<password>@cluster0.abcd123.mongodb.net/myDatabase?retryWrites=true&w=majority
  • Configure in n8n In the MongoDB node, paste the URI.

Replace <username>, <password>, and myDatabase with your actual credentials and database name.

  • Test the connection to ensure it is successful.

5. Form Ending Node

Purpose: Provides closure to the workflow.

Functionality: Sends a confirmation response back to the user, indicating that their contact details were successfully submitted and stored.

Result: With this workflow, all contact form submissions are safely validated, normalized, and stored in MongoDB Atlas, ensuring both data integrity and security basic.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Validate Pattern

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note9

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Sticky Note10

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - On form submission

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.3

Block 10 - Insert documents

Type / Role
n8n-nodes-base.mongoDb - mongoDb
Config choices
Version 1.2

Block 11 - Edit Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 12 - Sticky Note11

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note12

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Form Ending

Type / Role
n8n-nodes-base.form - form
Config choices
Version 2.3

Block 15 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Process contact form submissions with validation and MongoDB storage
Complexity advanced
Nodes 16
Categories Document Extraction, Lead Generation
Author Samuel Heredia
Published 30 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8071/8071.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Process contact form submissions with validation and MongoDB storage do?

This n8n workflow securely processes contact form submissions by validating user input, formatting the data, and storing it in a MongoDB database. The flow ensures data consistency, prevents unsafe...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction, Lead Generation use case.