Skip to content

Task guide

Send a confirmation to the form respondent

Send each person who submits your Google Form a short thank-you email that repeats their answers. The form must collect verified email addresses.

1 · Prepare

Put these pieces in place

  • Turn on Collect email addresses in the form. Open the form, click Settings, open the Responses section, and set Collect email addresses to Verified. Without this setting, the response has no verified email address to reply to.
  • Use this only for a form whose respondents expect a confirmation, such as a sign-up or a request form. Do not use it to message people who did not ask to hear from you.
  • Open the script project attached to the form. In the form, click the three-dot menu at the top right and choose Script editor.
  • Sign in as the account that should appear as the sender, because the trigger sends mail as the account that installs it.

Change these values

Change these values

Make the code yours before you run it.
Email subject
Thanks for your response

This is the subject the respondent sees.

Opening line
Thank you for your response. Here is a copy of your answers.

The first line of the message. Change it to your own wording.

Closing line
This confirmation was sent automatically. There is no need to reply.

The last line of the message. It tells the reader the email is automatic.

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 each new response to this Form, including the collected email address.
  • 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 one confirmation to the respondent. It comes from the account that installed the trigger.

Effects of one run

  • Sends one email to the verified respondent address after each new submission, listing every question title and the answer given.
  • Sends nothing when the response has no email address, for example when Collect email addresses is off.
  • Does not change or delete any form response, and does not email anyone except the verified account that submitted the form.

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 = 'Thanks for your response'; // This is the subject the respondent sees.
const OPENING_LINE = 'Thank you for your response. Here is a copy of your answers.'; // The first line of the message. Change it to your own wording.
const CLOSING_LINE = 'This confirmation was sent automatically. There is no need to reply.'; // The last line of the message. It tells the reader the email is automatic.

/** @param {Events.FormsOnFormSubmit} event */
function emailRespondentConfirmation(event) {
  const response = event.response;
  const respondentEmail = response.getRespondentEmail();
  if (!respondentEmail) return;

  const answers = response.getItemResponses().map((itemResponse) => {
    return itemResponse.getItem().getTitle() + ': ' + itemResponse.getResponse();
  });

  const message = OPENING_LINE
    + '\n\n' + answers.join('\n')
    + '\n\n' + CLOSING_LINE;

  GmailApp.sendEmail(respondentEmail, EMAIL_SUBJECT, message);
}

4 · Run

Follow these steps in order

  1. Check the form setting first

    In the form, click Settings, open Responses, and check that Collect email addresses is set to Verified. When a response has no address, the script stops without an error and sends nothing.

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

  3. Install the trigger

    Click Triggers, the clock icon in the left sidebar, then click Add Trigger. Choose emailRespondentConfirmation 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.

  4. Submit one test response yourself

    Open the form as a respondent while signed in to your own Google account and submit it. Within a minute, an email with the subject Thanks for your response arrives in that inbox. Check it before you share the form with anyone else.

5 · Confirm

How to tell it worked

Seconds after a submission, the verified address on the response receives a short thank you that repeats each question and answer.

If the result is different

Troubleshooting

No confirmation arrives after a test submission.
Check that Collect email addresses is set to Verified in the form settings, and that the trigger under Triggers runs emailRespondentConfirmation with From form and On form submit. Submit a new test response after you turn on verified collection. Earlier responses do not get a confirmation.
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.
The confirmation comes from the wrong sender.
Delete the trigger, sign in as the account that should send the mail, and install the trigger again. The sender is always the account that installed the trigger.
The answer to a checkbox or grid question prints with commas between the choices.
Change the line that builds each answer if you want another layout. Those answers arrive as a list, and joining a list with a string puts commas between the items.

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