Module 13 / 15

Project: The Auto-Responder

Make your script say "Thank You" to your readers automatically.

We are going to take the form from Module 12 and give it a voice. By the end of this module, your blog will be acting like a professional company!

What You Will Learn
  • How to collect an Email Address from your blog.
  • How to use that address to send a personalized reply.
  • How to combine "Saving to Sheets" and "Sending Email" in one go.
Who Is This For?

This is for the "Customer Experience" specialist. If you want to make sure your readers know you received their message, this auto-responder is the perfect solution.

Real Life Connection

Think of Ordering Food Online.

As soon as you pay for your burger, you get an email saying "We got your order! It's cooking!" That email makes you feel safe. Today, you are building that same feeling for your blog readers.

The "Double Action" Script

A script doesn't have to do just one thing. When the doPost function catches data, it can perform many tasks in a row:

  1. Task A: Write the data to your Google Sheet.
  2. Task B: Send the confirmation email.

The computer is so fast it will do both in less than a second!

The Auto-Responder Workflow
1. User types Email & Message 📧
⬇️
2. Script saves them to the Sheet 📊
⬇️
3. MailApp sends "Thank You" 🕊️
⬇️
4. Inbox Ding! 🔔
Updating the Logic

We need to add one more piece of data to our "Catching Glove": the Email. Then we use the MailApp command we learned in Module 10.

function doPost(e) {
  const name = e.parameter.name;
  const email = e.parameter.email;
  const msg = e.parameter.message;

  // Action 1: Save to Sheet
  SpreadsheetApp.getActiveSheet().appendRow([name, email, msg]);

  // Action 2: Send Email
  MailApp.sendEmail(email, "Got it!", "Thanks for the message!");
}
The "Full Professional" Script

Copy this code. Remember to Manage Deployments and create a New Version after pasting!

function doPost(e) { // 1. Get info from the Blogger Form const userName = e.parameter.name; const userEmail = e.parameter.email; const userMsg = e.parameter.message; // 2. Log to Sheet const sheet = SpreadsheetApp.getActiveSheet(); sheet.appendRow([new Date(), userName, userEmail, userMsg]); // 3. Send Auto-Reply const subject = "Thank you for contacting me, " + userName + "!"; const body = "Hi! I received your message: '" + userMsg + "'. I will get back to you soon."; MailApp.sendEmail(userEmail, subject, body); return ContentService.createTextOutput("Email Sent!"); }
Updating your Blogger HTML

In your Blogger page, you need to add an input for the email. Here is what your "Mini Script" on Blogger should look like now:

// In your Blogger HTML View:
fetch(url + "?name=" + nameVal + "&email=" + emailVal + "&message=" + msgVal);

When a reader types their real email and clicks send, they will see a notification in their inbox in seconds!

Why did the email not send?
Click for the responder checklist

1. Daily Limit: Google has a limit on how many emails you can send per day (usually 100 for free accounts). Don't go crazy testing it!

2. Parameter Names: If Blogger sends &user_email= but your script looks for e.parameter.email, it won't find it. The names must match exactly.

3. The "Allow" Popup: Because you added a new "Service" (MailApp), you might need to click Run once in the editor to trigger the authorization popup again.

The "Signature" Challenge

Can you add a custom signature at the end of the email body? Something like "Sent automatically by my Google Apps Script Robot". It makes your app look even cooler!

Who Else Uses This?

E-commerce sites like Shopify use this for every order. They don't have time to email 1,000 customers. They use a script just like this to handle the "Thank You" part so they can focus on shipping the products!

Module Summary

You have built a fully automated communication system! Your blog now talks back to its readers. You have combined data storage (Sheets) and communication (Gmail) into one powerful app.

Status: Communication Pro 📣 | Level: Automation Architect 🏗️

Type NEXT to unlock the next module 🚀