How to send email based on a response in Google Forms

With Google Forms, you can collect responses and opinions from your respondents in a variety of ways, be it a simple quiz or a long questionnaire. While it has several handy native features, Google Forms does not yet allow you to natively send email notifications to yourself or the respondent.

The latter comes to the picture when you want to thank the user for their response and time. On the other hand, if your form appeals to a large audience and involves multiple departments, searching through all of the form responses is time-consuming.

Fortunately, there are a few workarounds you can use to send email to the owner or to individuals. Now there are two ways to go about this.

You can either send an email based on a response to your form. Or, you can send one based on the responses users chose. And as mentioned earlier, both methods require the help of an external add-on. Since you are sending an e-mail from your account, you must grant the add-on or function the appropriate permissions.

Now that we have it sorted out let’s get started, shall we?

How to send a generic email using Google Forms

Luckily, sending a generic email to either the user or the owner isn’t rocket science. The aptly named form notification add-on lets you send simple thank you emails to users.

Step 1: After you’ve created the form, right click on the three-dot menu and select Add-ons from the list. This will take you to the Google Marketplace.

Step 2: Now look for Form Notifications and click on it to install.

Next, create the form. If you want to send the emails directly to the respondent, select the Collect emails check box under Settings.

How to send an email based on a reply in Google Forms 3

Or you can set up a form question asking for the user’s email and mark it as Required as shown below.

How to send an email based on a reply in Google Forms 4

Step 3: When you’re done, click the little add-on icon and choose Form Notifications. You will see a prompt in the lower right corner.

How to send an email based on a reply in Google Forms 5

Toggle the thank you email button.

How to send an email based on a reply in Google Forms 6

As mentioned earlier, you can use either the Automatic field or the Form field. Choose the one that best suits your needs. At the same time, you can also add a Bcc for the email by filling in the “Send a copy to” field.

Step 4: Next, add the subject and body of the email, and that’s it! Save the settings and click the preview icon at the top to see if the current configurations work for you.

How to send email based on a reply in Google Forms 7

This is a simple add-on, and configuration is simple and straightforward. And the one published by Google Cloud Tag also makes it a bit reliable.

Aside from the above, you can also email yourself (or the creator) if the form has a fixed number of responses.

To do this, toggle the button for “Notify me on form response”. The email address of the creator is automatically entered in the recipient field. It’s not hard-coded and you can enter other email addresses as well.

How to send an email based on a reply in Google Forms 1

When you’re done, add the notification threshold and hit the save button. From now on, your form will shoot an email as soon as it crosses the response threshold.

How to send responses based on responses

Let’s put it right there. As described above, if you want to send responses based on the responses in your form, it is not easy. Here you have to tinker with the app script of the connected spreadsheet.

Fortunately, if you have a simple form, it should be easy to do. In our case, we have a simple form in which we ask respondents what their preferred vacation spot is.

2 how to send email based on a reply in Google Forms 89

And depending on the answers in the form, an email will be sent to a specified email address. Of course, the code can be adapted to the needs of your form.

Step 1: Once your form is created, click the Responses tab and tap the little table icon on the right. This will connect your form to a table.

2 How to send email based on a response in Google Forms 3

Step 2: Go to the table and click Tools> Script Editor.

2 How to send email based on a response in Google Forms 4

In the script editor, paste the following lines of code:

                      function checkLocation(e) {
 var subject="";
 var values = e.namedValues;
 var prefLocation="";

for (Key in values) {
 var label = Key;
 var data = values[Key];
 prefLocation=data;
 Logger.log(data);
 }
}

                    

Here, e is the event that is triggered when the form is submitted while the e.namedValues ​​object brings you the form data in the form of an array.

Once this data is collected, the For statement loops through the array to show you the data. At the end, the form data for this special answer is assigned to the variable prefLocation.

Step 3: In the meantime, click the little clock icon in the left pane to access the triggers and choose Add Triggers.

2 How to send email based on a response in Google Forms 6

Select From table as the event source and When sending as the event type.

2 How to send email based on a response in Google Forms 7

This ensures that the function described above is only triggered when the form is sent. And when it is submitted, it only pulls data from the linked table.

Step 4: Now return to the Script Editor to modify the code as per your needs.

In our case, we want an email to be sent to a specific email id when a Hills respondent replies, and so on.

So we added a simple If and Else-If condition to the code,

                       function checkLocation(e) {
 var subject="";
 var values = e.namedValues;
 var prefLocation="";

 for (Key in values) {
 var label = Key;
 var data = values[Key];
 prefLocation=data;
 Logger.log(data);
 if (prefLocation=="Hills"){
 subject="You have an email for Hills Location"; 
 GmailApp.sendEmail('[email protected]', subject, prefLocation);
 }else if (prefLocation=="Beaches"){
 subject="You have an email for Beaches Location";
 GmailApp.sendEmail('[email protected]', subject, prefLocation);
 } 
 else if(prefLocation=="Cities") {
 subject="You have an email for Cities Location";
 GmailApp.sendEmail('[email protected]', subject, prefLocation);
 }
}
}
                    

Of course, you need to give permission for the GmailApp.sendEmail feature to work. However, it is a one-time process.

Step 5: Now that everything is in place, save your code by clicking the save icon as shown below.

2 How to send an email based on a reply in Google Forms 29

Now run the code. Unfortunately, without an event, you will not be able to run the code directly from the Script Editor.

Submit your form for your code to run. If everything is in the right place, you will likely receive an email.

Once you’re done, you can customize the code to your liking and add custom If-Else conditions. At the same time, you can also compose the text of the email according to the data.

How to check for errors

It’s rare to get code right the first time without errors, and to be honest, there are a lot of things that can go wrong. To check for errors go to the Executions tab and you will see all the instances that the function has called.

2 How to send an email based on a reply in Google Forms 9

Click to view the errors. Here you can also see how the function was called. A trigger tag is translated into a form submission, while an editor tag means that the function was performed through the editor.

If you want to check the value of the function at the same time, just add the Logger.log (variable) to log the data.

2 How to send email based on a response in Google Forms 2

For example, we called Logger.log (prefLocation) within each If-Else condition, and our log looked like the one above.

To code or not to code

The second method can look a little tricky. But once you get the hang of how each function is called, the chances get a little easier.

But at the end of the day, if you don’t want to get your hands dirty, you can E-mail notification forms Add on. This is designed for sending emails based on conditional responses. However, the conditional formatting feature isn’t free and costs around $ 4 per month for a single-user license.

So if you need to send responses for your forms occasionally, you can paste the code above into the app script editor.

Related Posts