Create Trello Cards from a Google Form with Google Scripts

C
Published in: Google Forms - Google Apps Script

Trello provides you a unique email address (like xyz@boards.trello.com) for any board in you account and any email message sent to this address is added as a new card to the Trello Board. @jezhou has written a Google Scripts that redirects Google Form submissions to a Trello using this email option.

When a Google Form is submitted, the onFormSubmit() event is triggered which then forwards the Google Form data to Trello via the GmailApp service. The subject is the title of the card while the email body goes in the description field. The script may be extended to forward Google Form entries to other services like WordPress, Evernote, Pocket, Tumblr, etc. since they too allow posting via Email.

// Credit: https://gist.github.com/jezhou/

// Fire off this function in the script editor to enable.

// Fire off this function in the script editor to enable.
function init() {

  var triggers = ScriptApp.getProjectTriggers();
  var form = FormApp.getActiveForm();

  // Delete all triggers before making a brand new one.
  for(var i in triggers) {
    ScriptApp.deleteTrigger(triggers[i]);
  }

  // Set up a new trigger
  ScriptApp.newTrigger('submitToTrello')
           .forForm(form)
           .onFormSubmit()
           .create();

  Logger.log('Successful creation of new submitToTrello trigger.');

}

function submitToTrello(e) {

  var form = FormApp.getActiveForm();
  var latestItemResponses = form.getResponses().pop().getItemResponses();

  if (MailApp.getRemainingDailyQuota() > 0) {

    // Trello email address goes here
    var email = "ctrlq@boards.trello.com";

    // Subject line will be the title of the event on Trello card
    var subject = latestItemResponses[3].getResponse();

    // Intial empty body
    var body = "";

    // Loop through recent responses and format them into string
    latestItemResponses.forEach(function (value, index, array) {
      var formatted = Utilities.formatString("**%s**\n %s\n\n", value.getItem().getTitle(), value.getResponse());
      body = body.concat(formatted);
    });

    MailApp.sendEmail(email, subject, body);
  }

}
📮  Subscribe to our Email Newsletter for Google tips and tutorials!
Published in: Google Forms - Google Apps Script

Looking for something? Find here!

Meet the Author

Web Geek, Google Developer Expert
A
Amit Agarwal

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India. He is the developer of Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Get in touch

Google Add-ons

Do more with your Gmail and GSuite account
G

We build bespoke solutions that use the capabilities and the features of Google Workspace for automating business processes and driving work productivity.

  1. Mail Merge with Attachments
    Send personalized email to your Google Contact with a Google Sheet and Gmail
  2. Save Emails and Attachments
    Download email messages and file attachments from Gmail to your Google Drive
  3. Google Forms Email Notifications
    Send email notifications to multiple people when a new Google Form is submitted
  4. Document Studio
    Create beautiful pixel perfect documents merging data from Google Sheets and Google Forms
  5. Creator Studio for Google Slides
    Turn your Google Slides presentations into animated GIFs and videos for uploading to YouTube