Google Forms App Scripts
Jump to navigation
Jump to search
About
NOTE: This page is a daughter page of: Google Forms
The Google Forms App Script feature allows a little extra functionality, potentially integrating with other products (like calendars, and sending emails). It is written in JavaScript, here's a simple example below of sending a custom email after the form is submitted.
How To: To Create a "Custom Email Reply" Add-On via App Scripts
The right API to help is the Google Docs API... but that's slow to process, so here's what you need to do to create a new menu item that does something:
- Create a brand new Google Doc ............... (tip: Try typing into Chrome: docs.new)
- Click menu bar: Extensions > App Scripts.
- Enter the javascript code below into the Script Editor and hit "Save" and "Deploy" (as "Editor Add-On")
..... (tip: You can hit the play button to test one of the functions before saving) - Reload your Google Doc and approve permissions.
- Run the Script by clicking the new menu item that appears: Custom Email Reply.
(see pictures of this process)
Here's the code to add.
Code.gs
function sendEmail(e) {
var email = e.response.getRespondentEmail(); // Get the collected email address... must have that option switched on in settings.
// NOTE: Probably we could get their correct email via `e.values[6]` but let's just go with human.
var subject = "Thank you for your registration!";
var message = "Hi there amazing human,\n\n" +
"Thank you for your registration! We've received your application form and are in the process of balancing gender and age groups for our events. We appreciate your patience and will send you a link to book your ticket soon! ❤️\n\n" +
"Warm regards,\n" +
"-- The Breath Collective";
MailApp.sendEmail(email, subject, message);
}
function onFormSubmit(e) {
sendEmail(e);
}
function setUpTrigger() {
var form = FormApp.openById('11HW0on-gBYQOq6HFr6n8JoMgX3zd_UjOU0FuKYdUmlY'); // Replace with your Form ID
ScriptApp.newTrigger('onFormSubmit')
.forForm(form)
.onFormSubmit()
.create();
}
Links
- Google Docs API - About the API.