Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save knpFletcher/dceb7e85b73070d8b6b55cacf83e8fee to your computer and use it in GitHub Desktop.
Save knpFletcher/dceb7e85b73070d8b6b55cacf83e8fee to your computer and use it in GitHub Desktop.
Google Form to Trello Board via Email
/*
If you want entries on a Google form to auto-create a Trello card,
you can follow the steps below.
There are two ways to connect a Google form to a Trello board. One of them
involves using the Trello API. This version instead works by sending an email to a
Trello board's private email address and then it creates cards based off the content
of the email.
Trello will make a card with a title that matches the "subject" line of the
email. The description will match the message within the email.
1. Create a Google form with a number of questions.
2. In the More settings of the Google form (kebab menu), select "< > Script Editor"
3. Replace the pre-existing text with the text from this form.
4. Adapt the code:
- Replace the email address that the script will send to with the email address you find on the Trello board. (Menu > More > Email-to-Board Settings)
- Change the content of the email message.
5. On the code page, go to Resources > Edit > All Your Triggers. Add a new trigger that runs onFormSubmit. (This will run the "onFormSubmit" function in your code when someone clicks "Submit" on the Google Form.
6. When prompted, provide necessary permissions for your google script to send emails on your behalf, etc.
*/
//Form Variables
var form; //this is your Google form
var responses; //is a collection of all the responses that are provided by the google form
//Google Form responses
//these are the individual responses that come with your form. Change the number of your what.
var entry1;
var entry2;
var entry3;
//email content
var trelloEmail = "example@email.com"; //This is the email address of your trello board.
var trelloTitle; //This is the Subject Line of the email your script will send.
var trelloDescription; //This is the Body of the email your script will send.
function onFormSubmit(e) {
form = FormApp.getActiveForm();
responses = e.response.getItemResponses();
//assign variables
AssignVariables();
//build email
BuildEmail();
//send email
SendEmail();
}
//Get the value of variables from the form
function AssignVariables(form){
entry1 = responses[0].getResponse();
entry2 = responses[1].getResponse();
entry3 = responses[2].getResponse();
}
function BuildEmail(){
trelloTitle = 'Google Form Entry';
trelloDescription = 'Values from your Google form include: ' + '\n' + entry1 + ', ' + entry2 + ', ' + entry3 + '.';
}
function SendEmail(){
MailApp.sendEmail(trelloEmail, trelloTitle, trelloDescription);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment