Skip to content

Task guide

Send a confirmation to the form respondent

When the form collects verified email addresses, a form submit trigger can send the person who answered a short thank you that repeats their answers.

1 · Prepare

Put these pieces in place

  • Turn on Collect email addresses in the form. Open the form, choose Settings, open Responses, and set Collect email addresses to Verified. Without verified collection, the script has no verified respondent 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 itself. In the form, use 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

  • Read the responses submitted to this Google Form, including the collected email address.
  • Send email from the Google account that installed the trigger. That account is the sender the respondent sees.
  • Create and view triggers in this Apps Script project.

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 safely

Follow these steps in order

  1. Check the form setting first

    In the form, open Settings, then Responses, and confirm that Collect email addresses is set to Verified. The script stops quietly when a response carries no address.

  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 press Run in the editor, because there is no submitted response there to work with.

  3. Install the trigger

    Open Triggers in the left sidebar, choose Add Trigger, pick emailRespondentConfirmation, then choose From form and On form submit. Approve access when Google asks.

  4. Submit one test response yourself

    Submit the form while signed in to your own verified Google account. Check that account’s inbox for the confirmation 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 is set to From form and On form submit. Submit a new test response after enabling verified collection; earlier responses are not resent.
Running the function in the editor fails with a message about reading response of undefined.
That is expected. The function needs a real submission to supply the event, so test it by submitting the form instead of pressing Run.
The confirmation comes from the wrong person.
The sender is the account that installed the trigger. Delete the trigger, sign in as the account that should send the mail, and install the trigger again.
The answers look odd for a checkbox or grid question.
Those answers arrive as a list, so they print with commas between the choices. Adjust the line that builds each answer if you want another layout.

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