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
- Email subject
Thanks for your responseThis 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.
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
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.
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.
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.
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
Apps Script symbols
Service pages
Keep going
Related tasks, basics, and apps
- Task guide Respond to a Google Form submission
Add a small response function, then install a form-submit trigger so each new answer produces a private email summary.
- Task guide Run an Apps Script function every day
Run the setup function once, then Apps Script calls the reminder function each day around your chosen hour.
- Object reference Form
A FormApp.Form is the Google Form itself. Reach it with FormApp.getActiveForm() or openById(id) to 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 Item response
An ItemResponse pairs one Google Form question with the answer submitted for it. Reach item responses from formResponse.getItemResponses(), then call getItem().getTitle() and getResponse().
- Object reference Trigger builder
ScriptApp.newTrigger(functionName) returns a TriggerBuilder that configures a timeBased(), forSpreadsheet(), or forForm() trigger before create() saves it.
- 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 Gmail
GmailApp scripts can send messages, search threads, apply labels, and read attachments after you approve Gmail access for the project.
- 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.