Created
February 6, 2018 04:45
-
-
Save manse/5c98ac8f20061a4c1b9447a6e772082d to your computer and use it in GitHub Desktop.
post to slack channel
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
const fetch = require('node-fetch'); | |
function post_message(channel, text) { | |
const obj = { | |
token: 'xoxb-aaaaaaaaaaa', | |
channel, | |
as_user: true, | |
text | |
}; | |
fetch('https://slack.com/api/chat.postMessage', { | |
method: 'POST', | |
body: Object.keys(obj).map((key) => key + '=' + encodeURIComponent(obj[key])).join('&'), | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment