EDITORIAL

Survey Form Webhook Guidelines

Yuvin Kim

August 31, 2023

EDITORIAL

Survey Form Webhook Guidelines

Yuvin Kim

August 31, 2023

The existing app.walla.my does not currently offer this feature. Please note that you should use the open beta version at app.wallaform.com.


  1. Creating a Google Sheet
(1-a) When Creating a New One

Access Google Drive and create a new Google Sheet.

(1-b) When Already Linked to Walla and Exporting Before Reconnecting

Select the already in-use Google Sheet, make a copy of it.

Once the copy is created, proceed with the following 2 steps.


(+) If you want to delete the existing Google Sheet:

Click the toggle on the right side of the Google Sheet integration.

Confirm that the toggle is set to OFF along with the Google Sheet deletion message.


  1. Google Apps Script Configuration

(1) In the Google Sheet, select the top menu "Extensions" > "Apps Script."

(2) In the code editor that appears, delete the existing code and paste the code below.

function doPost(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  ss.setSpreadsheetTimeZone('Asia/Seoul');
  // Parsing the POST data to get the required data
  var data = JSON.parse(e.postData.contents);
  
  var formAnswers = data.form_answers;
  var submittedAt = new Date(data.form_response.submitted_at);

  var responseId = data.form_response.response_id.slice(0,10);
  // First row: labels
  if (sheet.getLastRow() === 0) {
    var fieldLabels = formAnswers.map(function(answer) {
      if (answer.type === 'RADIO_GRID' || answer.type === 'CHECKBOX_GRID') {
        return answer.response.map(el => `${answer.label} - ${el.lineLabel}`);
      }
      return answer.label
    }).flat();
    var headers = ['Response ID', 'Time Submitted', ...fieldLabels]
    sheet.appendRow(headers);
  } 
   var rowData = formAnswers.map(field => {
      switch (field.type) {
        case 'CHECKBOX':
        case 'RADIO': {
          var isResponseArray = Array.isArray(field.response);
          if (isResponseArray) {
            return field.response.filter(el => Boolean(el)).join(', ');
          }
          return field.response || '';
        }
        case 'CHECKBOX_GRID':
        case 'RADIO_GRID': {
          var isLineResponseArray = Array.isArray(field.response.lineResponse)
          return field.response.map(el => {
            if (isLineResponseArray) {
              return el.lineResponse.filter(el => Boolean(el)).join(', ');
            }
            return el.lineResponse || '';
          })
        }
        case 'GEOLOCATION': {
          var response = field.response || {};
          var responseArray = Object.entries(response).map(el => `${el[0]}: ${el[1]}`);
          return responseArray.join(', ');
        }
        case 'HIDDEN': {
          return field.response === undefined || field.response === null
            ? ''
            : field.response;
        }
        default: {
          var response =
            field.response === undefined || field.response === null ? '' : field.response;
          if (Array.isArray(response)) {
            return response.join(', ');
          }
          return response;
        }
      }
    }).flat();
  sheet.appendRow([responseId, submittedAt, ...rowData]);
  return ContentService.createTextOutput(JSON.stringify({result: "success"})).setMimeType(ContentService.MimeType.JSON);
}

  1. Deploy as a Web App

(1) In the code editor's top menu, select "Deploy" > "New Deployment."

(2) Click the "Settings" button, then choose "Web App."

(3) Provide a name (e.g., test1) and be sure to set access rights to 'Anyone.'

(4) Finally, click "Deploy," and an "Authorization Required" button will appear.

(5) Click it to proceed with authorization.

(6) Click on your own Google account that created the Google Sheet.

(7) Click "advanced" at the bottom left, then proceed with the unsafe version at the bottom.


  1. Copy the URL of the web app

(1) Copy the URL of the web app that appears after deployment.


  1. Integration with the Walla Platform (Webhook)

(1) Access the Walla platform page and select the project you want to integrate.

(2) On the "Integration" page, click the "Add New Webhook" button.

(3) Enter a name freely and paste the URL of the web app copied earlier.

(4) Since the current webhook does not provide test requests, save the webhook and return to the integration.


  1. Testing and Verification

Submit responses for the project in the Walla platform to confirm that data is being sent to the Google Sheet via the webhook.

The existing app.walla.my does not currently offer this feature. Please note that you should use the open beta version at app.wallaform.com.


  1. Creating a Google Sheet
(1-a) When Creating a New One

Access Google Drive and create a new Google Sheet.

(1-b) When Already Linked to Walla and Exporting Before Reconnecting

Select the already in-use Google Sheet, make a copy of it.

Once the copy is created, proceed with the following 2 steps.


(+) If you want to delete the existing Google Sheet:

Click the toggle on the right side of the Google Sheet integration.

Confirm that the toggle is set to OFF along with the Google Sheet deletion message.


  1. Google Apps Script Configuration

(1) In the Google Sheet, select the top menu "Extensions" > "Apps Script."

(2) In the code editor that appears, delete the existing code and paste the code below.

function doPost(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  ss.setSpreadsheetTimeZone('Asia/Seoul');
  // Parsing the POST data to get the required data
  var data = JSON.parse(e.postData.contents);
  
  var formAnswers = data.form_answers;
  var submittedAt = new Date(data.form_response.submitted_at);

  var responseId = data.form_response.response_id.slice(0,10);
  // First row: labels
  if (sheet.getLastRow() === 0) {
    var fieldLabels = formAnswers.map(function(answer) {
      if (answer.type === 'RADIO_GRID' || answer.type === 'CHECKBOX_GRID') {
        return answer.response.map(el => `${answer.label} - ${el.lineLabel}`);
      }
      return answer.label
    }).flat();
    var headers = ['Response ID', 'Time Submitted', ...fieldLabels]
    sheet.appendRow(headers);
  } 
   var rowData = formAnswers.map(field => {
      switch (field.type) {
        case 'CHECKBOX':
        case 'RADIO': {
          var isResponseArray = Array.isArray(field.response);
          if (isResponseArray) {
            return field.response.filter(el => Boolean(el)).join(', ');
          }
          return field.response || '';
        }
        case 'CHECKBOX_GRID':
        case 'RADIO_GRID': {
          var isLineResponseArray = Array.isArray(field.response.lineResponse)
          return field.response.map(el => {
            if (isLineResponseArray) {
              return el.lineResponse.filter(el => Boolean(el)).join(', ');
            }
            return el.lineResponse || '';
          })
        }
        case 'GEOLOCATION': {
          var response = field.response || {};
          var responseArray = Object.entries(response).map(el => `${el[0]}: ${el[1]}`);
          return responseArray.join(', ');
        }
        case 'HIDDEN': {
          return field.response === undefined || field.response === null
            ? ''
            : field.response;
        }
        default: {
          var response =
            field.response === undefined || field.response === null ? '' : field.response;
          if (Array.isArray(response)) {
            return response.join(', ');
          }
          return response;
        }
      }
    }).flat();
  sheet.appendRow([responseId, submittedAt, ...rowData]);
  return ContentService.createTextOutput(JSON.stringify({result: "success"})).setMimeType(ContentService.MimeType.JSON);
}

  1. Deploy as a Web App

(1) In the code editor's top menu, select "Deploy" > "New Deployment."

(2) Click the "Settings" button, then choose "Web App."

(3) Provide a name (e.g., test1) and be sure to set access rights to 'Anyone.'

(4) Finally, click "Deploy," and an "Authorization Required" button will appear.

(5) Click it to proceed with authorization.

(6) Click on your own Google account that created the Google Sheet.

(7) Click "advanced" at the bottom left, then proceed with the unsafe version at the bottom.


  1. Copy the URL of the web app

(1) Copy the URL of the web app that appears after deployment.


  1. Integration with the Walla Platform (Webhook)

(1) Access the Walla platform page and select the project you want to integrate.

(2) On the "Integration" page, click the "Add New Webhook" button.

(3) Enter a name freely and paste the URL of the web app copied earlier.

(4) Since the current webhook does not provide test requests, save the webhook and return to the integration.


  1. Testing and Verification

Submit responses for the project in the Walla platform to confirm that data is being sent to the Google Sheet via the webhook.

The existing app.walla.my does not currently offer this feature. Please note that you should use the open beta version at app.wallaform.com.


  1. Creating a Google Sheet
(1-a) When Creating a New One

Access Google Drive and create a new Google Sheet.

(1-b) When Already Linked to Walla and Exporting Before Reconnecting

Select the already in-use Google Sheet, make a copy of it.

Once the copy is created, proceed with the following 2 steps.


(+) If you want to delete the existing Google Sheet:

Click the toggle on the right side of the Google Sheet integration.

Confirm that the toggle is set to OFF along with the Google Sheet deletion message.


  1. Google Apps Script Configuration

(1) In the Google Sheet, select the top menu "Extensions" > "Apps Script."

(2) In the code editor that appears, delete the existing code and paste the code below.

function doPost(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  ss.setSpreadsheetTimeZone('Asia/Seoul');
  // Parsing the POST data to get the required data
  var data = JSON.parse(e.postData.contents);
  
  var formAnswers = data.form_answers;
  var submittedAt = new Date(data.form_response.submitted_at);

  var responseId = data.form_response.response_id.slice(0,10);
  // First row: labels
  if (sheet.getLastRow() === 0) {
    var fieldLabels = formAnswers.map(function(answer) {
      if (answer.type === 'RADIO_GRID' || answer.type === 'CHECKBOX_GRID') {
        return answer.response.map(el => `${answer.label} - ${el.lineLabel}`);
      }
      return answer.label
    }).flat();
    var headers = ['Response ID', 'Time Submitted', ...fieldLabels]
    sheet.appendRow(headers);
  } 
   var rowData = formAnswers.map(field => {
      switch (field.type) {
        case 'CHECKBOX':
        case 'RADIO': {
          var isResponseArray = Array.isArray(field.response);
          if (isResponseArray) {
            return field.response.filter(el => Boolean(el)).join(', ');
          }
          return field.response || '';
        }
        case 'CHECKBOX_GRID':
        case 'RADIO_GRID': {
          var isLineResponseArray = Array.isArray(field.response.lineResponse)
          return field.response.map(el => {
            if (isLineResponseArray) {
              return el.lineResponse.filter(el => Boolean(el)).join(', ');
            }
            return el.lineResponse || '';
          })
        }
        case 'GEOLOCATION': {
          var response = field.response || {};
          var responseArray = Object.entries(response).map(el => `${el[0]}: ${el[1]}`);
          return responseArray.join(', ');
        }
        case 'HIDDEN': {
          return field.response === undefined || field.response === null
            ? ''
            : field.response;
        }
        default: {
          var response =
            field.response === undefined || field.response === null ? '' : field.response;
          if (Array.isArray(response)) {
            return response.join(', ');
          }
          return response;
        }
      }
    }).flat();
  sheet.appendRow([responseId, submittedAt, ...rowData]);
  return ContentService.createTextOutput(JSON.stringify({result: "success"})).setMimeType(ContentService.MimeType.JSON);
}

  1. Deploy as a Web App

(1) In the code editor's top menu, select "Deploy" > "New Deployment."

(2) Click the "Settings" button, then choose "Web App."

(3) Provide a name (e.g., test1) and be sure to set access rights to 'Anyone.'

(4) Finally, click "Deploy," and an "Authorization Required" button will appear.

(5) Click it to proceed with authorization.

(6) Click on your own Google account that created the Google Sheet.

(7) Click "advanced" at the bottom left, then proceed with the unsafe version at the bottom.


  1. Copy the URL of the web app

(1) Copy the URL of the web app that appears after deployment.


  1. Integration with the Walla Platform (Webhook)

(1) Access the Walla platform page and select the project you want to integrate.

(2) On the "Integration" page, click the "Add New Webhook" button.

(3) Enter a name freely and paste the URL of the web app copied earlier.

(4) Since the current webhook does not provide test requests, save the webhook and return to the integration.


  1. Testing and Verification

Submit responses for the project in the Walla platform to confirm that data is being sent to the Google Sheet via the webhook.

Continue Reading

The form you've been searching for?

Walla, Obviously.

Paprika Data Lab Inc.

557, Yeoksam-ro, Gangnam-gu, Seoul

The form you've been searching for?

Walla, Obviously.

Paprika Data Lab Inc.

557, Yeoksam-ro, Gangnam-gu, Seoul

The form you've been searching for?

Walla, Obviously.

Paprika Data Lab Inc.

557, Yeoksam-ro, Gangnam-gu, Seoul