Skip to content

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

Change these values

Make the code yours before you run it.
Email subject
New form response

This 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.

Code.gs
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

  1. 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.

  2. 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.

  3. 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

Keep going