Using Google Script to set up auto-response for Google forms respondents

If your are currently setting up your own survey using Google forms, why not add a personalizing feature to it and sent your respondents automatic e-mails with individual content based on their responses? This blogpost is aiming to give the interested an insight into how we connected Google forms with Google scripts for our survey. We specifically used Google scripts to send the respondents automatically generated e-mails with the result of their survey as something of an ‘incentive’, communicating the survey as a “personality quiz”.

This is therefore something of a walk through on how to add a script to your forms and how we used it in particular.

Starting on your finished online survey you constructed using Google forms, you go to the Google spreadsheet where the results of your survey are saved into:

The Google spreadsheet then opens in a new Browser tab. When it is loaded, click on “tools” and “script editor” which will open the script editor in a new tab:


Once your script editor is open, you see an empty function which you just delete. You can use different programming languages with Scripts and use it for different things for which you can find help on the documentation page. We however used javascript in order to create a function that sends automatically generated e-mails to respondents the moment they submit the form. Based on their answers, the respondents can be assorted to one out of 6 “news reader types” and accordingly receive an e-mail with a description of their type. This is the code we wrote:


This is an image, so you will not be able to copy the code here. You can however have a look at it in this pdf and copy it from there.

Once you set up the script, you have to save it (choose any name you want) and to set the triggers for it, in this case the trigger ‘onFormSubmit’. You can do this, by clicking on “Resources” and “add new triggers”. This script needs authorization since it wants to send e-mails from your e-mail account. If you do not want to use your personal e-mail, you should set up a new g-mail account for it. Once you gave authorization to the script, it will automatically send e-mails to the respondents the moment they submit the Google form.


We hope that may help you, if you are doing a similar project or are just curious about the possibilities of using Google forms.

Tags: , , , ,