// use Slack web API to get an RTM API URL request({ method: 'GET', uri: `https://slack.com/api/rtm.start`, json: true, qs: { token: process.env.SLACK_TOKEN } },(err, res, body) => { // use the url to open a new websocket const rtm = new Ws(body.url, null, {agent: null}) let lastMessageId = 0 // this is where the magic will happen rtm.on('message', (event) => { const message = JSON.parse(event) const replyMessage = { id: ++lastMessageId, type: 'message', channel: message.channel, text: 'GO CUBS' } ! rtm.send(JSON.stringify(replyMessage)) }) }) https://github.com/colestrode/fun-and-profit/tree/master/examples/01