Created
April 15, 2021 03:17
-
-
Save mcnaveen/65383f07fb55e986cda6b5123445154d to your computer and use it in GitHub Desktop.
Send Data from Google Forms to External API or Webhook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Originally Authored by @mskian for Pushbullet: https://gist.github.com/mskian/96c5385cef64ca99de7994387348e2a6
This is the Customized version of that script.