Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Free: 6-day Agentic AI Engineering Email Guide.
Learnings from Towards AI's hands-on work with real clients.
End-to-End Workflow Automation with n8n: Google Forms, Sheets, MongoDB, and AI
Latest   Machine Learning

End-to-End Workflow Automation with n8n: Google Forms, Sheets, MongoDB, and AI

Last Updated on October 4, 2025 by Editorial Team

Author(s): Jeet Mukherjee

Originally published on Towards AI.

End-to-End Workflow Automation with n8n: Google Forms, Sheets, MongoDB, and AI

Well, it’s not just a hype. This is the simplest interface for building some of the most complex automation workflows. For all those who want to automate their work, use this tool. You’ll be amazed by seeing what a layer of abstraction can do.

But we’re building agents, right? Well, let’s just say we are automating an AI workflow.

So, in this article, we will build a workflow to automate the process of getting data after form submission, saving it in MongoDB, and then sending a welcome email created by LLM to a particular email address. This is going to be the most beginner-friendly article about n8n.

Setting-up n8n

We’ll start by setting up n8n on our local machine. This is quite simple. Make sure you have Node(≥18) installed.

# Check if you have Node installed or not
node -v
npm -v
# Install n8n globally
npm install n8n -g
# Command to start n8n
n8n

Now you can access it here — http://localhost:5678

Make sure to use the Chrome browser; I faced issues with Safari.

You should see an interface like this once you visit the above-mentioned URL.

There’s an orange button in the top right corner to get started. A blank workflow page should look like this —

Setting Up a Google Form with n8n

You can create a Google Form here. I have created a demo form; you can access it here (But you won’t receive any mail after filling it out).

But we can’t create a trigger on a Google Form, so we will create a trigger on a Google Sheet that stores the submitted data of the form. Make sure to enable Link to Sheets in the response tab.

Now, in the n8n workflow, click on add first step.

Upon clicking on “On row added or updated” you should see something like this —

Here, by clicking on “Select Credential”, you will get the option “Create New Credential”.

You need to collect your Client ID and Client Secret from Google Cloud Console.

First, you need to enable the Google Sheets API. Make sure you have a client created with the OAuth Redirect URL given by n8n. Remember, you also need to enable the Google Drive API.

Once you complete the setup, click on the Sign in with Google button.

Upon completing a successful setup, you should get a message showing that the setup is done.

Setting up MongoDB with n8n

You need to collect the MongoDB string from MongoDB Atlas. And add it in the n8n Connection String field. Also, add the database name in the Database field.

n8n Portal
Mongo DB Atlas

It’s as simple as that. Let’s get back to the workflow, and things will make more sense.

The Workflow

Our workflow should look something like this. We have two new components that we haven’t discussed yet: the AI Agent and Gmail.

The basic idea is to summarize an email message for the new user who just submitted the form. So, here is the flow —

  1. User submits a form, and the data is added to the sheet.
  2. A function to organize data in proper JSON format (optional)
  3. An AI Agent to summarize a welcome mail for the new users.
  4. A set to format the input data for MongoDB (Will add later)
  5. Store all the data in a MongoDB database.

Now, if everything works fine, click on the Google Sheets Trigger. You should see something like this —

Choose the Document, in our case, it is n8n test. Just below it, you’ll have an option to choose the Sheet.

Next, add a model for the AI Agent. I am gonna choose Groq. Make sure you have credentials from the groq api.

— These are the details of the language model.

You can also add a Simple Memory and Tool, just by clicking on the add button in the bottom section of the AI Agent.

But in our case, we don’t need any memory or tools. We’re gonna open the Groq Chat Model and add this prompt —

Write a greeting email to {{ $json.Name }} by saying this was a process of testing the n8n workflow.

We also need to add an output parser, as we want the output of the AI Agent to be properly formatted so that we can use it for sending emails. And this can easily be done by clicking on the AI Agent component. Make sure this is turned on —

The workflow should now look something like this —

Now, by following the same process as Google Sheets and Drive, you need to enable the Gmail API.

Once the Gmail API is ready to be used, make sure the Parameters fields are properly set up. Take a look at the image below to understand the syntax.

Finally, we need to store data in MongoDB, but this part is little tricky. Let’s start by adding a Set before sending data to MongoDB.

This section is to properly build the inputs for MongoDB. You need to add this syntax to the JSON field.

={{ 
{
name: $node["Google Sheets Trigger"].json["Name"],
email: $node["Google Sheets Trigger"].json["Email Id"],
subject: $('AI Agent').item.json.output.subject,
message: $('AI Agent').item.json.output.message
}
}}

As you can see, the above fields are taken out of multiple fields created through the previous steps of the workflow.

Once we have all the inputs ready, let’s simply put them into the MongoDB field.

And this is the entire workflow. Below is the output from my MongoDB database.

Also, here’s the snap of the mail I received in my inbox —

Make sure the workflow is activated, then only your workflow will execute automatically.

Conclusion

Well, this was just a simple implementation of the n8n workflow; the main idea was to give you a detailed overview of how multiple components can be used and integrated. Here, we tried to use multiple Google products, including the gmail api. Also, we integrated a MongoDB database. This guide should give you a great starting point for n8n.

Hope you enjoyed, feel free to add some thoughts in the comment section. Thanks 🙂

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI


Towards AI Academy

We Build Enterprise-Grade AI. We'll Teach You to Master It Too.

15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.

Start free — no commitment:

6-Day Agentic AI Engineering Email Guide — one practical lesson per day

Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages

Our courses:

AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.

Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.

AI for Work — Understand, evaluate, and apply AI for complex work tasks.

Note: Article content contains the views of the contributing authors and not Towards AI.