Skip to content

Instantly share code, notes, and snippets.

@dheerajsharma14
Forked from eyalway2cu/gforms_webhook.js
Created September 9, 2025 17:07
Show Gist options
  • Select an option

  • Save dheerajsharma14/ea33a3c2d095e9dfcc160a67ae4e7235 to your computer and use it in GitHub Desktop.

Select an option

Save dheerajsharma14/ea33a3c2d095e9dfcc160a67ae4e7235 to your computer and use it in GitHub Desktop.
Google Forms Webhook Script
var POST_URL = "enter your webhook URL";
function onSubmit(e) {
var form = FormApp.getActiveForm();
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.getItemResponses();
var payload = {};
for (var i = 0; i < response.length; i++) {
var question = response[i].getItem().getTitle();
var answer = response[i].getResponse();
payload[question] = answer;
}
var options = {
"method": "post",
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
UrlFetchApp.fetch(POST_URL, options);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment