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.
Process Contact Form Submissions with Validation and MongoDB Storage
This n8n workflow provides a robust solution for handling contact form submissions. It captures form data, performs essential validation, and securely stores the processed information in a MongoDB database. Additionally, it offers a user-friendly form interface for submissions.
What it does
- Listens for Form Submissions: The workflow is triggered by submissions to an n8n-generated web form.
- Provides a User-Friendly Form: An n8n Form node is included, allowing for easy creation and hosting of the contact form itself.
- Edits Fields (Data Transformation): A "Set" node (renamed to "Edit Fields") is included, suggesting a step for data transformation or manipulation before storage. This could be used for formatting, adding timestamps, or other pre-processing.
- Executes Custom Logic (Validation/Processing): A "Code" node is present, indicating that custom JavaScript logic can be executed. This is ideal for implementing data validation rules (e.g., checking for valid email formats, required fields) or additional processing.
- Stores Data in MongoDB: Validated and processed form data is then inserted into a specified MongoDB collection.
Prerequisites/Requirements
- n8n Instance: A running n8n instance to host and execute the workflow.
- MongoDB Account/Instance: Access to a MongoDB database where the form submissions will be stored. You will need the connection details and credentials.
- n8n MongoDB Credential: An n8n credential configured for your MongoDB instance.
Setup/Usage
- Import the Workflow: Import the provided JSON into your n8n instance.
- Configure MongoDB Credentials:
- Locate the "MongoDB" node.
- Click on "Credential" and either select an existing MongoDB credential or create a new one.
- Provide your MongoDB connection string, database name, and other necessary details.
- Configure the Form:
- Locate the "n8n Form Trigger" node. This node generates the URL for your form.
- Locate the "Form" node. This node defines the structure and fields of your web form. Customize the fields to match your contact form requirements (e.g., Name, Email, Message).
- Customize Data Transformation:
- Review the "Edit Fields" (Set) node. Adjust its configuration if you need to rename, add, or modify fields before they are sent to MongoDB.
- Implement Validation/Custom Logic:
- Open the "Code" node.
- Add JavaScript code to perform any necessary data validation (e.g., checking if email is valid, if required fields are present). You can also add logic to transform data further or handle errors.
- Activate the Workflow: Once configured, activate the workflow to make the form publicly accessible and start processing submissions.
- Share the Form URL: The "n8n Form Trigger" node will provide a unique URL for your form. Share this URL with your users or embed it on your website.
Related Templates
AI-powered code review with linting, red-marked corrections in Google Sheets & Slack
Advanced Code Review Automation (AI + Lint + Slack) Whoโs it for For software engineers, QA teams, and tech leads who want to automate intelligent code reviews with both AI-driven suggestions and rule-based linting โ all managed in Google Sheets with instant Slack summaries. How it works This workflow performs a two-layer review system: Lint Check: Runs a lightweight static analysis to find common issues (e.g., use of var, console.log, unbalanced braces). AI Review: Sends valid code to Gemini AI, which provides human-like review feedback with severity classification (Critical, Major, Minor) and visual highlights (red/orange tags). Formatter: Combines lint and AI results, calculating an overall score (0โ10). Aggregator: Summarizes results for quick comparison. Google Sheets Writer: Appends results to your review log. Slack Notification: Posts a concise summary (e.g., number of issues and average score) to your teamโs channel. How to set up Connect Google Sheets and Slack credentials in n8n. Replace placeholders (<YOURSPREADSHEETID>, <YOURSHEETGIDORNAME>, <YOURSLACKCHANNEL_ID>). Adjust the AI review prompt or lint rules as needed. Activate the workflow โ reviews will start automatically whenever new code is added to the sheet. Requirements Google Sheets and Slack integrations enabled A configured AI node (Gemini, OpenAI, or compatible) Proper permissions to write to your target Google Sheet How to customize Add more linting rules (naming conventions, spacing, forbidden APIs) Extend the AI prompt for project-specific guidelines Customize the Slack message formatting Export analytics to a dashboard (e.g., Notion or Data Studio) Why itโs valuable This workflow brings realistic, team-oriented AI-assisted code review to n8n โ combining the speed of automated linting with the nuance of human-style feedback. It saves time, improves code quality, and keeps your teamโs review history transparent and centralized.
Generate Weather-Based Date Itineraries with Google Places, OpenRouter AI, and Slack
๐งฉ What this template does This workflow builds a 120-minute local date course around your starting point by querying Google Places for nearby spots, selecting the top candidates, fetching real-time weather data, letting an AI generate a matching emoji, and drafting a friendly itinerary summary with an LLM in both English and Japanese. It then posts the full bilingual plan with a walking route link and weather emoji to Slack. ๐ฅ Who itโs for Makers and teams who want a plug-and-play bilingual local itinerary generator with weather awareness โ no custom code required. โ๏ธ How it works Trigger โ Manual (or schedule/webhook). Discovery โ Google Places nearby search within a configurable radius. Selection โ Rank by rating and pick the top 3. Weather โ Fetch current weather (via OpenWeatherMap). Emoji โ Use an AI model to match the weather with an emoji ๐ค๏ธ. Planning โ An LLM writes the itinerary in Markdown (JP + EN). Route โ Compose a Google Maps walking route URL. Share โ Post the bilingual itinerary, route link, and weather emoji to Slack. ๐งฐ Requirements n8n (Cloud or self-hosted) Google Maps Platform (Places API) OpenWeatherMap API key Slack Bot (chat:write) LLM provider (e.g., OpenRouter or DeepL for translation) ๐ Setup (quick) Open Set โ Fields: Config and fill in coords/radius/time limit. Connect Credentials for Google, OpenWeatherMap, Slack, and your LLM. Test the workflow and confirm the bilingual plan + weather emoji appear in Slack. ๐ Customize Adjust ranking filters (type, min rating). Modify translation settings (target language or tone). Change output layout (side-by-side vs separated). Tune emoji logic or travel mode. Add error handling, retries, or logging for production use.
AI-powered document search with Oracle and ONNX embeddings for recruiting
How it works Create a user for doing Hybrid Search. Clear Existing Data, if present. Add Documents into the table. Create a hybrid index. Run Semantic search on the Documents table for "prioritize teamwork and leadership experience". Run Hybrid search for the text input in the Chat interface on the Documents table. Setup Steps Download the ONNX model allMiniLML12v2augmented.zip Extract the ZIP file on the database server into a directory, for example /opt/oracle/onnx. After extraction, the folder contents should look like: bash bash-4.4$ pwd /opt/oracle/onnx bash-4.4$ ls allMiniLML12_v2.onnx Connect as SYSDBA and create the DBA user sql -- Create DBA user CREATE USER app_admin IDENTIFIED BY "StrongPassword123" DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON users; -- Grant privileges GRANT DBA TO app_admin; GRANT CREATE TABLESPACE, ALTER TABLESPACE, DROP TABLESPACE TO app_admin; Create n8n Oracle DB credentials hybridsearchuser โ for hybrid search operations dbadocuser โ for DBA setup (user and tablespace creation) Run the workflow Click the manual Trigger It displays Pure semantic search results. Enter search text in Chat interface It displays results for vector and keyword search. Note The workflow currently creates the hybrid search user, docuser with the password visible in plain text inside the n8n Execute SQL node. For better security, consider performing the user creation manually outside n8n. Oracle 23ai or 26ai Database has to be used. Reference Hybrid Search End-End Example