/* 
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 settings of the Google form, select "< > Script Editor"
3. Replace the pre-existing text with the text from this form.
4. Adapt the code:
   - Replace the email adress 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 goolge 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, title, message);
}