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!
- 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.
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.
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.
A script doesn't have to do just one thing. When the doPost function catches data, it can perform many tasks in a row:
- Task A: Write the data to your Google Sheet.
- Task B: Send the confirmation email.
The computer is so fast it will do both in less than a second!
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.
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!");
}
Copy this code. Remember to Manage Deployments and create a New Version after pasting!
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:
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!
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.
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!
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!
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 🏗️