Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Send Google Forms to Slack

# read more about slack web hooks here: https://api.slack.com/incoming-webhooks

var POST_URL = "https://hooks.slack.com/services/YOUR_TOKEN";

function onSubmit(e) {
var response = e.response.getItemResponses();

var toType = function(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}

// "Form Respondent: " + e.response.getRespondentEmail()

var email = response[0].getResponse();
var field2 = response[1].getResponse();
var field3 = response[2].getResponse();
var field4 = response[3].getResponse();

var d = "*SUBMITTED FORM*\n>>>Email: " + email + "\n";

d += "other fields: \n" + field2 + field3 + field4;

var payload =
{ "payload": '{"text": "' + d + '"}' }

var options =
{
"method" : "post",
"payload" : payload
};

UrlFetchApp.fetch(POST_URL, options);
};

You need to add javascript code above to Script Editor section of google form. When you are in form editing mode click the three dot in top corner and click on Script Editor. When your're done click on save and give a name to your project script. Now on the script editor page click on edit -> All your triggers and bind your script to form onSubmit event.

Read more about webhooks for slack here:
- here: https://api.slack.com/incoming-webhooks

That's all! Now will have all your submitted forms in Slack. Voila!

#google #slack #forms #google_forms #webhook #hook #javascript