Heyah,

I have written a short script automatically posting new Google-Form-Entries to Discourse. You can use it to allow any kind of 3-party Data input into discourse for example:

  • Anonymous Feedback
  • Support-Request
  • Membership-Applications (this is what we do with it)

The script

The script is small and simple:

// ----- MINIMUM CONFIGURATION !!!!
// generate this at /admin/api
API_KEY = "d29dXXXXXXXXXXXXXXXXXXXXX70"
// use full qualified domain name in url to discourse index
TARGET_INSTALLATION = "http://DISCOURSE.EXAMPLE.ORG/"

// ----- Optional Configuartion

// which category to post this to? Default: 'uncategorized'
CATEGORY = 'uncategorized'
// which user should be the one posting? Default: 'system'
POSTER = "system"

// you probably wanna activate this, when using templates
INCLUDE_RAW_DATA = true

// the title to post at,
// should contain any 'form'-replacer or Discourse might complain it already has that title
TITLE_TEMPLATE = "New Form Entry: "

// Wanna have it look pretty?
TEMPLATE  = "# \n\n - Water Type: " + 
             

function _compile(source, values){
    var processed = source;
    for (key in values) {
      processed = processed.replace(" + key + ", values[key]);
    }
    return processed;
  }


function _compile_data_from_form(formResponse){
  var data = {},
      itemResponses = formResponse.getItemResponses();
  for (var j = 0; j 

Installation

  1. Generate an ADMIN-Key of your installation at /admin/api
  2. Add Script to a new googles form or existing one via Tools-> Script Editor

  3. Copy the entire script into the new Editor that opens
  4. Replace the API-Key in the script with the one from your installation,
    Change the Installation-Target-Name
  5. Save and check your configuration by running the “API_TEST” function:

  6. A new post should show up in your Discourse.
    – you might want to do redo this one until the configuration (posting user, posting in proper category) are all figure out
  7. Connect function to trigger by going to Resources->All Triggers and an on-form-submit-trigger connected to the postToDiscourse function:

    (you might be asked to give permission when saving the first time: yes, please do so)

Voilá, you’ll receive new posts (including all update and email features) of forms submitted in your discourse instance from now on.

You might want to also take a look at my “automatically email form-data” script and add that one, too. As always, feel free to posts questions, feedback and praise right down here as replies :) .

Source: https://meta.discourse.org/t/any-kind-of-data-input-also-anonymous-through-google-forms/21008