Skip to content

Instantly share code, notes, and snippets.

@petarjs
Created July 3, 2024 19:00
Show Gist options
  • Save petarjs/9d1173742722c1459fd2d587c2d88bb7 to your computer and use it in GitHub Desktop.
Save petarjs/9d1173742722c1459fd2d587c2d88bb7 to your computer and use it in GitHub Desktop.
var POST_URL = "https://api.automateo.app/api/w/<WorkflowId>";
var apiKey = "<AutomateoApiKey>";
function onSubmit(e) {
var form = FormApp.getActiveForm();
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.getItemResponses();
var email = latestResponse.getRespondentEmail();
var payload = {};
for (var i = 0; i < response.length; i++) {
var question = response[i].getItem().getTitle();
var answer = response[i].getResponse();
payload[question] = answer;
}
payload['email_to'] = email;
var options = {
"method": "post",
"contentType": "application/json",
"payload": JSON.stringify({input: payload}),
"headers": {
"Authorization": "Bearer " + apiKey,
},
};
UrlFetchApp.fetch(POST_URL, options);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment