Task guide
Respond to a Google Form submission
Get an email every time someone submits your Google Form, listing each question and its answer. The email goes only to you, the owner of the script.
1 · Prepare
Put these pieces in place
- Open the script project attached to the Google Form. In the form, click the three-dot menu at the top right and choose Script editor.
- Use a form with at least one question, so each response has something to summarize.
- Sign in as the account that should receive the emails, because the trigger sends them to the account that installs it.
Change these values
- Email subject
New form responseThis is the subject in the notification email.
2 · Review before running
What the script can access and change
Permissions you approve
- See, edit, create, and delete all your Google Forms forms. The code only reads the answers in each new response to this Form.
- Read, compose, send, and permanently delete all your email from Gmail. Google asks for full Gmail access because the code uses GmailApp, but the code only sends the summary to your own address.
- See your primary Google Account email address. The code reads it to know where to send the summary.
Effects of one run
- Sends one email to the account that installed the trigger after each new form submission, listing every question title and its answer.
- Does not change or delete any form response, and does not email the respondent.
3 · Copy
Paste this into the Apps Script editor
Create or open a script file, replace the example values marked above, then save the project.
const EMAIL_SUBJECT = 'New form response'; // This is the subject in the notification email.
/** @param {Events.FormsOnFormSubmit} event */
function emailFormSummary(event) {
const response = event.response;
const answers = response.getItemResponses().map((itemResponse) => {
return itemResponse.getItem().getTitle() + ': ' + itemResponse.getResponse();
});
const message = answers.length ? answers.join('\n') : 'A form response was received with no answers.';
const recipient = Session.getEffectiveUser().getEmail();
GmailApp.sendEmail(recipient, EMAIL_SUBJECT, message);
} 4 · Run
Follow these steps in order
Paste the function and save
In the script project attached to the form, replace the starter code with this function and save. Do not click Run in the editor, because there is no submitted response there to work with.
Install the trigger
Click Triggers, the clock icon in the left sidebar, then click Add Trigger. Choose emailFormSummary as the function, From form as the event source, and On form submit as the event type. Click Save and approve access when Google asks.
Submit one test response yourself
Open the form as a respondent, answer at least one question, and submit it. Within a minute, an email with the subject New form response arrives in the inbox of the account that installed the trigger.
5 · Confirm
How to tell it worked
After each submission, an email with the subject New form response arrives, with one line per question in the form Question: answer.
If the result is different
Troubleshooting
- Clicking Run in the editor shows "TypeError: Cannot read properties of undefined (reading 'response')".
- Test the function by submitting the form instead. The Run button calls it with no submission, so there is no event.response to read.
- No email arrives after a test submission.
- Open Triggers and check that the trigger runs emailFormSummary with From form and On form submit. Then open Executions to see whether the run failed. If it says authorization is required, delete the trigger, add it again, and approve access when Google asks.
Technical details
Names used in this script
Open these details when you want to adapt the example or look up an exact service or method name.
Show Apps Script symbols and service pages
Apps Script symbols
Service pages
Keep going
Related tasks, basics, and apps
- Task guide Run an Apps Script function every day
Make a function run on its own once a day. Run the setup function once, and from then on Apps Script calls the reminder function each day around the hour you chose.
- Task guide Create a Google Doc from each Sheet row
Create one short Google Doc for each row on a Projects tab that has no document link yet. The script writes the link to the new Doc back into the row.
- Object reference Form
A FormApp.Form is the Google Form itself. Get it with FormApp.getActiveForm() or openById(id). Read its questions with getItems() or count submissions with getResponses().
- Object reference Form response
A FormResponse contains the answers sent in one Google Form submission. A form-bound submit trigger passes it to your function as event.response, where getItemResponses() returns the submitted item responses.
- Object reference Trigger builder
ScriptApp.newTrigger(functionName) returns a TriggerBuilder that configures a timeBased(), forSpreadsheet(), or forForm() trigger before create() saves it.
- Basics Google Apps Script triggers explained
Google Apps Script triggers run functions automatically when a file opens, a cell changes, a form is submitted, or a scheduled time arrives. Use a simple onEdit or onOpen for work in the bound file. Choose an installable trigger for a schedule, form submission, or work that needs authorization.
- Google app Google Forms
FormApp scripts and form-bound submit triggers run when someone submits a Google Form, passing event.response to your function.
- Google app Triggers
A trigger is a saved schedule or event rule in ScriptApp that runs your function on time, on edit, or on form submit.
- Google app Gmail
GmailApp scripts can send messages, search threads, apply labels, and read attachments after you approve Gmail access for the project.