Skip to content

Instantly share code, notes, and snippets.

@codeas
Last active March 16, 2023 11:24
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save codeas/1fd5697037bc5ebb2b31 to your computer and use it in GitHub Desktop.
Save codeas/1fd5697037bc5ebb2b31 to your computer and use it in GitHub Desktop.
gas2slack by incoming webhook
function START() {
var url = "https://hooks.slack.com/services/xxxxxx/xxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxx";
var payload = {
"channel" : "#test", // <-- optional parameter, use if you want to override default channel
"username" : "robot", // <-- optional parameter, use if you want to override default "robot" name
"text" : "It's working", // <-- required parameter
"icon_emoji": ":robot_face:", // <-- optional parameter, use if you want to override default icon,
//"icon_url" : "http://image" // <-- optional parameter, use if you want to override default icon
}
sendToSlack_(url,payload)
}
function sendToSlack_(url,payload) {
var options = {
"method" : "post",
"contentType" : "application/json",
"payload" : JSON.stringify(payload)
};
return UrlFetchApp.fetch(url, options)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment