Slack To Tweet
An npm module that returns a simple server that will post from a slack channel to twitter.
Install
npm i slack-to-tweet
Use
Set up an outgoing webhook for the slack channel you would like to connect to twitter. In twitter set up an application, and acquire the keys for that application. Implement the code below and deploy the server (heroku deployment is very easy). The formatMessage
function allows you to contorl the output of the message. Currently messages over 140 characters will not be posted. The shouldTweet
function should return a boolean that determines whether or not a tweet will be sent.
You may pass through an optional userMap
paramater utilizing slack username as the key and twitter username as the value. If there is match in the map, it will default to the slack username.
var slackToTweet = ; var slackToTweetSettings = twitterConsumerKey: processenvCONSUMER_KEY twitterConsumerSecret: processenvCONSUMER_SECRET twitterAccessTokenKey: processenvACCESS_TOKEN twitterAccessTokenSecret: processenvACCESS_TOKEN_SECRET { return user !== "conor"; } { return "From " + user + ": " + message; } userMap: conor: "@stillconor" ; var slackToTweetServer = ;