At the moment Make (Integromat) does not have an instant trigger for Google Forms. I found a workaround online that uses a webhook via Google Apps Script. It works great except when there are non-answered questions on the form or questions with the same name; it only fetches the fields when the questions are answered. Is there a way to modify the code to fetch the entire form's array of questions instead of only the answers? I have very little experience with JavaScript, so some assistance would be great.
Here is the code:
function sendWebhook(e) {
var url = 'Make_Webhook_URL';
var data = {
"form": {
"id": e.source.getId(),
"title": e.source.getTitle() ? e.source.getTitle() : "Form_Title_Here",
"is_private": e.source.requiresLogin(),
"is_published": e.source.isAcceptingResponses(),
},
"response": {
"id": e.response.getId(),
"timestamp": e.response.getTimestamp(),
"email": e.response.getRespondentEmail(),
"edit_url": e.response.getEditResponseUrl(),
"payload": e.response.getItemResponses()
.map(function(y) {
return {
h: y.getItem().getTitle(),
k: y.getResponse()
}
}, this)
.reduce(function(r, y) {
r[y.h] = y.k;
return r
}, {})
},
};
var options = {
method: "post",
payload: JSON.stringify(data, null, 2),
contentType: "application/json; charset=utf-8",
};
UrlFetchApp.fetch(url, options);
}
Many Thanks