Answerfinch

Send email based on a Google Forms answer with Apps Script

You can use a form submit trigger to read an answer and send an email only when it matches. Use the example below to email yourself when someone selects Refund. Use an add-on if you want to set that kind of rule inside the form without maintaining the script.

By Lazy Labs. . Example checked against the linked Apps Script documentation.

Make a test form and add the script

  1. Open a test form in Google Forms™. Add one required multiple choice question titled “Request type.” Add Refund and Other as the choices. Enter “Other” as a regular choice.
  2. Open More, then Apps Script, from the form editor. This binds the script to the form. Don't open Apps Script from the linked response spreadsheet for this example.
  3. Paste the code below. Replace you@example.test with your own address. Save the project.
function emailOnFormSubmit(e) {
  const recipient = 'you@example.test';
  if (recipient.endsWith('@example.test')) {
    throw new Error('Set your own test email address first.');
  }
  if (!e || !e.response) {
    throw new Error('Submit the test form to run this function.');
  }

  const items = e.response.getItemResponses();
  const matching = items.filter(
    item => item.getItem().getTitle() === 'Request type'
  );

  if (matching.length !== 1 || matching[0].getResponse() !== 'Refund') {
    return;
  }

  MailApp.sendEmail(recipient, 'New refund request',
    'Someone selected Refund. Open the form to review the response.');
}

Use the exact question title and choice in the code. If you rename either one, update the script. Keep the question title unique. You get an email saying someone selected Refund. You won't see their address or other answers in the message.

Add the trigger and submit a response

  1. In Apps Script, open Triggers and choose Add Trigger. For the function, select emailOnFormSubmit. Set the event source to From form and the event type to On form submit. Choose Save.
  2. Review the permissions to read form responses and send email before you authorize the script. Install the trigger with the Google account you want to send from.
  3. Submit the test form as a respondent. Choose Refund, then check your inbox. Submit another response with Other. The script skips that response.

Use the real submit button for the test. The editor's Run button doesn't supply the form event. Google uses a different event object for a Sheets form submit trigger. If the email doesn't arrive, check Executions in Apps Script and look in spam.

See Google's docs for installable triggers, MailApp and current sending limits. This is a test example. It doesn't keep a send log or prevent duplicate sends if you install more than one matching trigger.

When to use an add-on, and when to keep the script

With Answerfinch, choose the question, Is equal to, Refund and This address. You can preview the message with a sample response, send yourself a test and check recorded attempts in Send log. On Free you can run one rule at a time across your Google account.

Keep your script if you need to match two separate questions in one rule or look up a recipient in another system. Answerfinch matches one question per rule. You choose a fixed address or the respondent's address from the form.

If you already send these emails from a script, test the new rule on a form copy first. When you switch the live form, disable only the old trigger you have confirmed sends the same email. If someone else owns that trigger, ask them to check it with you. Submit a fresh test after switching and check that you get one email.

Related guides

Install AnswerfinchFree plan included