Skip to content

Instantly share code, notes, and snippets.

@mahya8585
Created October 13, 2016 06:47
Show Gist options
  • Select an option

  • Save mahya8585/22684b2036aea9723c11b8bfda45fd5d to your computer and use it in GitHub Desktop.

Select an option

Save mahya8585/22684b2036aea9723c11b8bfda45fd5d to your computer and use it in GitHub Desktop.
googleフォームから通知するスクリプト(メールアドレス収集設定付き)
function sendToSlack(body, channel) {
var url = "【incomingHookの設定URL】";
var data = { "channel" : channel, "username" : "ぐーぐるふぉーむ通知君", "text" : body, "icon_emoji" : ":hatched_chick:" };
var payload = JSON.stringify(data);
var options = {
"method" : "POST",
"contentType" : "application/json",
"payload" : payload
};
var response = UrlFetchApp.fetch(url, options);
}
function test() {
sendToSlack("It's a test message", "#general")
}
function onFormSubmit(e){
var body = "【" + e.response.getRespondentEmail() + "】\n";
var itemResponse = e.response.getItemResponses();
var bodyPublic = "";
for (var j = 0; j < itemResponse.length; j++){
var formData = itemResponse[j];
var title = formData.getItem().getTitle();
var response = formData.getResponse();
body += title + "\n";
body += response + "\n\n";
}
sendToSlack(body, "#general");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment