Created
October 13, 2016 06:47
-
-
Save mahya8585/22684b2036aea9723c11b8bfda45fd5d to your computer and use it in GitHub Desktop.
googleフォームから通知するスクリプト(メールアドレス収集設定付き)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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