This project is a Google Apps Script for google forms that sends an email to voters notifying them about their vote eligibilities upon form submission. It uses matching the main voting processor's and fetches video data from an external service. The endpoint for fetching video data is currently set with my domain brambles-c.com
, but would be changed when the actual server is set up
- In a form with short answer boxes, you can attach a script to it by using the script editor button as shown in the image below
![Script_btn](https://private-user-images.githubusercontent.com/74834218/335878948-37f9796d-5e0c-46d0-be5a-db64851c7ba4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzc4MTMsIm5iZiI6MTczOTI3NzUxMywicGF0aCI6Ii83NDgzNDIxOC8zMzU4Nzg5NDgtMzdmOTc5NmQtNWUwYy00NmQwLWJlNWEtZGI2NDg1MWM3YmE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDEyMzgzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI0ZTVhMzQxZWE2Y2E1N2UyYTUyNjdhMDdhNjE1ZWNmNTliMzFlOWVjM2FhNTZkMGY2MzFlODVkZjMzN2FhNGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8kCyOikfKjp5Xq03bc8UcWTHQDhpezhqTP5jDGVp_gI)
- Rename the .json files by removing
.template
from them - Set the timezone in
appsscript.json
(e.g., America/Los_Angeles) - Configure
.clasp.json
with the properrootDir
and the script ID. The script ID can be found in the Apps Script project settings.
- Deploying to the Apps Script is done with the clasp command-line tool, which can be installed by running:
npm install -g @google/clasp
- To allow clasp to edit your Apps Scripts, log in to your google account with:
clasp login
- Pushing all of the local project files into the Apps Script is done by
cd
'ing into the project directory and run
clasp push
- A trigger needs to be added so that the form will execute the main function whenever a form response is submitted
To do this:
- Navigate to the
Triggers
page - Add a trigger
- Match settings with the image
- Save
(Optional): Set how often you'd like to be emailed of execution failures within a specified time frame
![Script steps 2](https://private-user-images.githubusercontent.com/74834218/336162431-e85b1eeb-55da-42f4-b858-e8ab4c2805b4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzc4MTMsIm5iZiI6MTczOTI3NzUxMywicGF0aCI6Ii83NDgzNDIxOC8zMzYxNjI0MzEtZTg1YjFlZWItNTVkYS00MmY0LWI4NTgtZThhYjRjMjgwNWI0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDEyMzgzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY0MWIyMDUyZmE5NGVkZWRiYmM0ZTBhYjQwMGU5NDg0ZWIwNTJiY2Y1ZGVjZDEzNjZjYzc2MmYyYjU3YmU5MWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.cuSUV4qb7OFH-lmsDNzOnlA9p64z1mPRqKeY0DTqvDw)
- The Apps Script requires authorization for the specified permissions (listed below) in order to run. Clicking
run
ordebug
with any function selected will show the authorization prompt
Now when a form response is submitted, and if it has an email in the last response box, the eligibility of the urls for the current voting period will be sent to them
In order to function, the script requires the following permissions specified in appsscript.json:
- View and manage forms that this application has been installed in
- Send email on the account's behalf
- Connect to an external service