Skip to content

Instantly share code, notes, and snippets.

@mcnaveen
Created April 15, 2021 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcnaveen/65383f07fb55e986cda6b5123445154d to your computer and use it in GitHub Desktop.
Save mcnaveen/65383f07fb55e986cda6b5123445154d to your computer and use it in GitHub Desktop.
Send Data from Google Forms to External API or Webhook
function onFormSubmit(e) {
var url = "WEBHOOKURL"; //n8n WebHook URL
var Field1 = ' ';
var Field2 = ' ';
var form = FormApp.openById("FORMID"); // Copy the Form ID from the URL
var formResponses = form.getResponses();
var formResponse = formResponses[formResponses.length - 1];
var itemResponses = formResponse.getItemResponses();
var response1 = itemResponses[0]; // Field Starts from 0 (For Example if Name Text box in Google Form has the ID 0)
var response2 = itemResponses[1];
response1 = Field1 + response1.getResponse();
response2 = Field2 + response2.getResponse();
var data = {
"response1": response1,
"response2": response2
};
var options = {
method: "post",
headers: {
"Content-Type": "application/json"
},
payload: JSON.stringify(data),
};
var response = UrlFetchApp.fetch(url, options);
}
@mcnaveen
Copy link
Author

Originally Authored by @mskian for Pushbullet: https://gist.github.com/mskian/96c5385cef64ca99de7994387348e2a6

This is the Customized version of that script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment